Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
kprotty
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
5 ms
·
1.
▲
by
kprotty
6mo ago
Zig gives things we really dont have yet: C + generics + good const eval + good build system + easy cross compilation + modern niceties (optionals, errors, sum types, slices, vectors, arbitrary bit packing, expression freedom). Are there an
2.
▲
by
kprotty
6mo ago
There are places a language could be a better fit, but which haven't adopted it. E.g. most languages over typescript on the backend, most systems programming languages over Java for games.
3.
▲
by
kprotty
6mo ago
Yes, I've written a few unsafe-focused crates [0], some of which have been modified & merged into the stdlib [1] [2] exposing them to the fringe edge-cases of Rust like strict provenance. IMO, Rust is good for modeling static const
4.
▲
by
kprotty
6mo ago
I've worked on two "production" zig codebases: tigerbeetle [0] and sig [1]. These larger zig projects will stick to a tagged release (which doesn't change), and upgrade to newly tagged releases, usually a few days or mon
5.
▲
by
kprotty
10mo ago
> so you have no clue if the shared data might be incompletely modified or otherwise logically corrupted. One can make a panic wrapper type if they cared: It's what the stdlib Mutex currently does: MutexGuard checks if its panicking
6.
▲
by
kprotty
1y ago
C++'s `::` vs Zig's `.` C++'s `__builtin_` (or arguably `_`/`__`) vs Zig's `@`
7.
▲
by
kprotty
2y ago
There's compiler-level traits like `Iterator` and `Future` which enforce references. If wanting to do intrusive pointers into them, one risks creating overlapping references: https://github.com/tokio-rs/tokio/
8.
▲
by
kprotty
2y ago
Tokio's focus is on low tail -latencies for networking applications (as mentioned). But it doesn't employs yield_now for waiting on a concurrent condition to occur, even as a backoff strategy, as that fundamentally kills tail-lat
9.
▲
by
kprotty
3y ago
Thanks, seems like most are from LLVM or packed structs.
10.
▲
by
kprotty
3y ago
Are there any links / examples for the miscompilations?
11.
▲
by
kprotty
3y ago
> Green threads give you all the advantages of async They require more memory over stackless coroutines as it stores the callstack instead of changing a single state. They also allow for recursion, but its undelimited meaning you either
12.
▲
by
kprotty
3y ago
This would imply a single/global runtime along with an unrealistic API surface; For 1) It's common enough to have multiple runtimes in the same process, each setup possibly differently and running independently of each other. Ofte
13.
▲
by
kprotty
3y ago
Preemption simulates localized concurrency (running multiple distinct things logically at the same time) not parallelism (running them physically at the same time). You can have concurrency outside continuations. OS threads for example
14.
▲
by
kprotty
3y ago
getaddrinfo() is a synchronous function that can do network requests to resolve DNS. The network property isn't reflected in its function signature becoming async. You can have an async_getaddrinfo() which does, but the former is just
15.
▲
by
kprotty
3y ago
no, .Wait in C# or block_on in Rust keep the caller sync while evaluating the async callee, preventing the "bubble up".
16.
▲
by
kprotty
3y ago
> The main problem is that tokio futures are 'static An important distinction to make is that tokio Futures aren't 'static, you can instead only spawn (take advantage of the runtime's concurrency) 'static Futures
17.
▲
by
kprotty
3y ago
Replacing Pin with Rc is what they refer to as "Arc shit up". Pin avoids the need for a heap allocation like Rc/Arc entirely.
18.
▲
by
kprotty
3y ago
Tokio and glommio using interrupts is ironically another misconception. They're cooperatively scheduled so yes, a misbehaving blocking task can stall the scheduler. They can't really interrupt an arbitrary stackless coroutine like
19.
▲
by
kprotty
3y ago
The cost of switching goroutines, rust Futures, Zig async Frames, or fibers/userspace-tasks in general is on the other of a few nano-seconds whereas it's in the micro-second range for OS threads. This allows you to spawn tons of t
20.
▲
by
kprotty
3y ago
Both qualify for writing tiny web servers, cli/byte-manipulation scripts, server automation jobs, in-house GUI applications, and other small stuff. Could technically argue that these are a "relatively little overlap" dependin
21.
▲
by
kprotty
3y ago
1) That's no longer "running async code in Drop" as it's spawned/detached and semantically/can run outside the Drop. This distinction is important for something like `select` which assumes all cancellation fini
22.
▲
by
kprotty
3y ago
> what prevents it from ensuring that a runtime is present when it does? The runtime being a library instead of a language/compiler level feature. Custom runtimes is necessary for systems languages as they can have specialized const
23.
▲
by
kprotty
3y ago
To run async in Drop in rust, you need to use block_on() as you can't natively await (unlike in Go). This is the "blocking on Drop" mentioned and can result in deadlocks if the async logic is waiting on the runtime to advance
24.
▲
by
kprotty
3y ago
Not sure I follow; the cancellation logic is on both threads/tasks 1) the operation itself waiting for either the result or a cancel notification and 2) the cancellation thread sending that notification. The cancellation thread is gene
25.
▲
by
kprotty
3y ago
You cancel a sync IO op similar to how you cancel an async one: have another task (i.e OS thread in this case) issue the cancellation. Select semantically spawns a task per case/variant and does something similar under the hood if canc
26.
▲
by
kprotty
3y ago
> That would be useful, but I wouldn't call the lack of it "half-baked", since no other mainstream language has it either. It's just a nice-to-have. Golang supports running asynchronous code in defers, similar with Zi
27.
▲
by
kprotty
3y ago
If a function calls something that does something async, that can't be evaluated synchronously due to 1) no setup; could be async IO and require being called in the context of an async runtime (library feature, not language feature) an
28.
▲
by
kprotty
3y ago
A spinlock can be conditionally faster than a lock with uses futex, but it doesn't scale. Futex is really meant to provide an efficient way to block and unblock threads. One could use FUTEX_LOCK_PI to have it actually implement a lock,
29.
▲
by
kprotty
3y ago
futex APIs are both prevalent and somewhat unfortunate: Since the task enqueue happens in the kernel, you have no control over how it does it. This makes something like "wait if not equal" or requeue either not portable (few non-l
30.
▲
by
kprotty
3y ago
This is partially why allocation is left to the caller (concurrent data structures are often intrusive), have single consumers (made lock free using separate synchronization) or only have lockless guarantees not obstruction freedom. I think
More ›