It's odd that the async/await syntax _exclusively_ uses threads under the hood. I guess it makes for a straightforward implementation, but in every language I've seen the point of async/await is to use an event loop/cooperative multitasking.
Zen-C: Write like a high-level language, run like C
71–80 of 159 posts
Re: Zen-C: Write like a high-level language, run like C
#72Re: Zen-C: Write like a high-level language, run like C
#73From what I can see in the codegen, defer is not implemented "properly": the deferred statements are only executed when the block exits normally; leaving the block via "return", "break", "continue" (including their labelled variants! those interact subtly with outer defers), or "goto" skips them entirely. Which, arguably, should not happen: var f = fopen("file.txt", "r"); defer fclose(f); if fread(&ch, 1, 1, f) would…
Re: Zen-C: Write like a high-level language, run like C
#74> Mutability > By default, variables are mutable. You can enable Immutable by Default mode using a directive. > //> immutable-by-default > var x = 10; > // x = 20; // Error: x is immutable > var mut y = 10; > y = 20; // OK Wait, but this means that if I’m reading somebody’s code, I won’t know if variables are mutable or not unless I read the whole file looking for such directive. Imagine if someone even defined custo…
When reading working code, it doesn't matter whether the language mode allows variable reassignment. It only matters when you want to change it. And even then, the compiler will yell at you when you do the wrong thing. Testing it out is probably much faster than searching the codebase for a directive. It doesn't seem like a big deal to me.
Re: Zen-C: Write like a high-level language, run like C
#75It's odd that the async/await syntax _exclusively_ uses threads under the hood. I guess it makes for a straightforward implementation, but in every language I've seen the point of async/await is to use an event loop/cooperative multitasking.
Noob question: if it just compiles to threads, is there any need for special syntax in the first place? My understanding was that no language support should be required for blocking on a thread.
Re: Zen-C: Write like a high-level language, run like C
#76Earlier quoted context omitted.
Odin and Jai are others.
chicken scheme compiles to c as well. it's a pretty convenient compilation target, you get to use all the compilers and tool chains out there and you don't add a dependency on llvm
Of course you can always drop to manually written C yourself and it's still a fantastic language to interop with C. And CHICKEN 6 (still pre-release) improves upon that! E.g structs and Unions can be returned/passed directly by/to foreign functions, and the new CRUNCH extension/subset is supposed to compile to something quite a bit closer to handwritten C; there are even people experimenting with it on embedded devices.
Re: Zen-C: Write like a high-level language, run like C
#77Re: Zen-C: Write like a high-level language, run like C
#78Earlier quoted context omitted.
chicken scheme compiles to c as well. it's a pretty convenient compilation target, you get to use all the compilers and tool chains out there and you don't add a dependency on llvm
I love CHICKEN Scheme! Nice to see it mentioned. Though I think it's worth pointing out it compiles to something pretty far from handwritten C, to my understanding. I think this is true of both performance and semantics; for example you can return a pointer to a stack allocated struct from a foreign lambda (this is because chicken's generated C code here doesn't really "return", I think. Not an expert). Of course you…
not an expert either, but you're right about that, it uses cps transformations so that functions never return. there's a nice write up here: https://wiki.call-cc.org/chicken-compilation-process#a-guide...
Re: Zen-C: Write like a high-level language, run like C
#79From what I can see in the codegen, defer is not implemented "properly": the deferred statements are only executed when the block exits normally; leaving the block via "return", "break", "continue" (including their labelled variants! those interact subtly with outer defers), or "goto" skips them entirely. Which, arguably, should not happen: var f = fopen("file.txt", "r"); defer fclose(f); if fread(&ch, 1, 1, f) would…
Did you manage to compile this example?
$ cat kekw.zc
include
fn main() {
var f = fopen("file.txt", "r");
defer fclose(f);
var ch: byte;
if fread(&ch, 1, 1, f)