| ▲ | observationist 13 hours ago | |
Not being slow - they compile straight to bytecode, they aren't interpreted, and have aggressive, opinionated optimizations baked in by default, so it's even faster than compiled c (under default conditions.) Contrasted with python, which is interpreted, has a clunky runtime, minimal optimizations, and all sorts of choices that result in slow, redundant, and also slow, performance. The price for performance is safety checks, redundancy, how badly wrong things can go, and so on. A good compromise is luajit - you get some of the same aggressive optimizations, but in an interpreted language, with better-than-c performance but interpreted language convenience, access to low level things that can explode just as spectacularly as with zig or c, but also a beautiful language. | ||
| ▲ | Zambyte 12 hours ago | parent | next [-] | |
Zig is safer than C under default conditions, not faster. By default does a lot of illegal behavior safety checking, such as array and slice bounds checking, numeric overflow checking, and invalid union access checking. These features are disabled by certain (non default) build modes, or explicitly disabled at a per scope level. It may be easier to write code that runs faster in Zig than in C under similar build optimization levels, because writing high performance C code looks a lot like writing idiomatic Zig code. The Zig standard library offers a lot of structures like hash maps, SIMD primitives, and allocators with different performance characteristics to better fit a given use-case. C application code often skips on these things simply because it is a lot more friction to do in C than in Zig. | ||
| ▲ | jibal 9 hours ago | parent | prev | next [-] | |
> they compile straight to bytecode machine code, not https://en.wikipedia.org/wiki/Bytecode > The price for performance is safety checks In Zig, non-ReleaseFast build modes have significant safety checks. > luajit ... with better-than-c performance No. | ||
| ▲ | agentifysh 13 hours ago | parent | prev [-] | |
will add this to the list, now learning new languages is less of a barrier with LLMs | ||