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.
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.
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.
Disclaimer: I'm tentatively exploring this via macros.
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.
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.
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.
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
I also toyed around with turning a math equation dsl into compiled statements at 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.
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].