Remix.run Logo
charlie90 10 hours ago

>Learning Zig is not just about adding a language to your resume. It is about fundamentally changing how you think about software.

Zig is just C with a marketing push. Most developers already know C.

pjmlp 4 hours ago | parent | next [-]

I would rephrase it as, Zig is just Modula-2 with a C like syntax.

dcre 10 hours ago | parent | prev | next [-]

I suspect most developers do not know C.

downrightmike 8 hours ago | parent | next [-]

C is fine C++ is where they jumped the shark

MyOutfitIsVague 7 hours ago | parent | next [-]

C++ is far better than C in very many ways. It's also far worse than C in very many other ways. Given a choice between the two, I'd still choose C++ every day just for RAII. There's only so much that we can blame programmers for memory leaks, use-after-free, buffer overflows, and other things that are still common in new C code. At some point, it is the language itself that is unsuitable and insufficient.

pjmlp 26 minutes ago | parent | prev | next [-]

Until WG14 ackwnowledges the safety holes in C, isn't fine at all, it should be nuked.

cowsandmilk 42 minutes ago | parent | prev | next [-]

I’m not sure what that has to do with the comment you’re replying to…

bnolsen 7 hours ago | parent | prev | next [-]

C++ explored a lot of ideas that some modern languages borrowed. C++ just had to haul along all the cruft it inherited and built up.

jeltz 7 hours ago | parent | prev [-]

No, C is not fine. It is a really bad language that I unfortunately have to code professionally.

7 hours ago | parent | prev [-]
[deleted]
keyle 9 hours ago | parent | prev [-]

That tagline unfortunately turned me off the book, without even starting to read.

I really don't need this kind of self-enlightenment rubbish.

What if I read the whole book and felt no change?

I think I understand SoA just fine.

xeonmc 9 hours ago | parent [-]

It is also just such a supremely unziglike thing to state.

Zambyte 8 hours ago | parent [-]

Early talks by Andrew explicitly leaned into the notion that "software can be perfect", which is a deviation from how most programmers view software development.

Zig also encourages you to "think like a computer" (also an explicit goal stated by Andrew) even more than C does on modern machines, given things like real vectors instead of relying on auto vectorization, the lack of a standard global allocator, and the lack of implicit buffering on standard io functions.

I would definitely put Zig on the list of languages that made me think about programming differently.

jamiejquinn 3 hours ago | parent | next [-]

Has it changed how you program in other languages? Because that to me is the true mark of a thought-shifting language.

keyle 6 hours ago | parent | prev [-]

I'm not sure how what you stated is different from writing highly performance C.

budro 5 hours ago | parent [-]

I think it mostly comes down to the standard library guiding you down this path explicitly. The C stdlib is quite outdated and is full of bad design that affects both performance and ergonomics. It certainly doesn't guide you down the path of smart design.

Zig _the language_ barely does any of the heavy lifting on this front. The allocator and io stories are both just stdlib interfaces. Really the language just exists to facilitate the great toolchain and stdlib. From my experience the stdlib seems to make all the right choices, and the only time it doesn't is when the API was quickly created to get things working, but hasn't been revisited since.

A great case study of the stdlib being almost perfect is SinglyLinkedList [1]. Many other languages implement it as a container, but Zig has opted to implement it as an intrusively embedded element. This might confuse a beginner who would expect SinglyLinkedList(T) instead, but it has implications surrounding allocation and it turns out that embedding it gives you a more powerful API. And of course all operations are defined with performance in mind. prepend is given to you since it's cheap, but if you want postpend you have to implement it yourself (it's a one liner, but clearly more expensive to the reader).

Little decisions add up to make the language feel great to use and genuinely impressive for learning new things.

[1] https://ziglang.org/documentation/master/std/#std.SinglyLink...