17 ms·
Zig's comptime is bonkers good
- datadeft 2y agoThis website is not mobile ready.
- HeliumHydride 2y agoWith reflection and code generation coming to C++26, and the already existing constexpr/consteval machinery, C++ will be able to do all of this.
- dwattttt 2y agoBash scripts and (optionally) an assembler can do this. That's not really the point.
- pipeline_peak 2y ago> Bash scripts and (optionally) an assembler What do you mean by that ?
- dwattttt 2y agoIn much the same way as "being Turing complete means you can do anything", it just being possible to do compile-time execution isn't the reason Zig is exciting here. C++ adding the same features means it'll be possible, but it has a much larger intersection of alternative features to introduce edge cases with, and _many_ implementations that will have this feature with varying quirks: all of this means C++ will have to do a _much_ better job than Zig does here to achieve nearly the same result.
- rowbin 2y agoThanks for that. I loathe replys like "but lang/framework/... can do/will be able to do something similar/does something else which I like better/...". Well, it's not about that. It's about how easy it is to use, how good it is from preventing you to shoot yourself in the foot, sometimes how performant it is, ...
- benatkin 2y agoIt's suggesting that Zig is convenient and that C/C++ won't be. I think both will be nice.
- carlos22 2y agoWell C++ has a history of not really being convenient and makes it easy to shoot you in the foot.
- logicchains 2y agoThat's something different, code generation. The point is that C++26 will have compile-time reflection without any need for an external code generation tool, similar to Zig.
- kstrauser 2y agoWith the main difference being that if you start Zig today, you’ll get to use that a good decade before it’s reliably available in C++. Hmm. Actually, now that makes me want to learn Zig.
- kevin_thibedeau 2y agoConsteval is usable today for a lot of scenarios that would require code generation tooling in years past.
- dwattttt 2y agoHow does consteval interact with thread_local? Defined (although I'm not sure what definition could make sense), error, or the dreaded "No diagnostic required"?
- flohofwoe 2y agoIn the end, generics, comptime and code generation are just different steps on the 'stamping out specialized code and data' ladder though (e.g. all three are useful).
- int_19h 2y agoErgonomics matters, though. In C++, this feature is bolted onto the language decades after it was originally designed. Zig is designed around this from the get go (which is why it doesn't have e.g. templates as a distinct feature).
- edflsafoiewq 2y agocomptime simplifies and unifies much of that machinery into a clean, conceptual framework.
- rochak 2y agoGood. Keep on adding stuff to an already bloated language.
- logicchains 2y agoCompile-time reflection will remove countless of lines of bloat from real C++ code bases due to eliminating the need to manually write formatting, hashing and serialisation implementations for classes.
- riwsky 2y ago…10 years from now
- fredrikholm 2y agoIf not more; the words "modern" and "C++11" are still used in conjunction despite the fact that 2014 was a long time ago.
- pjmlp 2y agoAll programming languages either die, or become bloated, as any software product. I bet a Fortran 77 developer will think the same of Fortran 2023, a COBOL 60 developer of COBOL 2023, a K&R C developer from C23, a 1975 Scheme developer from R7RS, a Python 1.0 developer from Python 3.13,... even Go 1.0 developers from 1.24 with generics, generators,...
- tialaramex 2y agoOne trick that can help you here is Rust's Editions (and the proposed but never implemented C++ Epochs). This lets the language throw away bad ideas, without throwing away the code people wrote in the era when we didn't realise that's a bad idea.
- pjmlp 2y agoKind of, because epochs only cover grammar changes and some kinds of semantic changes. It doesn't cover standard library, scenarios with binary libraries doing cross calls across epochs and several others. I still don't see it any different from a language version switch like in many other languages, specially in JVM and .NET ecosystem.
- brabel 2y agoThe examples in thist post seem very similar to how you do metaprogramming in the D language. That has existed for years yet you rarely hear about that.
- pjmlp 2y agoWith a much better ecosystem, 40 years of IDE tooling, frameworks, OS support. Which is what people always forget when comparing language grammars.
- 9dev 2y agoI'm not sure if you actually want to call "copy these header files into your local file system" an ecosystem at all. The last 40 years have brought heaps of improvements in software development ergonomics. Zig is growing just fine, as other languages like Rust or Go.
- pjmlp 2y agoThat is what script kiddies do when using compiled languages. Rust has had an almost usable implementation for affine types, and being the second coming of Ada, to win the hearths of the industry, including all major OS vendors and hyperscallers. Go got lucky with Docker and Kubernetes rewrites, and their adoption across the industry. So far Zig is basically Modula-2 with C like syntax, and compile time execution, relies on the same tooling that C and C++ have had for decades for use-after-free, doesn't support a binary libraries ecosystem by design, and really Bun isn't going to be the killer project that triggers a Rewrite in Zig movement. It remains to be seen if Zig 1.0 happens, and how its adoption story at scale will be like.
- vkazanov 2y agoI agree that zig is taking too long to be finalised. And rust has made certain questionable life choices. But people really, REALLY want to get off c and c++ for all the numerous reasons everybody knows.
- pjmlp 2y agoThey might want, yet while Khronos keeps publishing standards using C and C++, GCC/LLVM/CUDA/.NET/Java/V8/Metal make use of C++, Nintendo/PlayStation/XBox rely on C++, ... they are going to stay around no matter what.
- katzenversteher 2y agoReminds me of "Der Untergang". Mit dem Angriff C++26 wird das alles in Ordnung kommen!
- flohofwoe 2y agoC++ could do generic programming long before Zig even was an idea, but writing generic code in Zig is still much more straightforward - also Zig is usable now, while C++26 features will probably land in real world C++ compilers around 2036 ;)
- diimdeep 2y agoYeah it's good, and tech evangelism is just marketing.
- SMP-UX 2y agoZig is overall pretty good as a language and it does what it needs to: staying in the lane of the purpose is very important. It is why I do not particularly care for some languages being used just because.
- littlestymaar 2y agoComptime to replace macros is indeed good, comptime to replace generics on the other hand isn't and that really makes me think of the “when all you have is a hammer” quote.
- edflsafoiewq 2y agoWhy?
- bsder 2y agoThe problem is that the alternatives to comptime for generics generally seems to have a hideous effect on compile times (see: C++ and Rust). Is there a language that does generics in such a way that doesn't send compile times to the moon?
- edflsafoiewq 2y agoShouldn't comptime have the same compile time implications as templates? In both cases you're essentially recompiling the code for every distinct set of comptime args/template parameters.
- bsder 2y agoZig doesn't instantiate anything the doesn't get called. So, it doesn't have to generate a whole bunch of templated functions and then optimize down to the ones that actually get used. The upside is that if you only call a generic function with a u32, you don't instantiate an f32 as well. The downside is that when you do decide to call that function with an f32, all the comptime stuff suddenly gets compiled for the f32 and might have an error. In practice, I feel that I gain way more from the fast compile than I lose from having a path that accidentally never got compiled as my unit tests almost always force those paths to be compiled at least once.
- dwattttt 2y ago> it doesn't have to generate a whole bunch of templated functions and then optimize down to the ones that actually get used. It's been a long time since I've dealt with templated C++, but I thought this was how C++ does it too. C++ will only generate functions for template parameters that are actually used, because it compiles a version of the templated function for each unique template parameters.
- bryango 2y agoI hope we can have something that combines the meta-programming capabilities of Zig with the vast ecosystem, community and safety of Rust. Looking at the language design, I really prefer Zig to Rust, but as an incompetent, amateur programmer, I couldn't write anything in Zig that's actually useful (or reliable), at least for now.
- norman784 2y agoI Agree. I tried briefly Zig and quickly gave up because, as someone used to Rust, the compiler wasn't helping me find those issues at compile time. I know that Zig doesn't make those promises, but for me, it's a deal breaker, so I suppose Zig isn't the language for me. On the other hand, I do like the concept of comptime vs Rust macros.
- Validark 2y ago[flagged]
- bryancoxwell 2y agoI beg your pardon
- drogus 2y ago"the community" meaning one weirdo commenter you've seen on HN? Cause I can assure you no people I know in the Rust community think that way. Personally I would really like to code some stuff in Zig if I had more time. It's not really appealing to me in many ways (like I prefer to spend a bit more on designing types for my programs and have safety guartantees), so I wouldn't probably ue it long term, but I admit stuff like comptime is interesting.
- ArtixFox 2y agobruh, zig's VP called rust users safety coomers. Its internet shitposting who cares. source: I was there when it happened and it was GLORIOUS.
- 2y ago
- Tiberium 2y agoIf you're surprised by Zig's comptime, you should definitely take a look at Nim which also has compile-time code evaluation, plus a full AST macro system.
- foretop_yardarm 2y agoNim is a fun language but I wouldn't consider it for "serious" work. It has the same issues as other niche languages (ie. ecosystem), plus: a polarising maintainer (most core contributors don't seem to last long) and primarily funded by a crypto company (if you care about that). Then again, 10 years ago none of that would have bothered me.
- planetis 2y agoAll these organizations[1] using nim in production must disagree with you then. [1]: https://github.com/nim-lang/Nim/wiki/Organizations-using-Nim https://github.com/nim-lang/Nim/wiki/Organizations-using-Nim
- zamalek 2y agoZig has the feature of not having exceptions. I see that Nim is trying to move away from them, but exceptions color functions, which means that you have to account for them even if you don't use functions that throw them[1]. Life is too short to deal with invisible control flow. [1]: https://github.com/status-im/nim-stew https://github.com/status-im/nim-stew
- cb321 2y agoWhether you want to handle every error is context dependent. StatusIM has long running servers & clients as primary products and so tilt away from exceptions, but for a CLI utility you might want the convenience of a stack trace instead. I've seen this many times in Python CL apps, for example. Alternatively, there is also a Nim effects tracking system that lets the compiler help you track the hidden control flow for you. So, at the top of a module, you can say {.push raises: [].} to make sure that you handled all exceptions somewhere. So, it may not be as "Wild West" as other exceptions systems that you are used to. As with so many aspects, Nim is Choice. For many choice is good. For others they want language designers to constrain choice a lot (Go is probably a big recent example, because fresh out of school kids need to be kept away from sharper tools or similar rationales). A lot of these prog.lang. battles mirror bigger societal debates/divides between centralized controls and more laissez-faire arrangements. Nim is more in the Voltaire/Spiderman's Uncle Ben "With great power comes great responsibility" camp, but how much power you use is usually "up to you" (well, and things you choose to depend upon).
- pjmlp 2y agoWhile interesting, this is one of the cases, where I agree with "D did it first" kind of comments.
- sixthDot 2y agosure, and hygienically, it's not a preprocessor thing.
- noelwelsh 2y agoIt would be nice to have a more indepth discussion of the issues that have been found with compile-time programming, rather than uncritical acclaim. Staged programming is not new, and people have run into many issues and design tradeoffs in that time. (E.g. the same stuff has been done in Lisps for decades, though most Lisps don't have a type system, which makes things a bit more complicated.) Some of the issues that come to mind: * Implementing generics in this way breaks parametricity. Simply put, parametricity means being able to reason about functions just from their type signature. You can't do this when the function can do arbitrary computation based on the concrete type a generic type is instantiated with. * It's not clear to me how Zig handles recursive generic types. Generally, type systems are lazy to allow recursion. So I can write something like type Example = Something[Example] (Yes, this is useful.) * Type checking and compile-time computation can interact in interesting ways. Does type checking take place before compile-time code runs, after it runs, or can they be interleaved? Different choices give different trade-offs. It's not clear to me what Zig does and hence what tradeoffs it makes. * The article suggests that compile-time code can generate code (not just values) but doesn't discuss hygiene. There is a good discussion of some issues here: https://typesanitizer.com/blog/zig-generics.html https://typesanitizer.com/blog/zig-generics.html
- flohofwoe 2y agoI think most of those points one only stumbles over after a few thousand lines of Zig and going really deep into the comptime features. And some features in your list are of questionable value IMHO (e.g. the "reasoning over a function type signature" - Rust could be a much more ergonomic language if the compiler wouldn't have to rely on function signatures alone but instead could peek into called function bodies). There are definitely some tradeoffs in Zig's comptime system, but I think the more important point is that nothing about it is surprising when working with it, it's only when coming from languages like Rust or C++ where Zig's comptime, generics and reflection might look 'weird'.
- eptcyka 2y ago> Rust could be a much more ergonomic language if the compiler wouldn't have to rely on function signatures alone but instead could peek into called function bodies This path leads to unbounded runtime for the type checker/borrow checker. We’re not happy about build times as is.
- bilekas 2y agoI see a lot of people in the comments basically saying "well X did it first" and that it's not worth talking about. This missed the point for me, zig is an interesting one personally and not out of semantics of std lib or anything really, it's just something nice to play around with so far. I think with the above attitude we probably could have stopped systems programming at c++, that wouldn't be too fun at all, what we all do without java to laugh at?
- koe123 2y agoAnother interesting pattern is the ability to generate structs at compile time. Ive ran experiments where a neural net is implemented by creating a json file from pytorch, reading it in using @embedFile, and generating the subsequent a struct with a specific “run” method. This in theory allows the compiler to optimize the neural network directly (I havent proven a great benefit from this though). Also the whole network lived on the stack, which is means not having any dynamic allocation (not sure if this is good?).
- 0x1ceb00da 2y agoHow does this affect the compile times?
- koe123 2y agoThey become quite long, but it was surprisingly tolerable. I recall it vaguely but a 100MB neural network was on the order of minutes with all optimizations turned on. I guess it would be fair to say it scaled more or less linearly with the file size (from what I saw). Moreover I work in essentially a tinyml field so my neural networks are on the order of 1 to 2 MB for the most part. For me it wouldve been reasonable! I guess in theory you could compile once into a static library and just link that into a main program. Also there will be incremental compilation in zig I believe, maybe that helps? Not sure on the details there.
- erichocean 2y agoIt's nothing like C++ templates.
- anonymoushn 2y agoI've done this sort of thing by writing a code generator in python instead of using comptime. I'm not confident that comptime zig is particularly fast, and I don't want to run the json parser that generates the struct all the time.
- DanielHB 2y agoI believe that Zig build system can cache comptime processes, so if the JSON didn't change it doesn't run again.
- pakkarde 2y agoAfter having written a somewhat complete C parser library I don't really get the big deal about needing meta programming in the language itself. If I want to generate structs, serialization, properties, instrumentation, etc, I just write a regular C program that processes some source files and output source files and run that first in by build script. How do you people debug and test these meta programs? Mine are just regular C programs that uses the exact same debuggers and tools as anything else.
- nox101 2y agoI don't know about zig bit the power of lisp is that youre manipulating the s-expressions or to put it another way, you're manipulating the ast. To do that in C you'd need to write a full C parser for your C program that processes source files.
- modernerd 2y agoYes, this is the same approach Ryan Fleury and others advocate, and it's perfectly good: > Arbitrary compile-time execution in C: > cl /nologo /Zi metaprogram.c && metaprogram.exe > cl /nologo /Zi program.c > Compile-time code runs at native speed, can be debugged, and is completely procedural & arbitrary > You do not need your compiler to execute code for you https://x.com/ryanjfleury/status/1875824288487571873 https://x.com/ryanjfleury/status/1875824288487571873
- chikere232 2y agoMS DOS choice of / for commandline arguments and \ for paths always hurts my eyes
- zamalek 2y agoThe only benefit that some (certainly more rare) compilers can provide is type metadata/compile-time reflection. Otherwise, totally.
- account42 2y agoThis gets unwieldy quick as soon as your compiler host and target are different platforms.
- elcritch 2y agoAh ‘fieldNames’, looks very similar to Nim’s ‘fieldPairs’. It’s an incredibly handy construct! It makes doing efficient serialization a breeze. I recently implemented a compile time check for thread safety checks on types using ‘fieldPairs’ in about 20 lines. This needs to become a standard feature of programming languages IMHO. It’s actually one of the biggest things I find lacking in Rust which is limited to non-typed macros (last I tried). It’s so limiting not to have it. You just have to hope serde is implemented on the structs in a crate. You can’t even make your own structs with the same fields in Rust programmatically.
- drogus 2y agoAt some point there was a discussion about compile time reflection, which I guess could include functionality like that, but I think the topic died along with some kind of drama around it. Quite a bummer, cause things like serde would have been so much easier to imeplement with compile time reflection
- cb321 2y agoAnother example applying compile-time reflection is something like https://github.com/c-blake/cligen https://github.com/c-blake/cligen { but it helps if your host prog.lang has named parameters like Python's foo(a=1, b=2) }.
- ptrwis 2y agoWith comp-time reflection you can build frameworks like ORMs or web frameworks. The only trade-off is that you have to include such a library in the form of source code.
- Uptrenda 2y ago[flagged]
- cowsandmilk 2y agoThe article went off the rails at partial evaluation as it doesn’t even show an example of partial evaluation. And then the section on generating code really went nowhere useful.
- G3rn0ti 2y agoSite is down: https://web.archive.org/web/20250107090641/https://www.scottredig.com/blog/bonkers_comptime/ https://web.archive.org/web/20250107090641/https://www.scott...
- melodyogonna 2y agoMojo's compiletime metaprogramming [1] is inspired by Zig's. Though Mojo takes things further by implementing a fully-featured generic programming system. 1. https://docs.modular.com/mojo/manual/parameters/ https://docs.modular.com/mojo/manual/parameters/
- Validark 2y agoWhat can you do in Mojo that you can't do in Zig?
- kstrauser 2y agoPay a company for the privilege of being allowed to develop with it. It has a commercial license, where Zig is MIT’d. I haven’t written a line of either. I could see using Zig, but there’s no plausible scenario where I’d ever write Mojo. Weird proprietary languages tend to be a career pigeonhole: “you’ve been doing what for the last 5 years?”
- thefaux 2y agoWeird proprietary languages _can_ also be much better for a particular task than anything else and can thus be smart business. Someone who will dismiss something they don't know on the grounds that is weird and proprietary is not someone I'd want to work with. But of course if this is how a lot of people think then there may be no choice but for most people to try and stick with the tried and true.
- melodyogonna 2y agoNobody is paying anybody to use Mojo, its main issue is cross-platform support, specifically lack of native Windows support. Like I always say, most languages start off closed, incubated for some years by a tiny group, before being opened. Mojo is no different, in fact, Modular have given a pretty solid timeline about when they plan to open source the compiler - https://youtu.be/XYzp5rzlXqM?si=nmvghH3KWX6SrDzz&t=1025 https://youtu.be/XYzp5rzlXqM?si=nmvghH3KWX6SrDzz&t=1025
- bionhoward 2y agoRust really needs comptime, I love cargo and the ecosystem but trait level programming is weird, macros are weird, why can’t you just be normal? (rust screams)
- spacecow 2y agoTiny bug report: The second code example's output is still ">>array's<< sum is 6" (emphasis mine) even though the code snippet's printout is "struct's sum is {d}"
- ScottRedig 2y agoFixed, thanks for the report.
- mkl 2y agoA spelling error: "unnessisary" → "unnecessary".
- skocznymroczny 2y agoZig looks interesting, I just wish it had operator overloading. I don't really buy most of the arguments against operator overloading. A common argument is that with operator overloading you don't know what actually happens under the hood. Which doesn't work, because you might as well create a function named "add" which does multiplication. Another argument is iostreams in C++ or boost::spirit as examples of operator overloading abuse. But I haven't really seen that happen in other languages that have operator overloading, it seems to be C++ specific.
- flohofwoe 2y agoIn C++ I ever only used operator overloading for vector/matrix math (where it is indeed very useful). I'd be fine if a language implements the vector math syntax directly (like shading languages do). Zig at least has a @Vector() [1] type which is a bit similar to Clang's Vector Extension (but unfortunately not the Extended Vector Extension) [2]. [1] https://ziglang.org/documentation/master/#Vector https://ziglang.org/documentation/master/#Vector [2] https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors https://clang.llvm.org/docs/LanguageExtensions.html#vectors-...
- hiccuphippo 2y agoYou don't know the amout of magic that goes behind the scenes in python and php with the __ functions. I think zig's approach is refreshing. Being able to follow the code trumps the seconds wasted typing the extra code.
- magicalhippo 2y agoDepends on domain I think. In some cases it can be very beneficial to keep the code close to the source, say math equations, to ensure they've been correctly implemented. In this case the operators should be unsurprising, so they do what one would expect based on the source domain. Multiplying a vector and a scalar for example should return the scaled vector, but one should most likely not implement multiplication between vectors as that would likely cause confusion.
- melodyogonna 2y ago
- brylie 2y agoIs anyone here using Zig for audio plugin development? It seems like a good candidate as an alternative to C++ but lacks the ecosystem (like JUCE). Are there any ongoing efforts to bring DSP/audio plugin development to Zig?
- hiccuphippo 2y agoIIRC Andrew Kelley's original goal for developing Zig was to build a DAW.
- p0nce 2y agoI'm using D for audio plugins and we do use CTFE extensively (named comptime in Zig). Zig might be a bit more fit maybe because of the easier C and C++ interop and targetting, but I'm not sure about the COM and OOP story.
- melon_tusk 2y agoZig is alright, but Odin is amazing.
- akkad33 2y agoWhy?
- WalterBright 2y agoD had it 17 years ago! D features steadily move into other languages. > Here the comptime keyword indicates that the block it precedes will run during the compile. D doesn't use a keyword to trigger it. What triggers it is being a "const expression". Naturally, const expressions must be evaluatable at compile time. For example: int sum(int a, int b) => a + b; void test() { int s = sum(3, 4); // runs at run time enum e = sum(3, 4); // runs at compile time } By avoiding use of non-constant globals, I/O and calling system functions like malloc(), quite a large percentage of functions can be run at compile time without any changes. Even memory can be allocated with it (using D's automatic memory management).
- WalterBright 2y agoHere's one of my favorite uses for it. I used to write a separate program to generate static tables. With compile time function execution, this was no longer necessary. Here's an example: __gshared uint[256] tytab = tytab_init; extern (D) private enum tytab_init = () { uint[256] tab; foreach (i; TXptr) { tab[i] |= TYFLptr; } foreach (i; TXptr_nflat) { tab[i] |= TYFLptr; } foreach (i; TXreal) { tab[i] |= TYFLreal; } /* more lines removed for brevity */ return tab; } (); The initializer for the array `tytab` is returned by a lambda that computes the array and then returns it. A link to the full glory of it: https://github.com/dlang/dmd/blob/master/compiler/src/dmd/backend/var.d#L184 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ba... Another common use for CTFE is to use it to create a DSL.
- optymizer 2y agoWalter, I'll take any chance I can get to say: thank you for creating D! One thing I was wondering about is the limits of compile time execution. How does the D compiler ensure correctness if the machine the compiler runs on is different from the machine the program will execute on? For example, how does the compiler know that "int s = sum(100000, 1000000)" is the same value on every x86 machine? I'm thinking there could be subtle differences between generations of CPU, how can a compiler guarantee that a computation on the host machine will result in the same value on the target machine in practice, or is it assuming that host and target are sufficiently similar, as long as the architecture matches? (which is fine, I'm wondering as to what approaches exist)
- dminik 2y agoAs a disclaimer, the last time I gave Zig a solid shot was when 0.12 released. The last time I played with comptime properly was in 0.11. There's a heap of praise thrown at zig comptime. I can certainly see why. From a programming language perspective it's an elegant and very powerful solution. It's a shame that Rust doesn't have a similar system in place. It works wonderfully if you need to precompute something or do some light reflection work. But, from an actual user perspective it's not very fun or easy to use as soon as you try something harder. The biggest issue I see is that there's no static trait/interface/concept in the language. Any comptime type you receive as a parameter is essentially the `any` type from TypeScript or `void` from C/C++. If you want to do something specific* with it, like call a specific method on it, you have to make sure to check that the type has it. You can of course ignore it and try to call it without checking it, but you're not going to like the errors. Of course, since there are no interfaces you have to do that manually. This is done by reading the Zig stdlib source code to figure out the type enum/structures and then pattern-matching like 6 levels deep. For every field, every method, every parameter of a method. This sucks hard. Of course, once you do check for the type you still won't get any intellisense or any help at all from your IDE/editor. Now, there are generally two solutions to this: One would be to add static interfaces/concepts to the language. At the time this was shot down as "unnecessary". Maybe, but it does make this feature extremely difficult to use for anyone but the absolutely most experienced programmers. Honestly, it feels very similar to how Rust proc macros are impenetrable for most people. The second one is to take a hint from TypeScript and take their relatively complex type system and type assertions. Eg. `(a: unknown): a is number => typeof a === 'number'`. This one also seems like a bust as it seems to go against the "minimal language" mantra. Also, I don't get the feeling that the language dev team particularly cares about IDEs/LSPs as the Zig LSP server was quite bad the last time I tried it. Now, the third solution and the one the people behind the Zig LSP server went with is to just execute your comptime functions to get the required type information. Of course, this can't really make the experience of writing comptime any easier, just makes it so that your IDE knows what the result of a comptime invocation was. So in short it is as difficult to use as it is cool. Really, most of the language is like this. The C interop isn't that great and is severly overhyped. The docs suck. The stdlib docs are even worse. I guess I'm mostly dissapointed since I was hoping Zig could be used where unsafe Rust sucks, but I walked away unsatisfied.
- ajkjk 2y agoIs there such a thing as a language that is always comptime by default? I.e. the main source code of the language runs at compile time, but emits as output another object in some data structure which then becomes the runnable program?
- ags1905 2y agoHow does this compare to vlang's compilation time? Isn't vlang even faster?