Hacker Newsnew | past | comments | ask | show | jobs | submit | austinjp's favoriteslogin

Hello friends! For more details, here's a blog post that sin-ack wrote about the porting work: https://sin-ack.github.io/posts/sycl-talk-20221007/

He also gave an in-person talk about Zig on SerenityOS at Software You Can Love 2022, there's a video of the talk here: https://www.youtube.com/watch?v=Ug3p8vELJqQ


Babel does this, using a library called gensync. I have a writeup which goes into more detail: https://writing.bakkot.com/gensync

gensync instead creates two functions, one sync and one async, which is probably a more familiar API for consumers of your code.


You can use One Weird Trick with generator functions to make your code "generic" over synchronicity. I use this technique to avoid needing to implement both sync and async versions of some functions in my quickjs-emscripten library.

The great part about this technique as a library author is that unlike choosing to use a Promise return type, this technique is invisible in my public API. I can write a function like `export function coolAlgorithm(getData: (request: I) => O | Promise<O>): R | Promise<R>`, and we get automatic performance improvement if the caller's `getData` function happens to return synchronously, without mystery generator stuff showing up in the function signature.

Helper to make a function that can be either sync or async: https://github.com/justjake/quickjs-emscripten/blob/ff211447...

Uses: https://cs.github.com/justjake/quickjs-emscripten?q=yield*+l...


This has made me rethink a lot of things. I think video on the web should probably use the webtorrent approach primarily. Thanks for posting... gonna go work on some interesting approaches now.

Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: