136 points · by andxor · 8y ago · 42 comments
I'm really looking forward to tinkering around in Zig, for my next hobby project(s).
P.S. In fact, I'm going to 'put my money where my mouth is' and contribute via Patreon[1]. Zig is incredibly high quality and well-designed, despite being achieved from the spare time of so few; it deserves better funding.
In one word zig is "joy". I forget that I am actually writing a compiled language. It feels almost like python. Everything just snapped into place for me.
I encourage everyone interested to give it a try, especially if you prefer C over languages with a strong paradigm. It is very easy to pick up zig. Read the short manual, check some samples or the "std" library and you can be immediately productive.
C interop is amazing. comptime is a sample of how it should work in other languages. syntax is clean and simple. no headers, good error strategies, a (rather) helpful compiler, build system included etc.
The only downside is now it feels heavy to go back to work and hammer on C++ ...
Zig Programming Language Blurs the Line Between Compile-Time and Run-Time
https://andrewkelley.me/post/zig-programming-language-blurs-...
Now that I think of it, I wonder if Go could take the approach of Zig for generics, or at least for containers.
Look at how they express List(i32) there. It seems like a much more Go-like approach than say what Swift or Rust do for containers and generics. Like Go, Zig seems to have no classes, only functions and structs.
It does seem like many newer languages have complicated type systems and long compile times. I think Zig has an interesting alternative approach, although I would have to use it more to really make an judgement.
Note that Haskell and Rust (and other languages) have adhoc polymorphism _with_ type system support via type classes/traits. I would class this more as 'duck-typed templates'.
> or binary bloat.
This is an orthogonal issue, to do with whether instantiations of parameterized types/functions are monomorphised or not. I would say the big issue with templates is that they are slow and produce hard-to decipher compile-time stack traces, because they are not checked at the instantiation site.
It's still missing linear/affine types, no? To me that's inexcusable given the current offering.
Zig certainly has some cool ideas - I definitely think that we should be making the phase distinction more flexible. I do wish however that its compile time function evaluation was built on a firmer foundation, ie. using dependent types.
Also depending on how you define "dependent types" - there are a few competing definitions - Zig has them.
So D, Nim, C# (AOT compiled), Java (Embedded/Android Things/MicroEJ), Swift, Go are pretty much on the table as well.
I don't have a problem with GC so Nim/D are on the table. ATS is a pain in the ass but after the arrival of Rust it's pretty clear that linear/affine types can be user-friendly. There's no excuse any more.
Could you clarify the ambiguity you see, and how Zig has them?
It's "linear/affine types," not "linear affine types".
Also: Zig doesn't have linear or affine types. You seem to be quite confused about PL theory, which frankly does not make me any more confident in the language.
I see now that binaries are available (maybe they always were?)--maybe it's time to put Zig to the test on these toy problems.
Here some more details: