4 ms·
> Syntax wise Nim it is a step back. It's hard to read and understand while any C/C++ dev will have next to no effort reading through D code. And of course whil
by mratsim 6y ago
> Syntax wise Nim it is a step back. It's hard to read and understand while any C/C++ dev will have next to no effort reading through D code. And of course while D is C ABI compliant it interoperates with C++ well too.
On the other hand, people coming from Python, Ruby, Pascal, Ada will appreciate the minimal amount of sigils.
> I seriously doubt that Nim or any other language in this regard has better metaprogramming than D.
Can you write an Embedded DSL + compiler running at compile-time in D
- https://github.com/numforge/laser/tree/master/laser/lux_compiler https://github.com/numforge/laser/tree/master/laser/lux_comp...
Can you write a cryptographic library with hex conversion to big integer and modular arithmetic running at compile-time in D?
- https://github.com/mratsim/constantine/blob/master/constantine/config/curves_declaration.nim#L51-L110 https://github.com/mratsim/constantine/blob/master/constanti...
Can you generate a state machine that lowers down to optimized computed gotos with no dynamic allocation suitable for multithreading runtimes and embedded devices and able to display the actual graph at compiletime?
- https://github.com/mratsim/Synthesis https://github.com/mratsim/Synthesis
Can you describe x86 opcodes in a declarative way for a JIT assembler and do all the rex/modrm/sib computation at compile-time?
- https://github.com/mratsim/photon-jit/blob/master/photon_jit/x86_64/x86_64_ops.nim#L24 https://github.com/mratsim/photon-jit/blob/master/photon_jit...
And the same thing for an emulator?
- https://github.com/mratsim/glyph/blob/master/glyph/snes/opcodes.nim#L16-L127 https://github.com/mratsim/glyph/blob/master/glyph/snes/opco...
Can you implement async as a library?
Can you emulate classes with ADTs to solve the expression problem, avoid cache misses and multithreading problem due to OOP and the double indirection due to the visitor pattern?
- https://github.com/mratsim/trace-of-radiance/blob/master/trace_of_radiance/support/emulate_classes_with_ADTs.nim https://github.com/mratsim/trace-of-radiance/blob/master/tra...
> Nim might have a speed overhead in certain tasks but that depends on a benchmark. Besides, does Nim have anything similar to NumPy which is actually faster? D does.
It does:
- https://github.com/mratsim/Arraymancer https://github.com/mratsim/Arraymancer
With CPU, OpenCL and Cuda backends (in differing state of maturity)
and it's being used for data analysis for example ancestry prediction:
- http://home.chpc.utah.edu/~u6000771/somalier-ancestry.html http://home.chpc.utah.edu/~u6000771/somalier-ancestry.html
You can even run a neural network and see its training live:
- https://github.com/Vindaar/NeuralNetworkLiveDemo https://github.com/Vindaar/NeuralNetworkLiveDemo
AFAIK D doesn't have any plotting library while Nim has plot.ly integration and a ggplot2 port in pure Nim:
- https://github.com/brentp/nim-plotly https://github.com/brentp/nim-plotly
- https://github.com/Vindaar/ggplotnim https://github.com/Vindaar/ggplotnim
And lastly nim can easily call Python:
- https://github.com/yglukhov/nimpy https://github.com/yglukhov/nimpy
or be called from Python:
- https://github.com/Pebaz/nimporter https://github.com/Pebaz/nimporter
- tastyminerals 6y agoAlso, all good points. Appreciate that.
- moonchild 6y agoI suspect d's metaprogramming is not as good as nim's (haven't used the latter), though it's better than metaprogramming of every language I've used without macros. That said, it can do all of the metaprogramming-related tasks you mention.
- mratsim 6y agoAre you aware of D libraries in that vein? I'm especially interested in the first 2, since those are something I'm actively working on at the moment.
- moonchild 6y agoI don't know of any DSLs, but the stdlib arbitrary precision integer library works just fine at compile time: enum x = BigInt("0xffffffffffffffffffffffffffffffff") % 2; writeln(x); ('enum' means 'make this value a compile-time constant; error if you can't')