Remix.run Logo
poly2it 5 hours ago

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

I'm not sure what they expect, but to me Zig looks very much like C with a modern standard lib and slightly different syntax. This isn't groundbreaking, not a thought paradigm which should be that novel to most system engineers like for example OCaml could be. Stuff like this alienates people who want a technical justification for the use of a language.

obviouslynotme 4 hours ago | parent | next [-]

There is nothing new under the Sun. However, some languages manifest as good rewrites of older languages. Rust is that for C++. Zig is that for C.

Rust is the small, beautiful language hiding inside of Modern C++. Ownership isn't new. It's the core tenet of RAII. Rust just pulls it out of the backwards-compatible kitchen sink and builds it into the type system. Rust is worth learning just so that you can fully experience that lens of software development.

Zig is Modern C development encapsulated in a new language. Most importantly, it dodges Rust and C++'s biggest mistake, not passing allocators into containers and functions. All realtime development has to rewrite their entire standard libraries, like with the EASTL.

On top of the great standard library design, you get comptime, native build scripts, (err)defer, error sets, builtin simd, and tons of other small but important ideas. It's just a really good language that knows exactly what it is and who its audience is.

simonask 3 hours ago | parent | next [-]

I don't know man, Rust's borrowing semantics are pretty new under the sun, and actually do change the way you think about software. It's a pretty momentous paradigm shift.

Zig is nice too, but it's not that.

rjzzleep 3 hours ago | parent | next [-]

To call Rust syntax beautiful is a stretch. It seems that way in the beginning but then quickly devolves into a monstrosity when you start doing more complex things.

Zig on the other specifically addresses syntax shortcomings in part of C. And it does it well. That claim of rust making C more safe because it’s more readable applies to Zig more than it does to Rust.

I feel like the reason the rust zealots lobby like crazy to embed rust everywhere is twofold. One is that they genuinely believe in it and the other is that they know that if other languages that address one of the main rust claims without all the cruft gains popularity they lose the chance of being permanently embdedded in places like the kernel. Because once they’re in it’s a decade long job market

hnarn 3 hours ago | parent | next [-]

> they know that if other languages that address one of the main rust claims without all the cruft gains popularity they lose the chance of being permanently embdedded in places like the kernel

First of all, I'm really opposed to saying "the kernel". I am sure you're talking about the Linux kernel, but there are other kernels (BSD, Windows etc.) that are certainly big enough to not call it "the" kernel, and that may also have their own completely separate "rust-stories".

Secondly, I think the logic behind this makes no sense, primarily because Rust at this point is 10 years old from stable and almost 20 years old from initial release; the adoption into the Linux kernel wasn't exactly rushed. Even if it was, why would Rust adoption in the Linux kernel exclude adoption of another language as well, or a switch to another, if it's better? The fact that Rust was accepted at all to begin with aside from C disproves the assumption, because clearly that kernel is open for "better" languages.

The _simplest_ explanation to why Rust has succeeded is that it's solves actual problems, not that "zealots" are lobbying for it to ensure they "have a job".

throw9404049 an hour ago | parent [-]

> Rust at this point is 10 years old from stable

Rust is not stable even today! There is no spec, no alternative implementations, no test suite... "Stable" is what "current compiler compiles"! Existing code may stop compiling any day....

Maybe in 10 years it may become stable, like other "booring" languages (Golang and Java).

Rust stability is why Linus opposes its integration into kernel.

bayindirh 30 minutes ago | parent [-]

In the "other good news department", GCC is adding a Rust frontend to provide the alternative implementation, and I believe Rust guys accepted to write a specification for the language.

I'm waiting for gccrs to start using the language, actually.

bayindirh an hour ago | parent | prev | next [-]

> To call Rust syntax beautiful is a stretch.

I'm no Rust fan, but beauty of a syntax is always in the eye of the beholder.

I personally find Go, C++ and Python's syntax beautiful. All can be written in very explicit or expressive forms. On the other hand, you can hide complexity to a point.

If you are going to do complex things in a compact space, you'll asymptotically approach Perl or PCRE. It's maths.

