Hacker News new | ask | show | jobs
by mindv0rtex 2310 days ago
Funny, today's when I finally decided to start learning Nim. I do C++ with CUDA and Python on top for work. Having looked at the Arraymancer lib, I became interested in the language. Between its outstanding meta programming features and its ability to be compiled to C++, I think it is perfect for the scientific computing domain.
1 comments

Thanks for pointing it out, that library looks quite interesting. A question: it mentions it "Supports tensors of up to 6 dimensions.". Sadly some of us have to deal with tensors of even more dimensions sometimes. Does Nim support some kind of equivalent to C++'s variadic templates that would allow creating tensors with an arbitrary number of dimensions?
Author here:

Actually it's 7 [1]

But in my future backend revamp I plan to make the default 6 [2]

Note that the line can easily be updated to

    const MAXRANK* {.intdefine.} = 6
as in the planned revamp and then you would be able to change the MAXRANK with a compile parameter

    nim c -d:MAXRANK=16 path/to/my/app
[1]: https://github.com/mratsim/Arraymancer/blob/6fddfa9a734ac01c...

[2]: https://github.com/numforge/laser/blob/d1e6ae6106564bfb350d4...

Nim supports variadic templates, type checked variadic run time calls, and macros which let you run readable code at compile time (unlike C++ which has an accidentally turing complete, so can do anything but readability -- or speed -- are not part of that accident).

But unless you actually extend Arraymancer to more than 6 dimensions, you will likely lose some speed and convenience.

mratsim is a magician. Both Arraymancer (tensor library) and weave (multithreading core) are comparable and in some way better than other similar runtimes, despite being written by one person who is working on other projects as well.