4 ms·
Zig is lower level than either (it's more like C than C++: expect to manually call 'free'on allocated values). It has a lot of nice improvments over C however,
by nicoburns 7y ago
Zig is lower level than either (it's more like C than C++: expect to manually call 'free'on allocated values). It has a lot of nice improvments over C however, like proper arrays, no null, a module system, and proper compile time evaluation (no need for the hacky preprocessor).
- rvz 7y agoI found the module system for C interop, quite innovative and was surprised to see that Rust didn't even have such a thing. If you compare bindgen to this approach, bindgen just seems like double work and harder to maintain autogenerated bindings. I have seen both Zig and Swift use the module system very well despite several devs strangely saying its somewhat complicated, but when used for low-level development this makes Zig an interesting language to use for language bindings.
- dnautics 7y agoI wrote a library for ffi (nifs) in elixir using zig, and a long term goal is for it to be easier to use zig as an intermediary for c library ffi than it is to use c. Already importing blas into elixir with it is crazy easy.
- blackhaz 7y agoMay I ask why people invent new languages rather than trying to extend or improve existing ones, like C?
- Ryckes 7y agoMany of the features of new languages are their restrictions. How would you restrict C in a new version to e.g. remove null pointers in favor of optional types?
- alfiedotwtf 7y agoA great feature I find with Rust not being superset of an unsafe language, is that the only option for you is to write safe code (unless you explicitly opt for `unsafe`). Compare this to merely extending a language e.g adding smart pointers - you could always (mistakenly) implicitly fall back onto bad coding practices.
- simias 7y agoYou could argue that it's what these languages do, the C heritage is very strong in every one of them. The problem is: do you want to maintain full backcompat or are you willing to break things to do it cleanly? If you do the former you end up with something like C++ which retains almost complete compatibility with C (but they you have a lot of baggage to carry around, which may get in the way at times) or you're willing to break things and then why not take the opportunity to improve the syntax and get rid of the cruft? C is ancient now, its type system and its many quirks are quite far from the state of the art or language design, a modern language wouldn't have to mess with the nonsense that are, for instance, C arrays (including C++ which can't outright remove them but does everything it can to render them obsolete with std::vector and std::array). An other big problem with C interop for newer languages is that while C itself is relatively small and easy the C preprocessor isn't. That's usually where the friction is, because if you want to maintain compatibility with C macros you have to choice but to implement the language syntax wholesale.
- pjmlp 7y agoC was already ancient when it came to be. In retrospective, the aversion of Go designers to current practices in other programming languages is quite similar to the aversion of them back when designing C, versus the other system programming languages that were being developed since 1961, like ESPOL, NEWP, PL/I, PL/S, BLISS.