> C++ with its classes and template is really hard. Can Nim use C++ libs like 
> Boost, CGAL, Qt out of the box?

I'm pretty sure it can.

We have wrapped a header-only C++ template-only bigint library: 
[https://github.com/status-im/nim-ttmath](https://github.com/status-im/nim-ttmath).

More benefits of the macro system:

  * no need to resort to Python, Ruby or JS codegen, or 2 step codegen to write 
an Assembler, VM Emulator, all can be done in Nim.
    * Example of C++ 2-step codegen for a popular assembler with text 
interpolation: 
[XByak](https://github.com/herumi/xbyak/blob/master/gen/gen_code.cpp) used by 
many projects including Intel Deep Learning backend.
    * Another example with a JS opcode table codegen, that is then pasted into 
C++ by 
[asmjit](https://github.com/asmjit/asmjit/blob/238243530a35f5ad6205695ff0267b8bd639543a/src/asmjit/x86/x86instdb.cpp#L12-L16)
 used notably by Facebook's PyTorch.
    * Nim proof-of-concept [Assembler opcode 
codegen](https://github.com/numforge/laser/blob/2f619fdbb2496aa7a5e5538035a8d42d88db8c10/laser/photon_jit/x86_64/x86_64_ops.nim).
    * Nim proof-of-concept [emulator codegen for 
6502](https://github.com/mratsim/glyph/blob/8b278c5e76c3f1053a196173a93686afda0596cc/glyph/snes/opcodes.nim)
  * You can reimplement Numpy-like indexing which is one of the main draws of 
Numpy, Julia and Matlab.
  * You can even implement your [own compiler in 
macros](https://github.com/numforge/laser/tree/2f619fdbb2496aa7a5e5538035a8d42d88db8c10/laser/lux_compiler)



i.e. I think Nim is the best language to provide custom focused DSL.

Beyond the macro system, I'm not aware of any other languages with the complete 
package of:

  * distinct types (i.e. avoid mixing Meters and Miles)
  * range types
  * type-level integer/boolean/enum
  * generics



which allows enforcing several constraints at compile-time.

In terms of breadth, Nim allows getting as close-to-metal as C when needed but 
as high-level as Python in case where tight control over OS resources (memory, 
file descriptor, sockets, ...) is not needed. The fact that the GC is tunable 
(we can swap implementation between deferred reference counting, 
mark-and-sweep, boehm) and also decided per type (only ref objects are GC-ed, 
plain object and ptr object are not) makes Nim very flexible.

Reply via email to