5 ms·
There are two features of Jai I hope turn up in other languages. I'm fascinated by the 'struct of arrays' data pattern (columnar vs row-oriented storage, in ef
by hinkley 7y ago
There are two features of Jai I hope turn up in other languages. I'm fascinated by the 'struct of arrays' data pattern (columnar vs row-oriented storage, in effect), but also the ability to declare functions that run at compile time instead of run time, instead of macros.
- pcwalton 7y ago> declare functions that run at compile time instead of run time, instead of macros. Lots of languages have this, including C++.
- tekknolagi 7y agoAnd Zig!
- thethirdone 7y agoJai does it to a degree that is certainly not common. C++ in particular only has true guaranteed compile time execution for constexpr functions in static_asserts and a few other small cases. Jai on the other hand can do pretty much anything at compile time.
- unlinked_dll 7y agoconstexpr is Turing complete and it’s only limit is recursion depth of the compiler, which can be changed. And as of C++17/20 some of the weird stuff like not using conditionals and such isn’t present anymore. Also if you’re a masochist, the template system is Turing complete.
- thethirdone 7y agoI was not talking about the turing completeness of constexpr. There are only a few contexts in which constexpr functions are guaranteed to be evaluated at compile-time. This contrasts Jai's compile time only functions. Additionally, Jai can perform arbitrary IO at compile-time which is simply not possible with c++. One of the early demos had a program which played a videogame at compile-time.
- spc476 7y agoThat's something Forth can do. It's how the language is extended.
- TeMPOraL 7y ago> also the ability to declare functions that run at compile time instead of run time, instead of macros Lisp macros are such functions. But you can also declare regular functions to be compiled around macroexpansion time, which makes them available to call during macro expansion. You can use the same functions during macroexpansion/compiling and runtime too, and you can compile new functions at runtime.