zlacker

[parent] [thread] 5 comments
1. SkiFir+(OP)[view] [source] 2024-01-20 12:22:42
IMO saying there's no function coloring in a language ignores a lot of details.

In Go there's no function coloring because there are only async functions. That's why they don't get any special color, they are the only color. In Go you don't get to use sync functions, which creates problems e.g. when you need to use FFI, because the C ABI is the exact opposite and doesn't have function coloring because it only allows you to use sync functions.

Zig and Rust's async-generic initiative are a bit different in that they want to allow functions to be both sync and async at the same time. Ultimately there are still colors, but you don't have to choose one of them when you write a function. However IMO there are a lot of non-trivial problems to solve to get to that result.

Ultimately Go's approach work well enough, and usually better than other approaches, until you need to do FFI or you need to produce a binary without a runtime (e.g. if you need to program a microcontroller)

replies(3): >>gpdere+DU >>65a+T92 >>yawara+Fl2
2. gpdere+DU[view] [source] 2024-01-20 18:11:47
>>SkiFir+(OP)
That's a bit of nonsense. As far as I know, all functions are sync in go. The fact that they are implemented async in the runtime with an user-space scheduler is irrelevant (you could otherwise make the point that there are truly no sync functions).

If we call the go programming model async, the word has completely lost all meanings.

replies(1): >>SkiFir+Mu1
◧◩
3. SkiFir+Mu1[view] [source] [discussion] 2024-01-20 21:45:03
>>gpdere+DU
What is the difference between a sync and an async function for you then?
replies(1): >>gpdere+mZ1
◧◩◪
4. gpdere+mZ1[view] [source] [discussion] 2024-01-21 01:43:06
>>SkiFir+Mu1
An async function is on CPS form and return it's result via a return continuation. Typically when invoked from a non CPS function it also forks the thread of execution.

These days async functions are also typically lazily evaluated via partial evaluation and the return continuation is not necessarily provided at the call site.

A sync function provides it's result via the normal return path.

5. 65a+T92[view] [source] 2024-01-21 03:29:24
>>SkiFir+(OP)
Go works fine for C FFI, all of its problems there are caused by its innovation wrt dynamic stack sizes and having a garbage collector. I'd rather write multithreaded Go FFI than deal with JNI again, anyway. There isn't really a language keyword-level concept of async in Go that's comparable to `await` in JS, or Java futures, or Rust async.
6. yawara+Fl2[view] [source] 2024-01-21 05:53:49
>>SkiFir+(OP)
> IMO saying there's no function coloring in a language ignores a lot of details.

Details which are meant to be ignored. When you use async/await constructs in various languages, you don't care about the fact that they are desugared into callback chains under the hood. You either do async/await in a language or you don't. That's what the concept of 'your function has a colour' means. If you want to change the meaning, OK but then you're talking about something else.

[go to top]