Live data from Hacker News

Show HN: Async UI: A Rust UI Library Where Everything is a Future

wishawa.github.io

91–96 of 96 posts

Re: Show HN: Async UI: A Rust UI Library Where Everything is a Future

#91

Earlier quoted context omitted.

So, you didn't give the explanation of what your snippet is supposed to do but, assuming that await returns control to f (as that the only thing that can happen with stackless coroutines) the equivalent in go would be to spawn a goroutine when calling g (pseudocode as I know approximately zero go): fn f() { var v1 = ..., var v2 = ...; go g(v2); } fn g(v2) { /* do something with v2 */ } There is no await as they are i…

> So, you didn't give the explanation of what your snippet is supposed to do but, assuming that await returns control to f No, await is a context switch of some kind. In a stackful implementation the stack is switched to another thread at that point (say for an I/O wait), in an async implementation, the point after await is resumed with the live variables needed for the remainder of the program because it will be pas…

So, don't you agree that the stackful equivalent of your stackless example will use something like 'go g(v1)' which will only capture v1?

Without explicitly forking v2 will be captured, but then it is a completely different program with different semantics and it doesn't make sense to say that it captures more.

Edit to be more practical: in c++ you can have both stackless and stackful coroutines. If you write the same program, say using asio, with either feature, the same data will be captured.

Re: Show HN: Async UI: A Rust UI Library Where Everything is a Future

#92

Earlier quoted context omitted.

> So, you didn't give the explanation of what your snippet is supposed to do but, assuming that await returns control to f No, await is a context switch of some kind. In a stackful implementation the stack is switched to another thread at that point (say for an I/O wait), in an async implementation, the point after await is resumed with the live variables needed for the remainder of the program because it will be pas…

So, don't you agree that the stackful equivalent of your stackless example will use something like 'go g(v1)' which will only capture v1? Without explicitly forking v2 will be captured, but then it is a completely different program with different semantics and it doesn't make sense to say that it captures more. Edit to be more practical: in c++ you can have both stackless and stackful coroutines. If you write the sam…

> So, don't you agree that the stackful equivalent of your stackless example will use something like 'go g(v1)' which will only capture v1?

It will only capture v1 and also reserve a larger stack space in case the new computation needs it, where the stackless equivalent does not require this.

> Without explicitly forking v2 will be captured, but then it is a completely different program with different semantics and it doesn't make sense to say that it captures more

It doesn't have different semantics just because v1 changes ones space behaviour and not the other's.

I'm not interested in Turing tarpit arguments that one can be made equivalent to the other. As I've already said, the point is what existing systems encourage what sort of program architectures and what allocation behaviour naturally follows. It's long been evident that stackless abstractions clearly must capture strictly less state at any given time.

Re: Show HN: Async UI: A Rust UI Library Where Everything is a Future

#93

Earlier quoted context omitted.

So, don't you agree that the stackful equivalent of your stackless example will use something like 'go g(v1)' which will only capture v1? Without explicitly forking v2 will be captured, but then it is a completely different program with different semantics and it doesn't make sense to say that it captures more. Edit to be more practical: in c++ you can have both stackless and stackful coroutines. If you write the sam…

> So, don't you agree that the stackful equivalent of your stackless example will use something like 'go g(v1)' which will only capture v1? It will only capture v1 and also reserve a larger stack space in case the new computation needs it, where the stackless equivalent does not require this. > Without explicitly forking v2 will be captured, but then it is a completely different program with different semantics and i…

If you are not interested in discussing it further so be it. But go did have segmented stacks that didn't require reserving additional space.

Re: Show HN: Async UI: A Rust UI Library Where Everything is a Future

#94

Earlier quoted context omitted.

> So, don't you agree that the stackful equivalent of your stackless example will use something like 'go g(v1)' which will only capture v1? It will only capture v1 and also reserve a larger stack space in case the new computation needs it, where the stackless equivalent does not require this. > Without explicitly forking v2 will be captured, but then it is a completely different program with different semantics and i…

If you are not interested in discussing it further so be it. But go did have segmented stacks that didn't require reserving additional space.

Go's segmented stacks are 2kB and used to be more. That is "reserving additional space".

Stackless space allocation is on the order of single or double digit bytes by contrast. There is no reasonable way to conclude they are comparable.

Re: Show HN: Async UI: A Rust UI Library Where Everything is a Future

#95

Earlier quoted context omitted.

What state does a userspace thread have to capture in order to work that a coroutine doesn't?

A userspace thread captures full a stack context, a delimited continuation used in async programming captures only the referenced variables needed for the remaining computation. This is a strict subset of the userspace thread state. For instance: fn f() { var v1 = ..., var v2 = ...; g(v2); } fn g(v2) { await; /* do something with v2 */ } // await is a context switch A userspace thread captures v1 and v2, an async com…

What is the fundamental difference between coroutines and userspace threads that makes such optimizations possible for coroutines and impossible for userspace threads?

Re: Show HN: Async UI: A Rust UI Library Where Everything is a Future

#96
post #85
post #78

Earlier quoted context omitted.

Sycamore works pretty similarly to React. See https://www.reddit.com/r/rust/comments/xvv49w/comment/ir6pw0... for how Async UI is different from React-style frameworks.

It don't see how this works out. React uses a virtual Dom. Sycamore: > Write code that feels natural. Everything is built on reactive primitives without a cumbersome virtual DOM. Yew works more similar to React

You're right. I got the two frameworks confused.

Async UI is similar to Sycamore in term of not diffing VDOM.

The API is different in that in Sycamore, you tell the framework what to render (by using sycamore::render) and the framework will handle it from there. In Async UI, you await what you want to render yourself. Async UI's API is more transparent in this way, and this brings benefits including - making async control flow (like the control flow example in the blog post) possible - making component simply async function or anything that implements IntoFuture

Sycamore's reactivity is pretty painless (a little too magical for my taste, but that's probably just me), so it's something Async UI can learn from.

Post reply on HN