3 ms·
Nim looks really awesome but I have a couple questions. Is Nim a replacement for high level for performant languages like OCaml, Haskell, etc. Or is it supposed
by smabie 6y ago
Nim looks really awesome but I have a couple questions. Is Nim a replacement for high level for performant languages like OCaml, Haskell, etc. Or is it supposed to be lower level and replace C? How does GC interact with the preferred style? Can you go without it?
- dsrw 6y agoIt’s really for both. I’m paraphrasing, but during Araq’s intro talk during the conference he said something like “Nim should be suitable for every task, but maybe not every programmer”. Whatever you’re trying to do, there’s probably a pretty good way to do it in Nim. It can run on microcontrollers or supercomputers. It can compile to C, C++, JS or LLVM ir (via nlvm), and has a good interop story with all of them. You can use it’s advanced meta programming facilities to create specialized domain specific languages, or you can ignore that feature and write code that looks more or less like python. It has an advanced compiler with lots of optimization opportunities, but it also has an interpreter if performance is less important. You can use it without GC, but the new arc collector is suitable for hard real-time, so I don’t think there are many cases where you’d need to drop to manual management. The main downsides (in my mind) are the small community and somewhat limited debugging support. I really like the language however, and use it wherever I can.
- mratsim 6y agoOCaml, with D, are probably the languages that feel the most similar to Nim. Regarding Haskell, you can do category theory[1] if you want or do integer operations within the type system like dependently typed languages[2], including BigInt computation at compile-time[3]. Regarding speed, Haskell and OCaml are sometimes as fast as C, Nim is always as fast as C. [1]: https://github.com/unicredit/emmy#algebraic-structures https://github.com/unicredit/emmy#algebraic-structures [2]: https://github.com/mratsim/constantine/blob/0400187f/constantine/elliptic/ec_endomorphism_params.nim#L24-L61 https://github.com/mratsim/constantine/blob/0400187f/constan... [3]: https://github.com/mratsim/constantine/blob/0400187f/constantine/config/precompute.nim#L490-L533 https://github.com/mratsim/constantine/blob/0400187f/constan...