|
|
|
|
|
by gf000
47 days ago
|
|
I don't think there is a standardized meaning of 'low-level'. I think a useful definition is that a low-level language controls more/is explicit about more properties of execution. So zig/c/c++/rust all have ways to specify when and where should allocations happen, as well as memory layout of objects. Expressivity is a completely different axis on which these low-level languages separate. C has ultra-low expressivity, you can barely create any meaningful abstraction there. Zig is much better at the price of remarkably small amount of extra language complexity. And c++ and rust have a huge amount of extra language complexity for the high expressivity they provide (given that they have to be expressive even on the low-level details makes e.g. rust more complex as a language than a similar, GC-d language would be, but this is a necessity). As for this particular case, I don't really see a level difference here, both languages can express the same memory layout here. |
|
Zig’s comptime is the primitive. Sum types, generics, etc. are things you can build on top.
The original example is the type-level equivalent of looking at:
and saying “why do I need all this function and return ceremony when I can just write the number 4 verbatim?”