8 ms·
It's nice to see Zig continuing to gain support. I have no idea why I've ended up siding with Zig in the lower languages wars. I used to root for the D program
by zoogeny 2y ago
It's nice to see Zig continuing to gain support. I have no idea why I've ended up siding with Zig in the lower languages wars.
I used to root for the D programming language but it seems to have got stuck and never gained a good ecosystem. I've disliked Rust from the first time I saw it and have never warmed up to it's particular trade offs. C feels unergonomic these days and C++ is overfull with complexity. Zig feels like a nice pragmatic middle ground.
I actually think Rust is probably perfectly suited to a number of tasks, but I feel I would default to choosing Zig unless I was certain beyond doubt that I needed specific Rust safety features.
- bornfreddy 2y agoI wanted to like Rust (memory safety and performance - what's not to like?) but both of my experiments with it ended in frustration. It seemed a way too complex language for what I needed. Recently, a coworker of mine made a great observation that made everything clear to me. I was looking for a replacement for C, but Rust is actually a replacement for C++. Totally different beast - powerful but complex. I need to see if Zig is any closer to C in spirit.
- fc417fc802 2y agoSomewhat related, even when I work with C++ I use it as "C with RAII". What I actually want is a scheme (R5RS) with manual memory management and a borrow checker. I don't know how well such a monstrosity would actually work in practice, but it's what I've convinced myself that I want.
- valorzard 2y agohttps://github.com/carp-lang/Carp https://github.com/carp-lang/Carp
- throwawaymaths 2y agoposted yesterday: https://news.ycombinator.com/item?id=42923829 https://news.ycombinator.com/item?id=42923829
- pcwalton 2y ago> I was looking for a replacement for C, but Rust is actually a replacement for C++. Totally different beast - powerful but complex. I've seen this sentiment a lot, and I have to say it's always puzzled me. The difference between Rust and basically any other popular language is that the former has memory safety without GC†. The difference between C++ and C is that the former is a large multi-paradigm language, while the latter is a minimalist language. These are completely different axes. There is no corresponding popular replacement for C that's more minimalist than Rust and memory safe. † Reference counting is a form of garbage collection.
- zamalek 2y ago> † Reference counting is a form of garbage collection. I agree with Raymond Chen's take on the academic definition of GCs[1], and therefore Rust is certainly a GC'd language (because your code behaves as though memory is infinite... usually). It's probably one of the first examples of "static garbage collection" - though I'm sure someone will point out a prior example. [1]: https://devblogs.microsoft.com/oldnewthing/20100809-00/?p=13203 https://devblogs.microsoft.com/oldnewthing/20100809-00/?p=13...
- jonahx 2y agoThis feels like deliberate misdirection, because in most practical cases what people mean is "some memory management process that will slow my program down non-trivially". By this definition Rust does not have GC whereas Go, eg, does. The "simulates infinite RAM" is an interesting perspective but simply not the subject of most conversations.
- huijzer 2y agoI read a blog that called Rust a language that was aimed to be high-level but without GC.
- anacrolix 2y agoThis is actually accurate. While Rust is a great replacement for C, so is C++. But Rust has tons of extra features that C doesn't have, just like C++. Moving from C++ to Rust is a sideways move. Moving from C to Rust is definitely an increase in complexity and abstraction. Rust is a great replacement for C++ as it fits into the same place in the stack of tools. Go is not a C or Python replacement. Zig is a good replacement for C.
- zozbot234 2y ago> But Rust has tons of extra features that C doesn't have, just like C++. C++ has tons of extra features over C because it's a kitchen sink language. Rust has some extra features over C because in order to support static analysis for memory safety in a practically usable manner, you need those features. In practice, there are lots of C++ features that Rust doesn't bother with, especially around templates. (Rust just has a more general macro feature instead. The C++ folks are now on track to adding a clunky "metaclass" feature which is a lot like Rust macros.)
- pjmlp 2y agoEvery language becomes a kitchen sink with enough time on the market, even C, people really should learn about the standard and the myriad of compiler extensions, K&R C was almost 60 years ago. C++ already has almost Rust macros, with a mix of compile time execution, concepts and traits, without requiring another mini-language, or an external crate (syn).
- bmacho 2y ago> Every language becomes a kitchen sink with enough time on the market, Sometimes they remove stuff, and then everything written before a specific date stop working.
- anacrolix 2y agoI've used Rust quite a bit now and there are too many features. It can't claim to be tidy anymore. Sure it's a better situation than C++, but it is getting worse and unlikely to get better.
- superlopuh 2y agoMy experience with Zig is that it's also a plausible replacement for C++
- fuzztester 2y agoexplanation needed, bro. nerdy langnoob or noobie langnerd here. not sure which is which, cuz my parsing skills are nearly zilch. ;)
- infamouscow 2y agoC programmers have long suffered the cumbersome ritual of struct manipulation—resorting to C++ merely to dress up structs as classes. Zig shatters that with comptime and the 'type' type.
- chongli 2y agoZig’s comptime feature gives a lot of the power of C++ templates. This makes it easier to implement a lot of libraries which are just a pain to do in plain C. Even seemingly simple things like a generic vector are annoying to do in C, unless you abandon type safety and just start passing pointers to void. I believe Zig even has some libraries for doing more exotic things easily, such as converting between an array of structs and a struct of arrays (and back).
- fuzztester 2y ago>Zig’s comptime feature gives a lot of the power of C++ templates. This makes it easier to implement a lot of libraries which are just a pain to do in plain C. Even seemingly simple things like a generic vector are annoying to do in C, unless you abandon type safety and just start passing pointers to void. I get it, thanks. in C you have to cast everything to (void *) to do things like a generic vector. >I believe Zig even has some libraries for doing more exotic things easily, such as converting between an array of structs and a struct of arrays (and back). yes, iirc, there was a zig thread about this on hn recently.
- pjmlp 2y ago
- FpUser 2y ago>"but Rust is actually a replacement for C++. " I would disagree. C++ provides way more features than Rust and to me Rust feels way more constrained comparatively.
- tialaramex 2y agoSure, in the sense that in C++ they've got the Head Of Vecna: https://rpgmuseum.fandom.com/wiki/The_Head_of_Vecna https://rpgmuseum.fandom.com/wiki/The_Head_of_Vecna Many of my favourite Rust features aren't in C++. For example they don't have real Sum types, they don't have the correct move semantic, they are statement oriented rather than expression oriented and their language lacks decent built-in tooling. But also, some of the things C++ does have are just bad and won't get fixed/ removed because they're popular. And there's no sign of it slowing down. I think that in practice you should use Rust in most places that C++ is used today, while some of the remainder should be WUFFS, or something entirely different.
- FpUser 2y ago>"I think that in practice you should use Rust" I am doing fine. Thank you. Also I am not a language warrior. I do have my preferences but use many since I am an independent and work with many clients.
- pjmlp 2y agoThe biggest issue for me, is that Rust isn't used where I care about, mainstream language runtimes, compiler toolchains, and GPU ecosystem standards. No one from them would accept a patch in Rust instead of C or C++. Yes I know about Deno, but even them haven't rewriten V8, and wgpu or Rust CUDA aren't the same as what Khronos, NVidia, AMD, Microsoft put out in C++.
- krona 2y ago> Rust is actually a replacement for C++ Last I checked, rust touted itself as a systems programming language, which C++ kinda is but mostly isn't (many C++ features just aren't appropriate or are poorly suited for systems programming). I would never choose Rust over C++ for scientific programming, because Rust metaprogramming features are so poor. However I'd probably choose Rust over C in many areas where C is best suited. So to me the venn diagram of utility shows Rust to overlap with C far more than C++.
- smartmic 2y agoFrom what you describe, you might also like Odin.
- zoogeny 2y agoInterestingly enough, it is one of the only "talked about" languages I have almost no experience with. Even Roc I've watched a few YouTube videos on. I've only really seen Odin mentioned on X, not even a HN post. I suppose there is also Jai in a similar space as well, although I'm not a devotee to Jonathan Blow and I don't share much of the excitement his followers seem to have. I do feel Zig has the current trend moving in its favor, with projects like Ghostty and Bun gaining prominence. I think Odin would need something like that to really capture attention.
- dismalaf 2y agoOdin has commercial applications, basically all the JangaFX apps... But yeah, it's missing a killer open source app. Positive is it has a decent amount of batteries included.
- smartmic 2y ago> I've only really seen Odin mentioned on X, not even a HN post. But there are some: https://hn.algolia.com/?q=Odin https://hn.algolia.com/?q=Odin
- johnisgood 2y agoI'm not a devotee to the creator of Odin. Odin may be fine, but I'm hesitant when it comes to contributing to it. Welp. Life goes on.
- christophilus 2y agoI've played with Hare, Zig, and Odin. Odin is my favorite. It's a fair bit faster to compile (similar to Hare), and has the nicest syntax (subjectively speaking). I wish it would get more traction. Looking forward to trying Jai if it ever makes it to GA.
- wolfspaw 2y agoOdin is the best (followed by Zig) Odin has the best approach for "standard library" by blessing/vendoring immensely useful libraries Odin also has the best approach for Vector Math with native Vector and Matrix types
- tialaramex 2y agoThe swizzling is pretty cool, rather special purpose but it makes sense that Ginger Bill wanted this and it's Ginger Bill's language. Odin's "standard library" stuff is very silly, it still feels like we were just copy-pasted the lead developer's "useful stuff" directory. Bill doesn't feel there's a value to actual standard libraries, so instead here's... whatever. He insists that's not what's going on here, but that doesn't change how it feels.
- LAC-Tech 2y agoI don't say the "lower language wars" as being between zig and rust. I see it as being between old and new. And I'm on team new.
- baranul 2y agoIt's questionable how attractive Zig really is, outside of people getting caught in the wave generated by its foundation, where there is a clear self financial benefit. A Zig language review indicates there are many questions as to its usefulness, and why it hasn't hit v1 yet, over just using C and the many available libraries of that ecosystem. Famous C programmers like Muratori, homemade hero, do not like Zig nor recommend it[1]. Rust is primarily aimed at more specific use cases, evolving around memory safety and low(er) level programming. So where people might dislike the confusing syntax and difficulty of learning either Zig or Rust (among other inconveniences), its harder to make arguments against Rust's usefulness for safety, maturity (v1 plus), or present job market popularity. Zig does not have the luxury of those bonus points. When it comes to general-purpose programming, including for hobbyists or students, there are many other alternative languages that are arguably much more attractive, easier to use, and/or easier to learn. Golang, Vlang, Odin, Jai, C3, etc... [1]: https://www.youtube.com/watch?v=uVVhwALd0o4 https://www.youtube.com/watch?v=uVVhwALd0o4 ("Language Perf and Picking A Lang Stream" from 29:50)
- knighthack 2y agoI'm happy for Zig to gain support for one major reason: Zig does not engage in "woke" culture the way Rust does. Zig seems to take a neutral, technical-first stance, while Rust has a strong focus on inclusivity, strict moderation, and social policies like with the foundation drama (which is just nonsense for a programming language). I really wish Nim would have won the language wars though.