3 ms·
>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 literall
by 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.