5 ms·
Zig is a modern C, Rust is a modern C++/OCaml So if you enjoy C++, Rust is for you. If you enjoy C and wish it was more verbose and more modern, try Zig.
by lionkor 8mo ago
Zig is a modern C,
Rust is a modern C++/OCaml
So if you enjoy C++, Rust is for you. If you enjoy C and wish it was more verbose and more modern, try Zig.
- bayindirh 8mo agoSeriously asking, where Go sits in this categorization?
- shilgapira 8mo agoIt's also a modern C. If you enjoy C and wish it was less verbose and more modern, try Go.
- bayindirh 8mo agoThanks. I write some Go, and feel the same about it. I really enjoy it actually. Maybe I'll jump to Zig as a side-gig (ha, it rhymes), but I still can't motivate myself to play with Rust. I'm happy with C++ on that regard. Maybe gccrs will change that, IDK, yet.
- VorpalWay 8mo agoGo has a garbage collector though. This makes it unsuitable for many use cases where you could have used C or C++ in the past. Rust and Zig don't have a GC, so they are able to fill this role. GC is a showstopper for my day job (hard realtime industrial machine control/robotics), but would also be unwanted for other use cases where worst case latency is important, such as realtime audio/video processing, games (where you don't want stutter, remember Minecraft in Java?), servers where tail latency matters a lot, etc.
- bboozzoo 8mo ago> GC is a showstopper for my day job (hard realtime industrial machine control/robotics) Which is a very niche use case to begin with, isn't it? It doesn't really contradict what the parent comment stated about Go feeling like modern C (with a boehm gc included if you will). We're using it this way and it feels just fine. I'd be happy to see parts of our C codebase rewritten in Go, but since that code is security sensitive and has already been through a number of security reviews there's little motivation to do so.
- VorpalWay 8mo ago> Which is a very niche use case to begin with, isn't it? My specific use case is yes, but there are a ton of microcontrollers running realtime tasks all around us: brakes in cars, washing machine controllers, PID loops to regulate fans in your computer, ... Embedded systems in general are far more common than "normal" computers, and many of them have varying levels of realtime requirements. Don't believe me? Every classical computer or phone will contain multiple microcontrollers, such as an SSD controller, a fan controller, wifi module, cellular baseband processor, ethernet NIC, etc. Depending on the exact specs of your device of course. Each SOC, CPU or GPU will contain multiple hidden helper cores that effectively run as embedded systems (Intel ME, AMD PSP, thermal management, and more). Add to that all the appliances, cars, toys, IOT things, smartcards, etc all around us. No, I don't think it is niche. Fewer people may work on these, but they run in far more places.
- pjmlp 8mo agoSee TamaGo, used to write firmware in Go, being shipped in production.
- VorpalWay 8mo agoNot familiar with it, but reading the github page it isn't clear how it deals with GC. Do you happen to know? Some embedded use cases would be fine with a GC (MicroPython is also a thing after all). Some want deterministic deallocation. Some want no dynamic allocator at all. From what I have seen, far more products are in the latter two categories. While many hobby projects fall into the first two categories. That is of course a broad generalization, but there is some truth to it. Many products want to avoid allocation entirely either because of the realtime properties, or because they are cost sensitive and it is worth spending a little bit extra dev effort to be able to save an Euro or two and use a cheaper microcontroller where the allocator overhead won't fit (either the code in flash, or just the bookkeeping in RAM).
- pjmlp 8mo agoYes, just like with real time Java for embedded targets from PTC and Aicas, it is its own implementation with another GC algorithm, additionally there are runtime APIs for regions/arenas. Here is the commercial product for which it was designed, https://reversec.com/usb-armory https://reversec.com/usb-armory A presentation from 2024, https://www.osfc.io/2024/talks/tamago-bare-metal-go-for-arm-risc-v-socs/ https://www.osfc.io/2024/talks/tamago-bare-metal-go-for-arm-...
- andrewl-hn 8mo agoGo is modern Java, at least based on the main area of usage: server infrastructure and backend services.
- bsaul 8mo agoi wonder what makes go more modern than java, in terms of features.
- cultab 8mo agoThe tooling and dependency management probably
- thezipcreator 8mo agoI still don't understand how they managed to make a build system as bad as Gradle. It's like they tried to make it as horrible as possible to use.
- kristianp 8mo agoYes, every time I fire up an old Android project it needs to download 500MB just for gradle upgrades. It's nuts.
- KronisLV 8mo agoTbh Go is also really nice for various local tools where you don’t want something as complex as C++ but also don’t want to depend on the full C# runtime (or large bundles when self-contained), or the same with Java. With Wails it’s also a low friction way to build desktop software (using the heretical web tech that people often reach for, even for this use case), though there are a few GUI frameworks as well. Either way, self contained executables that are easy to make and during development give you a rich standard library and not too hard of a language to use go a long way!
- 9rx 8mo agoGo is modern/faster Python. - It was explicitly intended to "feel dynamically-typed" - Tries to live by the zen of Python (more than Python itself!) - Was built during the time it was fashionable to use Python for the kinds of systems it was designed for, with Google thinking at the time that they would benefit from moving their C++ systems to that model if they could avoid incurring the performance problems associated with Python. Guido Van Rossum was also employed at Google during this time. They were invested in that sort of direction. - Often reads just like Python (when one hasn't gone deep down the rabbit hole of all the crazy Python features)
- gf000 8mo agoNowhere, or wherever C# would sit. Go is a high level managed language.
- Imustaskforhelp 8mo agoGo is a language which sits perfectly where using garbage collection is no problem with ya.
- benob 8mo agoTime to start zig++
- microtonal 8mo agoIt is kind of interesting that the Linux kernel is slowly adopting Rust, whereas Zig seems like it would be a more natural fit? I know, timelines not matching up, etc.
- keybored 8mo agoAnd “if you enjoy C++/if you enjoy C” are gross oversimplifications.
- andrepd 8mo agoDefinitely not. Rust gives you a tangible benefit in terms of correctness. It's such a valuable benefit that it outweighs the burden of incorporating a new language in the kernel, with all that comes with it. Zig offers no such thing. It would be a like-for-like replacement of an unsafe old language with an unsafe new one. May even be a better language, but that's not enough reason to overcome the burden.
- dnautics 8mo agoactually that's not true at all. Zig offers you some more safety than C. And it also affords you a compiler architecture and stdlib that is so well designed you could probably bolt on memory safety relatively easily as a 3rd party static checker https://github.com/ityonemo/clr https://github.com/ityonemo/clr
- simonask 8mo ago"More safety than C" is an incredibly low bar. These are hygiene features, which is great, but Rust offers a paradigm shift. It's an entirely different ballpark.
- dnautics 8mo agonegative. For example bounds checking is turned on by default in Zig, which prevents classes of overflow safety errors.
- geon 8mo agoComparing Rust to C++ feels strange to me. It’s like people do it just because Zig is very comparable to C. So the more complex Rust must be like something else that is also complex, right? And C++ is complex, so… But that is a bit nonsensical. Rust isn’t very close to C++ at all.
- lionkor 8mo agoI wrote lots of C++ before learning Rust, and I enjoyed it. Since learning Rust, I write no more C++. I found no place in which C++ is a better fit than Rust, and so it's my "new C++". For example, high performance servers (voltlane.net), programming languages (https://github.com/HF-Foundation https://github.com/HF-Foundation, https://github.com/lionkor/mcl-rs https://github.com/lionkor/mcl-rs, and one private one), webservers (beampaint.com) and lots of other domains. Rust is close to C++ in that it is a systems language that allows a reasonable level of zero-cost abstractions.
- pjmlp 8mo ago> found no place in which C++ is a better fit than Rust, and so it's my "new C++". Writing the compiler toolchains that Rust depends on, industry standards like CUDA, SYSCL, Metal, Unreal or the VFX Reference Platform.
- simonask 8mo agoRust uses LLVM because it's pretty great, not because you couldn't implement LLVM in Rust. Maybe cranelift will eventually surpass LLVM, but there isn't currently much reason to push for that.
- 7bit 8mo agoC++ added OOP to C. Rust is not object-oriented. That makes your statement wrong.
- pjmlp 8mo agoIt certainly is according to the various CS definitions of type systems. Plenty of OOP architectures can be implemented 1:1 in Rust type system.
- Ygg2 8mo ago> Plenty of OOP architectures can be implemented 1:1 Plenty of OOP architecture can be implemented in C. That's an extremely flawed and fuzzy definition. But we've been through this before.
- pjmlp 8mo agoYet people have to keep be reminded of it.
- Ygg2 8mo agoI think the issue is OOP patterns are one part missing features, one part trying to find common ground for Java, Modula, C++, SmallTalk, that it ends up too broad. A much saner definition is looking at how languages evolved and how term is used. The way it's used is to describe an inheritance based language. Basically C++ and the descendants.
- 9rx 8mo ago> one part trying to find common ground for Java, Modula, C++ The primary common ground is that their functions have encapsulation, which is what separates it from functions without encapsulation (i.e. imperative programming). This already has a name: Functional programming. The issue is that functional, immutable programming language proponents don't like to admit that immutability is not on the same plane as imperative/functional/object-oriented programming. Of course, imperative, functional, and object-oriented language can all be either mutable or immutable, but that seems to evade some. > SmallTalk Smalltalk is different. It doesn't use function calling. It uses message passing. This is what object-oriented was originally intended to reference — it not being functional or imperative. In other words, "object-oriented" was coined for Smalltalk, and Smalltalk alone, because of its unique approach — something that really only Objective-C and Ruby have since adopted in a similar way. If you go back and read the original "object-oriented" definition, you'll soon notice it is basically just a Smalltalk laundry list. > how term is used. Language evolves, certainly. It is fine for "object-oriented" to mean something else today. The only trouble is that it's not clear to many what to call what was originally known as "object-oriented", etc. That's how we end up in this "no its this", "no its that" nonsense. So, the only question is: What can we agree to call these things that seemly have no name?
- api 8mo agoMy take, unfortunately, is that Zig might be a more modern C but that gives us little we don’t already have. Rust gives us memory safety by default and some awesome ML-ish type system features among other things, which are things we didn’t already have. Memory safety and almost totally automatic memory management with no runtime are big things too. Go, meanwhile, is like a cleaner more modern Java with less baggage. You might also compare it to Python, but compiled.
- kprotty 8mo agoZig gives things we really dont have yet: C + generics + good const eval + good build system + easy cross compilation + modern niceties (optionals, errors, sum types, slices, vectors, arbitrary bit packing, expression freedom). Are there any other languages that provide this? Would genuinely consider the switch for some stuff if so.
- vitaminCPP 7mo ago+1 The zig toolchain is the state of the art currently.
- mgoetzke 8mo agoAs someone who never liked writing anything C++ since 2000+ (did like it before) I cannot agree with this. C++ and Rust are not comparable in this sense at all. One can argue Rust is what C++ wanted to be maybe. But C++ as it is now is anything but clean and clear.
- lionkor 8mo agoSee my other comment[1] It replaces C++ for me, so I would say it's "a C++" [1]: https://news.ycombinator.com/item?id=47334275 https://news.ycombinator.com/item?id=47334275
- keybored 8mo agoAnd in a world of only you your claim is true.
- naasking 8mo agoI think the comparison is fair, strictly in the sense that both Rust and C++ are designed around extensible programming via a sort of subtyping (C++ classes, Rust traits), and similar resource management patterns (ownership, RAII), where Zig and C do not have anything comparable.
- jodleif 8mo agoI found swift way more enjoyable than rust as a C++ alternative. It even has first class-ish interop now.
- pjmlp 8mo agoZig is Modula-2/Object Pascal re-packaged with a C like syntax.