3 ms·
Zig is trying to be a new C. Rust is trying to be a low-level ML. Sometimes people say that "Rust is trying to be the new C++" but this is only true in a more a
by scythe 3y ago
Zig is trying to be a new C. Rust is trying to be a low-level ML. Sometimes people say that "Rust is trying to be the new C++" but this is only true in a more abstract sense that looks at use cases — it doesn't follow the same technical path C++ did.
You could probably make a reasonable analogy that Zig:Rust::Go:OCaml but this isn't perfect. Zig is simpler to work with but it doesn't have as many powerful features, like certain Rust safety guarantees, as you mentioned.
- wredue 3y ago>doesn’t have as many powerful features comptime is easily one of the most powerful language features of any language in existence. Comptime gives you literally everything you get from macros and generics without the complexity of needing to know 3 separate Turing complete languages to get it. Zig doesn’t need a horde of random highly complex differently rule bounded features all complexily interacting with one another because it has 1 easy to use feature that eliminates those needs.
- satvikpendem 3y agoAh, if only Rust didn't drive away the person who was working on the comptime equivalent in Rust. Sadly, now it is likely that that will be a long way off.
- Ygg2 3y agoIf only 1% people whining about comptimes actually sat down and looked into adding it, we'd have comptimes already. Disclaimer: I'm tentatively exploring this via macros.
- veber-alex 3y ago> Comptime gives you literally everything you get from macros and generics without the complexity of needing to know 3 separate Turing complete languages to get it. comptime doesn't allow you to create domain specific macros like html! in Rust, it also doesn't allow you to constrain what types are accepted by your functions. It also has its own problems with long compile times.
- dundarious 3y ago> it also doesn't allow you to constrain what types are accepted by your functions. It does, if by constrain you mean “succeed or fail”: just write a comptime if statement and @compileError. If you mean a mechanism like concepts or SFINAE then you are correct.
- wredue 3y agoThe concept of “interfaces” in zig is a comptime pattern rather than a language construct. See std.io.SeekableStream. To check that an anytype meets the decls of SeekableStream is rudimentary. It’s funny that you say that about html, as a project in the discord was just released to get comptime html only in the last few weeks. I don’t remember the project name unfortunately.
- Laremere 3y ago> comptime doesn't allow you to create domain specific macros Sure it does! Zig's string format function is written using comptime. It parses the format string and validates the arguments at compile time. See https://github.com/ziglang/zig/blob/master/lib/std/fmt.zig https://github.com/ziglang/zig/blob/master/lib/std/fmt.zig I also toyed around with turning a math equation dsl into compiled statements at https://github.com/Laremere/alg https://github.com/Laremere/alg I got matrix math working so, eg, if you multiply a 2by1 matrix by a 1by2 matrix, it returns a matrix which is typed to 2x2.
- satvikpendem 3y ago> Rust is trying to be a low-level ML Yep, this is probably why I like it so much. I liked OCaml when I used it and Rust derives a lot of features from OCaml, as well as its initial compiler being written in OCaml, so I think the creators saw how well parts of OCaml fit together (Option and Result types, ADTs, etc) and added it to Rust, as Rust was much different than currently [0]. [0] http://venge.net/graydon/talks/intro-talk-2.pdf http://venge.net/graydon/talks/intro-talk-2.pdf