All code is maths, BTW.

latexr an hour ago | parent | prev | next [-]

> To call Rust syntax beautiful is a stretch.

I don’t see where the comment you’re replying to does that (was it edited?). Their comment says nothing about aesthetics.

fransje26 11 minutes ago | parent [-]

Higher up

> Rust is the small, beautiful language hiding inside of Modern C++

andy12_ an hour ago | parent | prev | next [-]

For my part, I don't know why, but Zig's syntax feels wrong to me. I don't even know why. I really want to like its syntax, as Zig seems really promising to me, but I just don't, which makes it not very enjoyable for me to write.

I don't know if it's my lack of practice, but I never felt the same about, say, Rust's syntax, or the syntax of any other language for that matter.

kibwen 2 hours ago | parent | prev [-]

> if other languages that address one of the main rust claims without all the cruft

But regardless of how much one likes Zig, it addresses none of the problems that Rust seeks to solve. It's not a replacement for Rust at all, and isn't suitable for any of the domains where Rust excels.

sgt 2 hours ago | parent [-]

> and isn't suitable for any of the domains where Rust excels.

That's a pretty bold claim since Zig is specifically designed for systems programming, low level stuff, network services, databases (think Tigerbeetle). It's not memory safe like Rust is, but it comes with constructs that make it simple to build largely memory safe programs.

GuB-42 15 minutes ago | parent | next [-]

Rust is not designed for low level system programming / embedded systems like Zig is. It is designed to make a browser and software that share requirements with making a browser.

There is some overlap but that's still different. The Zig approach to memory safety is to make everything explicit, it is good in a constrained environment typical of embedded programming. The Rust approach is the opposite, you don't really see what is happening, but there are mechanisms to keep your safe. It is good for complex software with lots of moving parts in an unconstrained environment, like a browser.

For a footgun analogy, one will hand you a gun that will never go off unless you aim and pull the trigger, so you can shoot your foot, but no sane person will. It is a good sniper rifle. The Rust gun can go off at any time, even when you don't expect it, but it is designed in such a way that it will never happen when it is pointed at your foot, even if you aim it there. It is a good machine gun.

JuniperMesos an hour ago | parent | prev [-]

> It's not memory safe like Rust is, but it comes with constructs that make it simple to build largely memory safe programs.

Right, this is the specific important thing that Rust does that Zig doesn't (with the caveat that Rust includes the `unsafe` mechanism - as a marked, non-default option - specifically to allow for necessary low-level memory manipulation that can't be checked for correctness by the compiler). Being able to guarantee that something can't happen is more valuable than making it simple to do something correctly most of the time.

dns_snek 36 minutes ago | parent | next [-]

It's not that simple though, Zig has equivalent spatial memory safety which prevents issues that are pretty consistently among (or at) the top of the list for most dangerous vulnerability classes.

And while I don't have enough experience with Rust to claim this first hand, my understanding is that writing correct unsafe Rust code is at least an order of magnitude harder than writing correct Zig code due to all of the properties/invariants that you have to preserve. So it comes with serious drawbacks, it's not just a quick "opt out of the safety for a bit" switch.

> Being able to guarantee that something can't happen is more valuable than making it simple to do something correctly most of the time.

Of course, all other things being equal, but they're not.

sgt an hour ago | parent | prev [-]

Sure but there's this belief in the Rust community that it's not responsible anymore to write software that isn't memory safe on the same level as Rust.

So Zig would fail that, but then you could also consider C++ unsuitable for production software - and we know it clearly is still suitable.

I predict Zig will just become more and more popular (and with better, although not as complete- memory safety), and be applied to mission critical infra.

pjmlp 26 minutes ago | parent [-]

If we ignore recent movents in govermental cybersecurity agencies, and big tech to move away from unsafe programming languages, as much as technically possible.

Introducing a language with the same safety as Modula-2 or Object Pascal, would make sense in the 1990's, nowadays with improved type systems making the transition from academia into mainstream, we (the industry) know better.

It is not only Rust, it is Linear Haskell, OCaml effects, Swift 6 ownership model, Ada/SPARK, Chapel,....

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

