5 ms·
I've been learning Zig by porting my toy SQL database in Go to Zig (both projects are on Github, you can go find them if you'd like). This is my first time tryi
by eatonphil 4y ago
I've been learning Zig by porting my toy SQL database in Go to Zig (both projects are on Github, you can go find them if you'd like). This is my first time trying to seriously use a non-GC language for a project, so there's a big learning curve unrelated to Zig in particular. However, it's much easier than trying to learn C (which I've tried a few times). The standard library is incredibly feature rich compared to C (although I've heard whispers that eventually they plan to reduce the size of the standard library, which I'd personally find sad). defer is awesome. comptime too.
I haven't noticed miscompilation yet but I have noticed occasional unclear error messages such as it pointing at the wrong line. I've meant to make a note of these but since I'm just focused on learning I haven't done a great job of writing down these minor bugs.
I don't think the breaking changes (which haven't seemed that big) are a huge deal for most folks curious about PL in general. And I think the potential for being a better C is just so great that it's worth continuing to try out Zig and follow it's development. In particular I think it would make a lot of sense as a teaching language for the college courses that would otherwise use C. And I think it would be a pretty fancy compilation target for language implementations like Chicken Scheme that otherwise target C. (I'm sure it would be great in other situations too but these two are ones I can relate to most.)
But I'm still early on in my exploration of Zig. (Disclaimer: the company I work for uses Zig and sponsors ZSF.)
- pjmlp 4y agoBeing a better C is not hard to achieve as goal, JOVIAL, NEWP and PL/I did it one decade before C was born, and Modula-2 did it while C was mostly a Bell Labs toy, back in 1978. The problem is getting the wider market to pick better C languages.
- eatonphil 4y agoI agree! I think the Zig community is doing a better job marketing than most better-c languages (which saddens me in some respects because I like D too, but sometimes you go with what meets most criteria and seems like it will succeed with adoption!).
- jpe90 4y agoI started trying to learn Zig as my first non-GC language but switched over to C because I had trouble finding learning resources for Zig, while there are plenty of books and C code written to ISO standards to learn from. It felt like a language for people already proficient in C/C++ and systems programming.. but props to you for proving that wrong!
- eatonphil 4y agoYeah that's a good point. I was a little surprised at the spartan quality of documentation. But I'm also comfortable grepping around the compiler/standard library source code to see patterns. And most importantly, I ask a ton of dumb questions on the Zig Programming Language's #zig-help channel. :) https://discord.gg/9Cp4uhDu https://discord.gg/9Cp4uhDu
- jpe90 4y agothe source code was very well laid put from what i remember, and tests were particularly helpful for understanding how to use library code. i just didn’t feel like i quite had the knowledge to architect low level code in general, you must have picked up on that naturally
- eatonphil 4y agoOf all the reasons I might imagine someone feeling like C is easier to pick up than Zig, "hardware-software knowledge to know how to architect low level code in general" does not make a ton of sense to me. In what way do you feel this was easier in C?
- kristoff_it 4y agoI think their point is that you need to learn that stuff and with C you can learn it "accidentally" through C learning materials. Zig doesn't have yet enough learning materials to "accidentally" teach you systems programming. The solution would be to have learning materials that teach you systems programming in a way that is not tied to a specific language, but I don't know of any example of that, and I guess the same applies to all the people that I had this discussion with in the past.
- the_mitsuhiko 4y ago> I haven't noticed miscompilation yet I found it shockingly easy to get a miscompilation that it really soured my interest in it. It’s good to hear that in practice that appears to be less of a concern.
- _vvhw 4y agoAnecdotally again, but I've been coding in Zig since 2020 and have hit I think 2-3 compiler bugs in all that time? The first was fixed within 24 hours, in fact just before I reported it. The others had clear TODO error messages in the panic, and there were easy enough workarounds.