News for hackers. Stuff that matters.
Re:Async Rust doesn't have to be hard by mwcampbell on Friday June 03, 2022 @08:01PM (#31615369)
> stackless async support is suitable for systems like microcontrollers, and the design reflects that.

Tangent: How feasible would it be to have a language where the required stack space for all function invocations is statically known at compile time, just as the sizes of Rust futures are statically known? I guess this would be even harder, because with async functions, the compiler only has to store the state of the function in a statically sized structure when it reaches an await point. But I'm guessing that running out of stack is a common problem when developing for microcontrollers.

Re:Async Rust doesn't have to be hard by kibwen on Friday June 03, 2022 @08:27PM (#31615553)
You can predetermine function stack sizes as long as you don't do anything resembling C's "alloca" (Rust doesn't support alloca directly, but it supports dynamically-sized types in some contexts which would stymie this). But from there you need to use that information to figure out the maximum stack usage of the program, which means exhaustively determining all possible execution paths, which can be a hard problem (you also need to forbid recursion, even mutual recursion, which languages generally don't try to do (something something y-combinator)).
Re:Async Rust doesn't have to be hard by kaba0 on Saturday June 04, 2022 @02:04AM (#31617470)
I may be very wrong here, but the JVM byte code’s method structure explicitly has a stack size and local array max size property, both calculated at compile time. Are they using some heuristic here?
Re:Async Rust doesn't have to be hard by surrealize on Saturday June 04, 2022 @04:12AM (#31618095)
I'd bet that the stack size you refer to doesn't include callees (i.e., the stack used by procedures called by the method in question).
Re:Async Rust doesn't have to be hard by kaba0 on Saturday June 04, 2022 @07:21AM (#31619088)
Oh you are right, Java has two stacks, an operational and a method/function stack. Only the former is calculated ahead of time (and the latter is configurable at runtime).