Kind of, https://en.wikipedia.org/wiki/Cyclone_(programming_language)

What it has achieved is making affine types something mainstream developers would care about.

hu3 2 hours ago | parent | prev | next [-]

There were languages with lifetimes and borrowing mechanics before Rust. Rust packages these mechanics in a nice way. Just like Zig encodes many niceties in a useful C language (comptime, simple cross-compilation, stdlib).

brabel 2 hours ago | parent [-]

Which ones?? Before Rust, to my knowledge, no language had an actually practical way to use lifetimes and borrow-checking so that both memory safety and concurrency safety (data races, which is huge) were solved, even though the concepts were known in research. Doing the actual work to make it practical is what makes the difference between some obscure research topic and a widely used language that actually solves serious problems in the real world.

pjmlp 25 minutes ago | parent [-]

Cyclone for one, which AT&T created exactly to replace C.

bayindirh an hour ago | parent | prev [-]

> actually do change the way you think about software. It's a pretty momentous paradigm shift.

That's true for people who doesn't read and think about the code they write. For people who think from the perspective of a computer, Rust is "same checks, but forced by the compiler".

Make no mistake, to err is human, but Rust doesn't excite me that much.

renewiltord 4 hours ago | parent | prev | next [-]

> Most importantly, it dodges Rust and C++'s biggest mistake, not passing allocators into containers and functions

Funny. This was a great sell to me. I wonder why it isn’t the blurb. Maybe it isn’t a great sell to others.

The problem for me with so many of these languages is that they’re always eager to teach you how to write a loop when I couldn’t care less and would rather see the juice.

However, nowadays with comprehensive books like this, LLM tools can better produce good results for me as I try it out.

Thank you.

obviouslynotme 4 hours ago | parent [-]

Very, very few people outside of foundational system software, HFT shops, and game studios understand why it's a great selling point. Everyone else likes the other points and don't realize the actual selling point of the language.

ninetyninenine 4 hours ago | parent | prev | next [-]

>Rust is that for C++

No it's not. Rust has roots in functional languages. It is completely orthoganol to C++.

jasode 3 hours ago | parent [-]

Graydon Hoare, a former C++ programmer on Mozilla Firefox and the original creator of Rust, acknowledges that for many people, Rust has become a viable alternative to C++ :

https://graydon2.dreamwidth.org/307291.html

And on slide #4, he mentions that "C++ is well past expiration date" :

https://venge.net/graydon/talks/intro-talk-2.pdf

It's possible that Graydon's earliest private versions of Rust the 4 years prior to that pdf were an OCaml-inspired language but it's clear that once the team of C++ programmers at Mozilla started adding their influences, they wanted it to be a cleaner version of C++. That's also how the rest of the industry views it.

krona 16 minutes ago | parent [-]

> Rust has become a viable alternative to C++

Alternative yes, derivative no. Rust doesn't approach C++'s metaprogramming features, and it probably shouldn't given how it seems to be used. It's slightly self-serving for browser devs to claim Rust solves all relevant problems in their domain and therefore eclipses C++, but to me in the scientific and financial space it's a better C, making tradeoffs I don't see as particularly relevant.

I say this as a past contributor to the Rust std lib.

kibwen 2 hours ago | parent | prev [-]

> Rust and C++'s biggest mistake, not passing allocators into containers and functions

Rather, basing its entire personality around this philosophy is Zig's biggest mistake. If you want to pass around allocators in C++ or Rust, you can just go ahead and do that. But the reason people don't isn't because it's impossible in those languages, it's because the overwhelming majority of the time it's a lot of ceremony for no benefit.

Like, surely people see that in C itself there's nothing stopping anyone from passing around allocators, and yet almost nobody ever does. Ever wonder why that is?

wavemode 5 hours ago | parent | prev | next [-]

Much of the book's copy appears to have been written by AI (despite the foreword statement that none of it was), which explains the hokey overenthusiasm and exaggerations.

keybored 37 minutes ago | parent | next [-]

