3 ms·
> What a truly inspiring language It's indeed an inspiring language, and rust is taking inspiration from it already: https://github.com/jswrenn/project-safe-tr
by littlestymaar 6y ago
> What a truly inspiring language
It's indeed an inspiring language, and rust is taking inspiration from it already: https://github.com/jswrenn/project-safe-transmute/blob/rfc/rfcs/0000-safe-transmute.md#safe-transmute-rfc https://github.com/jswrenn/project-safe-transmute/blob/rfc/r...
> lack of generics
I can't wait before Zig2 comes and eventually adds generics…
- dnautics 6y agoZig already has generics, gp was imprecise. They are not a part of the language, but an emergent feature that is simple enough to implement using comptime. Edit: clearly gp was not mistaken, just imprecise.
- pron 6y ago> and rust is taking inspiration from it already But C++/Rust can never have Zig's primary feature -- simplicity. Zig's power is not that it has comptime, but that it has little else. > I can't wait before Zig2 comes and eventually adds generics… No need. Zig gives you the same capabilities as generics do, only through a separate feature that other languages also have in addition to generics. In other words, it has generics, but without having generics as a special construct. Zig recognises that once you have that other feature (compile-time introspection) you don't need generics as a separate construct, but they can be just an instance of that single construct.
- littlestymaar 6y ago> But C++/Rust can never have Zig's primary feature -- simplicity Sounds like a Go pitch, except Zig ain't Go. And while comptime is a cool feature, it's also a really complex one! > In other words, it has generics, but without having generics as a special construct. Zig recognises that once you have that other feature (compile-time introspection) you don't need generics as a separate construct, but they can be just an instance of that single construct. This has advantages (only one feature to know), but it also has a big drawback: the lack of orthogonality. C is also simple, for instance it has no concept of errors (only return values) or arrays (only pointers), but most people won't consider this a good idea (and Zig didn't follow C on either of those two design points) Zig is cool, but I hoped the “generics are too complex of a feature” meme would die now that Go is getting generics, and I'd be really sad to see come back…
- pron 6y ago> it's also a really complex one! No, it's a very simple one, so much so that it's erasable: https://news.ycombinator.com/item?id=24293611 https://news.ycombinator.com/item?id=24293611 And still it is probably the most complex aspect of Zig. > Zig is cool, but I hoped the “generics are too complex of a feature” meme would die now that Go is getting generics, and I'd be really sad to see come back… You've misunderstood me. Generics are a good thing -- if that's all you have. But if you have generics and procedural macros, it turns out that you can do the work of both with a feature that's simpler than either. The capability generics add is a very important one, but given that low-level languages need another one as well, it turns out that generics can be subsumed into that one without being a separate and additional construct. Zig has generic types and concepts/typeclasses; these just aren't atomic language constructs.
- littlestymaar 6y ago> But if you have generics and procedural macros, it turns out that you can do the work of both with a feature that's simpler than either. Here I think we just have a different subjective perception of what simplicity is. I much prefer have two orthogonal systems which do their own business than having a single more powerful tool than do both (like having slices + references instead of the all powerful pointer) Anecdotal note: more than 10 years ago, the Go team pitched why they didn't need generics nor macros, because code generation would solve both problems (+ others), and now they're on their way back to add generics to Go (with a lot of hassle).
- pron 6y ago> I much prefer have two orthogonal systems which do their own business than having a single more powerful tool than do both (like having slices + references instead of the all powerful pointer) OK, but that's not quite the situation. Here we're talking about languages that have, or will have, the single "more powerful" construct, and also the more specific, special case one, as two separate constructs, even though one of them would have sufficed. Again, Zig has parameterized types, and very elegant and powerful ones -- they're functions that take some types as argument and return a type. It just doesn't have generics as a separate construct. Rather, it is a special case of a more general one (that Rust and C++ will also have).
- DennisP 6y agoLooks like comptime is what they already have instead: https://ziglang.org/documentation/master/#Introducing-the-Compile-Time-Concept https://ziglang.org/documentation/master/#Introducing-the-Co...
- irq-1 6y agoIn Zig types are values (same as any other value.) This lets you do generics without the need for any special syntax; you can simply pass types as parameters and return types.
- PaulDavisThe1st 6y agoClearly you meant zig++
- littlestymaar 6y ago(This was a reference to the Go language, which after a decade saying “generics aren't needed” and even “the lack of generics is a feature”, are eventually shoehorning them in the language in their Go2 campaign.)
- nulltype 6y agoI think they've been saying "We haven't yet found a design that gives value proportionate to the complexity, although we continue to think about it." since 2013: https://web.archive.org/web/20130410000959/https://golang.org/doc/faq#generics https://web.archive.org/web/20130410000959/https://golang.or...
- wtetzner 6y agoThat's what they've been saying, but I don't buy it. I mean, the workarounds are horrible code generation tools and reflection. How were those ever not considered to be more complex than generics?