Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The other consequence, however, is that Go coroutines only work with other Go code, and bespoke Go threads and stacks require the runtime to jump through a lot of hoops to do FFI correctly, with the result that the ecosystem tends to rewrite rather than reuse existing code in C and other languages.

In contrast, the approach with explicit promises and await can be mapped all the way down to a C struct with a function and a data pointer representing a callback. That is, it is C ABI compatible, and thus it can be easily composed across any boundary that respects that ABI.



The only runtime hoop I've ever had to jump through was to invoke runtime.LockOSThread() inside a go-routine. In a lot of ways:

    go func() {
        runtime.LockOSThread()
        // ...
    }()
Is simpler than creating a thread in other languages.


The runtime jumps through those hoops for you as needed, mostly, but there are consequences to that wrt performance.




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

Search: