4 ms·
This is awesome. The best kind of programming: doing something for the fun of it. Also, what is Nim? How popular is it? What popular products is it used in? W
by doctor_eval 7y ago
This is awesome. The best kind of programming: doing something for the fun of it.
Also, what is Nim? How popular is it? What popular products is it used in?
Would it be a useful language for a python developer to learn? I have a friend who is a python dev and he has lamented that he’d like to learn something else. Should I recommend nim? Is it good for numerical analysis?
- eindiran 7y agoNim 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.
- sp33der89 7y ago> Would it be a useful language for a python developer to learn Does he only know python? If so I'd say yes, Nim looks like Python but it's semantics are quite different and it performance a lot better. Also Nim <-> Python interop is nice too. Besides what eindiran said, your friend could also take a quick peek at: https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programm... and for numerical stuff Nim's ecosystem is quite young for it but people are working hard on it: https://github.com/HugoGranstrom/numericalnim https://github.com/HugoGranstrom/numericalnim I'd say go for it!
- nepeckman 7y agoAs someone who loves Nim and uses it a lot, I'm a little wary of recommending it as a faster Python. Nim takes from Python its whitespace sensitive syntax, as well as its "batteries included" standard library. But other than that, the two are very different languages with some major philosophical and semantic differences. That said, I much prefer Nim to Python. If you can live without a robust library ecosystem and are interested in a fast, easy to use language, Nim is a great fit.
- joppy 7y agoNim has a heavy focus on metaprogramming using both templates and macros, and so the syntax is designed to be very permissive, and parse (but not understand) a very wide grammar so that users can write macros/templates to transform them. Kind of a middle ground between lisps which have very little syntax, and complete syntax extensions to languages which require compiler extensions so the compiler can even parse the file.
- cpach 7y agoFor a fun example of some Nim action, check out this DSL that can generate SVG files and GIF animations: https://github.com/bluenote10/NimSvg https://github.com/bluenote10/NimSvg Pretty cool!