Hacker News new | ask | show | jobs
by yellowapple 2460 days ago
Having looked at all three, I've so far settled on Zig for a couple reasons:

- Cross-compilation is trivial (I haven't dug too deeply into the cross-compilation story on Nim and Crystal, but Zig's is front-and-center)

- Allocations are explicit (functions that require allocating memory do so by accepting an allocator as an argument)

- Windows support seems to be better than with Crystal (which means I can use Zig for desktop programming for my dayjob, since at work most of the PCs here run Windows 10; not that I would at the moment, given that it's very much not production ready yet, but still)

- I strongly dislike Python's syntax, and therefore strongly dislike Nim's syntax (I also somewhat dislike C's syntax - and therefore Zig's - but not nearly as strongly)

- Zig's build system is pretty great (albeit not exactly intelligent when it comes to finding system header and library paths, I've noticed)

That said, there are some downsides to Zig that I'm hoping can be resolved (whether by someone else or - if I get comfortable enough with it - myself):

- Profound lack of standard library documentation

- I like Crystal's syntax better

- C++ interoperability is practically nonexistent (though it might be possible to write small C++ shims that link against Zig-outputted headers; not sure if Zig's included C compiler can compile those, but if it can, then this would be easy to integrate into the build process)

1 comments

To be fair, C++ has no ABI, de facto or otherwise. The best way to write C++ that can be called by other languages is with extern "C"
That is true. I only brought it up as a comparison with e.g. Nim, which does (claim to) have the ability to interoperate with C++ directly without C-ABI shims. D supposedly has similar capabilities, as does Chicken Scheme.

But yeah, the use case ain't to work with C++ code I've written (if I'm writing it, then my goal is to write as close to zero lines of C++ as possible ;) ), but rather to work with third-party C++ codebases that do not expose a C-compatible API (or do so poorly).