3 ms·
For all the reasons that Zig is a better language than C++: * Debugging is easier, faster, and more straightforward * Fewer bugs due to footguns in the langua
by AndyKelley 5y ago
For all the reasons that Zig is a better language than C++:
* Debugging is easier, faster, and more straightforward
* Fewer bugs due to footguns in the language
* Typical Zig code runs faster than typical C++ code. Part of this is due to Zig's safety features - there are design optimizations for performance that I won't even attempt in C or C++ because it's footgun city. Meanwhile in Zig it's actually completely safe in debug builds; you get a compile error or runtime panic if you mess up something.
* Floating point operations work on f16 and f128 without a dependency on SoftFloat library
* Cross compilation is trivial
* Comptime features make build options feasible and maintainable, such as enabling/disabling logging, whether to link libc, whether to link llvm, whether to enable tracy profiling, etc.
* Zig's error handling makes correct code the default instead of the other way around in C++
* The std lib HashMap, ArrayHashMap, and ArrayList data structures are really nice
* If the compiler is written in Zig, then adding a new target backend to the Zig compiler makes the Zig compiler work on that target. With another language we are stuck only supporting whatever that language supports.
Not only that but the Zig compiler available for download today is already backed by majority of lines of code written in Zig rather than C++; what is available today is already partially self-hosted. For example the following features are already written in Zig, not C++: `zig fmt`, `zig translate-c`, the command line interface, `zig cc`/`zig c++`, `zig build`, the cache system, compiler-rt, the macOS linker, and compile error checks that operate before type checking.
- _vvhw 5y ago> * The std lib HashMap, ArrayHashMap, and ArrayList data structures are really nice Reading Zig's std lib HashMap code the first time was an unforgettable experience for me. I've spent literally months on some state of the art hash table papers, implementations and tons of hash functions, and Zig's HashMap implementation has got to be right up there with some of the best and most performant out of the box. However, what impressed me most was just the level of control offered by the interface, and how clean and readable the code is.