As we know AI is at least as smart as the average human. It knows the Zeitgeist and thus adds “No AI used” in order to boost “credibility”. :) (“credibility” since AI is at least as smart the average human, for us in the know.)

ninetyninenine 4 hours ago | parent | prev [-]

That's ok, in the near future nobody will actually read this book. AI will be reading it. This is training data.

userbinator 5 hours ago | parent | prev | next [-]

For those who actually want to learn languages which are "fundamentally changing how you think about software", I'd recommend the Lisp family and APL family.

fuzztester 3 minutes ago | parent | next [-]

And Forth.

And 6502 assembly. ;)

And SNOBOL.

And Icon.

And ...

pjmlp 4 hours ago | parent | prev | next [-]

And Prolog as well.

zwnow 4 hours ago | parent | prev | next [-]

I'd also throw Erlang/Elixir out there. And I really wished Elm wasn't such a trainwreck of a project...

59nadir 11 minutes ago | parent | next [-]

No need to include Elixir here; none of the important bits that will change how you view software come from Elixir, it's just a skin on top of Erlang (+ some standard library wrappers) and that's it.

zwnow 3 minutes ago | parent [-]

I'd argue more people use Elixir over Erlang at this point. Sure its just an abstraction on top of Erlang, but people learn through Elixir nowadays, not through Erlang.

matu3ba 3 hours ago | parent | prev [-]

What is the most optimal Erlang/Elixir you can think of regarding standardized effect systems for recording non-determinism, replaying and reversible computing? How comparable are performance numbers of Erlang/Elixir with Java and wasm?

zwnow 3 hours ago | parent [-]

I'd recommend asking the Elixir community about this as I didn't even understand your question. I am by no means a professional with Erlang/Elixir. I threw it out there because these language force you to think differently compared to common OOP languages.

miki123211 4 hours ago | parent | prev [-]

Am I correct that you can essentially "learn APL without learning APL" by just learning Numpy / Pytorch?

I looked at array languages briefly, and my impression was that"ooh this is just Numpy but weirder."

benji-york 32 minutes ago | parent | next [-]

You might enjoy this video: https://www.youtube.com/watch?v=a9xAKttWgP4

veqq 3 hours ago | parent | prev [-]

Not even close. While Numpy has many similar operations, it lacks the terseness, concepts like trains and forks etc. Modern APL style doesn't use... control flow (neither recursion nor loops nor if...) and often avoids variables (tacit/point-free style).

12 minutes ago | parent | prev | next [-]
[deleted]
5 hours ago | parent | prev | next [-]
[deleted]
3 hours ago | parent | prev | next [-]
[deleted]
cindyllm 3 hours ago | parent [-]

[dead]

adev_ 2 hours ago | parent | prev | next [-]

> It is about fundamentally changing how you think about software.

> I'm not sure what they expect, but to me Zig looks very much like C

Yes. I think people should sincerely stop with this kind of wording.

That makes Zig looks like some kind of cult.

Technically speaking, Zig democratized the concept of imperative compile time meta-programming (which is an excellent thing).

For everything else, this is mainly reuse and cherry pick from other languages.

IshKebab 3 hours ago | parent | prev | next [-]

I guess comptime is a little different but yeah I wouldn't say it fundamentally changes how you think about software.

I wouldn't say that about OCaml either really though. It's not wildly different in the way that e.g. Lean's type system, or Rust's borrow checker or Haskell's purity is.

vlovich123 2 hours ago | parent [-]

D has similar comptime capabilities if I recall correctly and proceeds Zig by almost 2 decades or so.

IshKebab 8 minutes ago | parent [-]

I don't think it's the same. You can do template metaprogramming, but Zig lets you use Zig itself which is a lot nicer.

I'm not a D programmer though so I could be wrong.

wolvesechoes 3 hours ago | parent | prev [-]

Zig community really tries to match Rust one in terms of cult resemblance.

IshKebab 3 hours ago | parent | next [-]

Did it occur to you that Rust and Zig might actually be very good?

hnarn 3 hours ago | parent | prev [-]

People that consider other people that are excited about something "culty" are usually people that themselves are excited by absolutely nothing.