3 ms·
Nim is a relatively small programming language that uses a Pythonic style of syntax. It adds some features that make it better suited to systems development, li
by eindiran 7y ago
Nim is a relatively small programming language that uses a Pythonic style of syntax. It adds some features that make it better suited to systems development, like type safety and better performance. It can be compiled using a few backends, to eg C or JavaScript.
Nim recently hit 1.0 and has grown a lot of the years, but it still isn't particularly common to see in industry. You can see some Nim related projects on GitHub: https://github.com/topics/nim https://github.com/topics/nim
I used it to write a few things/just play around with in the pre-1.0 days, and found it quite nice to write and easy to read.
Regarding your question about numerical analysis and Python, this post touches on using Nim for tasks that you might reach for numpy for: http://rnduja.github.io/2015/10/21/scientific-nim/ http://rnduja.github.io/2015/10/21/scientific-nim/
This one has a brief comparison of Nim and Python + numpy: https://narimiran.github.io/2018/05/10/python-numpy-nim.html https://narimiran.github.io/2018/05/10/python-numpy-nim.html
Note that both are for pre-1.0 Nim.
Nim's site: https://nim-lang.org/ https://nim-lang.org/
- girvo 7y ago> isn't particularly common to see in industry You're completely right, but I can say I've introduced it for writing custom developer tooling across three companies, including one very large rather well known one in the travel space (though that was pre 1.0)!
- sp33der89 7y agoWhat was your experience like using Nim for those projects?
- girvo 7y agoWonderful; though I've been using it for quite literally years at this point. It's pretty rapid compile times, coupled with easy-as-anything C integration meant writing performant CLI tools or daemons with it was a breeze. The nicest part of Nim I feel is that it was super easy for non-Nim programmers to pick up and understand. The team would regularly contribute to the tooling despite not using it anywhere near as extensively as myself, which I think speaks volumes to it's ease-of-use
- jonahx 7y agoHow does it compare with Go and Rust?
- kungtotte 7y agoI haven't written any Go, and only a little Rust, but it competes with both of them in a way. It's safe and GC'd by default, but you can trivially swap GC or you can run entirely without GC and do everything manually. It's idiomatic to use managed references but you can do unsafe pointers if you want. Interoperability with C is easy but not seamless like with for instance Zig. Compile times are excellent compared to Rust, as are binary sizes, making static binaries is trivial (which is harder in Go from what I understand). I find the syntax easier/better than Rust with fewer special characters, but compared to Go I think the syntax is a wash. It requires very little boiler plate, and let's you do things that cut down on code size like using `var` or `let` statements in blocks: var intVal: int strVal: string I like the distinction of var vs. let over Rust's let mut/let as well. The two major weaknesses at this point are package availability and documentation. There's a package for everything in Go and Rust land, and there's lots of documentation for everything. There's quite a handy standard library in Nim and most of what you typically need in the Nimble package manager, but sometimes you'll run into the situation of having to roll your own X.
- rezeroed 7y agoIt's a pleasure to use compared to Go. (Also, has generics).
- logicchains 7y agoWhat are Nim's compile times like? I write a lot of C++, and by far my biggest issue is compile times for large projects. I'd love a systems language that had decent compile times for template-heavy code.
- sp33der89 7y agoAs girvo mentioned, compile times are really fast. Might not be as fast if you're heavy user of metaprogramming but it's still really good. For example see: https://github.com/mratsim/Arraymancer https://github.com/mratsim/Arraymancer in the README it mentions: > Note: While Nim is compiled and does not offer an interactive REPL yet (like Jupyter), it allows much faster prototyping than C++ due to extremely fast compilation times. Arraymancer compiles in about 5 seconds on my dual-core MacBook.
- PMunch 7y agoReally fast! Even with heavy meta-programming it stays fast. As an example bootstrapping the latest stable release on my machine takes 1m06s. This is a process that involves compiling the compiler multiple times, just compiling the compiler takes 41s (i7-4770K, so not a sloth of a processor, but still).
- beagle3 7y agoNim is not a “small language”; it’s huge in scope, both domain and range. It is well thought out, so that you don’t need to be aware of all of it to be effective, though. It’s community is comparatively small, but it is incredibly helpful, smart and capable.