3 ms·
D has a bigger scope than Rust. It is Rust‘s scope plus use cases where a garbage collector is appreciated and it provides more meta programming mechanisms. It
by qznc 3y ago
D has a bigger scope than Rust. It is Rust‘s scope plus use cases where a garbage collector is appreciated and it provides more meta programming mechanisms.
It might be the most comprehensive programming language ever.
- mratsim 3y agoWhat are the key metaprogramming features you miss when not using D? How do they compare to Nim's?
- chromatin 3y agoAlthough I haven't used Nim, something I miss while using rust is `static if`. You can sort of approximate / do a subset of this with #[cfg(xxx)] directives in Rust.
- cb321 3y agoFWIW, the Nim analogue of `static if` would be `when` statements. EDIT: or any of mratsim sibling's fine choices. Nim is Choice and has many uncommon compile-time powers.
- mratsim 3y ago`when myCondition():` instead of `if myCondition:` is done at compile-time. Alternatively you can use a `static:` code block to force compile time evaluation. Or tag a function {.compileTime.} or tag function inputs with `static` modifier. It is possible to create a compiler or an assembler running fully in Nim macros as well: - https://github.com/mratsim/constantine/blob/master/constantine/platforms/isa/macro_assembler_x86_intel.nim https://github.com/mratsim/constantine/blob/master/constanti... (all that file runs at compile-time) You can also implement Continuation-Passing-Style transformation at compile-time: - https://github.com/nim-works/cps https://github.com/nim-works/cps Or a neural network DSL or for a self-contained example, einsum: - https://github.com/mratsim/Arraymancer/blob/master/src/arraymancer/tensor/einsum.nim https://github.com/mratsim/Arraymancer/blob/master/src/array... It's worth noting that nim async/await transformation is fully implemented as a library in macros.