12 ms·
Ask HN: Does anyone use Nim language in production?
How has your experience been compared to your previous tech?
How mature is the standard library? How abundant are third party libraries?
- lulyxime41 9y agogenial?
- dom96 9y agoJudging by the upvotes there is a lot of interest in hearing answers to this question and yet there are few comments so far. I will share my thoughts but keep in mind that I am (extremely) biased as I am one of the core Nim devs. > How has your experience been compared to your previous tech? Previous to using Nim I was primarily using Python. This was a few years ago now, but recently I was working on a project in Python and found myself yearning for Nim. There were multiple reasons for this, but what stuck with me was how much I missed static typing. The Python project used type hints which I found rather awkward to use (of course the fact that we didn't enforce their use didn't help, but it felt like such a half-baked solution). Dependencies very often required multiple guesses and searches through stack overflow to get working. And the resulting program was slow. As far as I'm concerned, Nim is Python done right. It produces fast dependency-free binaries and has a strong type system with support for generics. Of course, that isn't to say that Nim is a perfect language (but then what is). For example, JetBrains has done a brilliant job with PyCharm. Nim could use a good IDE like PyCharm and with its strong typing it has the potential to work even better. > How mature is the standard library? To be honest the standard library does need some work. In the next release we do plan on making some breaking changes, but we always lean on the side of keeping compatibility even though Nim is still pre-1.0. Of course, sometimes this is not possible. > How abundant are third party libraries? Not as abundant as I would like. Great news is that you can help change that :) The Nimble package manager is still relatively new, but you can get a pretty good idea of the third party libraries available by looking at the package list repo[1]. Hope that helps. Please feel free to AMA, I'd love to introduce you to our community. 1 - https://github.com/nim-lang/packages/blob/master/packages.json https://github.com/nim-lang/packages/blob/master/packages.js...
- vitiral 9y agoThanks for being honest with everything, I found this to be a very balanced answer. What would you say are the advantages of Nim over a language like Go? I see a lot of similar "value add" statements.
- dom96 9y agoHappy to hear that you found my answer balanced :) > What would you say are the advantages of Nim over a language like Go? I see a lot of similar "value add" statements. In all fairness I haven't given Go a proper try. But my main problems with it, based on what I've seen of it, are the following: * Lack of generics * Lack of exceptions * I prefer the Python-like syntax of Nim * Metaprogramming in Nim is fun and powerful * Lack of (official) package manager
- sepisoad 9y ago* Lack of generics * Lack of exceptions I don't see these items as being shortcomings. Go is simple and simplicity is elegance, and simplicity is something that cannot be found in most modern languages. Just look what happened to C++, It has become more like C# and Java. Regarding Nim, I believe it's a nice language and I have done a few small projects using it but just like what I mentioned there are 10000 ways to do a single task and that sometimes is confusing. BTW C/Go/lua are my languages of choice
- joobus 9y agoBeing fluent in Python and Go, I definitely prefer the explicit error handling in Go as opposed to the try-catch error handling in python where most of the time you can never really be sure of all the possible errors which can be thrown. I spent some time learning Haskell, and one of the points that stuck was that in languages with exception handling, a function will have some kind of declared result, but all the different exceptions which can be thrown are also basically alternative return values. Any caller of the function then has to know all possible return types to effectively handle all errors, but since most code doesn't document which errors might be thrown, it's a crap shoot. Functional languages basically force the return to always be the declared type, and go mostly follows this model.
- nimmer 9y ago> How has your experience been compared to your previous tech? Having used Python, Go, C, Perl, Java, Nim is a breeze to code in. Occasionally the compiler glitches and you have to delete nimcache. Very rarely it fails to compile something and you have to rewrite few lines differently. Not an issue. Build frequently to avoid any surprise. > How mature is the standard library? Not that much: it lacks examples and helper procedures that you would expect, yet I still feel more productive with Nim than other languages. > How abundant are third party libraries? Look at the packages. Most of the basic stuff it's there. For small and medium projects it's usually not an issue, occasionally I have to wrap functions from a C library. If you are looking for big, fancy libraries like Pandas and Sklearn, they are just not there. Use Nim for tool and services instead.
- ryanx435 9y ago> Very rarely it fails to compile something and you have to rewrite few lines differently This is a huge issue. If you can't trust the compiler, it's not ready to be used for any function that is system critical.
- dom96 9y agoThat depends on the frequency. Even gcc has bugs, albeit more rarely than Nim. The great thing about Nim is that you can very easily get in touch with one of the developers (me or Araq) on IRC/Gitter.
- ryanx435 9y agoYeah I don't care if you guys were on site providing 24/7 support, im not going to use a language in production that can't be trusted to compile accurately.
- throwaway7645 9y agoI've just started writing a few scripts I'd normally use Python for (no production) and have been impressed with the speed and binary sizes. Nim in Action (book) is really good and what is missing to get the beginner started. I'd like to see a PyCharm like IDE for Nim as well, but Vim seems to work well.
- girvo 9y agoSpin up VS Code and install the Nim plugin. Still not PyCharm, but damn close for my usage!
- throwaway7645 9y agoThank you!
- dmlorenzetti 9y agoFor those interested in "Nim in Action", its publisher, Manning has a 50% off all e-books sale going through midnight today (27-May). Use code `wm052717lt`. Usually when they have this sort of sale on a holiday weekend, they spin up some new 50% off sale the following day, so check in again Sunday if you missed it today.
- dom96 9y agoHere is another discount code for today: wm052817lt Also here is my referral link (helps me when you buy via this link :) ) https://www.manning.com/books/nim-in-action?a_aid=niminaction&a_bid=78a27e81 https://www.manning.com/books/nim-in-action?a_aid=niminactio...
- effie 9y agoThanks, I've tried the code on the linked page, but it didn't work. Luckily the older code wm052717lt did work.
- throwaway7645 9y ago
- girvo 9y agoI did, and do at my new place of work too. Usually for tooling, automation, etc. As of 0.17, I'm quite happy with the standard library, though I still think the Futures impl needs a bit of work. I'm now using it extensively for a confidential computing and block chain project, which is quite exciting.
- PudgePacket 9y agoNot myself personally, but I know this game was written with nim: https://impbox.itch.io/vektor2089 https://impbox.itch.io/vektor2089.
- dom96 9y agoYep, impbox is extremely talented having won the latest Ludum Dare recently with Nim too[1] (A web version that uses Nim's JS backend also exists![2]) 1 - https://ldjam.com/events/ludum-dare/38/smalltrek https://ldjam.com/events/ludum-dare/38/smalltrek 2 - http://static.impbox.net/smalltrek/nicojs.html http://static.impbox.net/smalltrek/nicojs.html
- u2227 9y agoOne outsourcing company named Xored have choosen Nim as their primary language few years ago, at least that is what a company owner have declared.
- jboy 9y agoYes, my startup Object AI uses Nim code in production. We have in-house implementations of machine learning, computer vision & image processing code in Nim, using a library called "Nim-Pymod" to integrate with Python's Numpy: https://github.com/jboy/nim-pymod https://github.com/jboy/nim-pymod (As you can see, I was one of the authors of that library in a previous startup. We haven't worked on Nim-Pymod in a while, alas -- I've been focused on the new startup! -- but Nim-Pymod is sufficient for our needs right now.) Our webserver main-loops are in Python; our number-crunching ML/CV/img-proc code is Python extension modules written in Nim. As a C++ & Python programmer, I'm a huge fan of Nim, which to me combines the best of both languages (such as Python's clear, concise syntax & built-in collection types, with C++'s powerful generics & zero-cost abstractions), with some treats from other languages mixed in (such as Lisp-like macros and some Ruby-like syntax). I find Nim much more readable than C or C++, especially for Numpy integration. I also find Nim much more efficient to code in than C or C++ (in terms of programmer time). And Nim is a very extensible language, which enables Nim-Pymod to be more than just a wrapper. For example: 1. Nim-Pymod uses Nim macros (which are like optionally-typed Lisp macros rather than text-munging C preprocessor macros) to auto-generate the C boilerplate functions around our Nim code to create Python extension modules. 2. Nim-Pymod provides statically-typed C++-like iterators to access the Numpy arrays; these iterators include automatic inline checks to catch the usual subtle array-access errors. Nim macros are themselves Nim code, which can be controlled via globals, which in turn can be set by compiler directives; by compiling the Nim code in "production" mode rather than "debug" mode after testing, we can switch off the slowest of these checks to get back to direct-access speed without needing to make any code changes. (And of course Nim's static typing catches type errors at compilation time regardless of the compilation mode.) 3. Nim exceptions have an informative stack trace like Python exceptions do, and Nim-Pymod converts Nim exceptions into Python exceptions at the interface, preserving the stack trace, meaning you have a Python stack trace all the way back to the exact location in your Nim code. Earlier on in our development of Nim-Pymod, there were some occasional headaches with Nim due to its in-development status. Occasionally the Nim syntax would change slightly and that would break our code (boo). We've also debugged a few problems in the Nim standard library. I suppose these problems are an unfortunate consequence of Nim having a small set of core devs contributing their time (rather than being supported by Microsoft, Sun, Google or Mozilla). Fortunately, these problems seem to have stabilised by now. The Nim standard library is reasonably large, somewhere between C++ STL (data structures & algos) & Python stdlib (task-specific functionality). I recall that the stdlib could use some standardisation for uniformity, but I haven't been watching it closely for the last year or so. Third party libraries are not abundant, aside from a handful of prolific Nim community-members who have produced dozens of fantastic libraries (eg, https://github.com/def- https://github.com/def- , https://github.com/dom96 https://github.com/dom96 , https://github.com/fowlmouth https://github.com/fowlmouth , https://github.com/yglukhov https://github.com/yglukhov ). I'm happy to answer any other questions about using Nim in production!
- deleted 9y ago[deleted]
- galfarragem 9y agoNoob question: differences between Nim and Crystal?
- dom96 9y agoGood question, I wish I could give a good answer but I haven't looked into Crystal much. One prominent difference is that Crystal compiles to LLVM whereas Nim compiles to C/C++ (and also JS).
- samuell 9y agoFrom the crowd-sourced intr feature table I initiated [1] it turns out light-weight threads is one of the the more prominent features that is only supported by Crystal, and not Nim. [1] https://docs.google.com/spreadsheets/d/1BAiJR026ih1U8HoRw__nzbCSFnnHicWrjxpW5l6-O3w/edit#gid=0 https://docs.google.com/spreadsheets/d/1BAiJR026ih1U8HoRw__n...
- boduh 9y agoFor those using Nim: how is the compile speed?
- dom96 9y agoVery fast. I can bootstrap the compiler in under a minute. Compilation times are further reduced while developing thanks to incremental compilation.
- boduh 9y agoSounds great! What about debugging? I understand that Nim compiles to C/C++ so I am curious if I can use Xcode on a Mac and Visual Studio on Windows to debug the generated C/C++ code.
- yglukhov 9y agoHere's a small teaser of yet not fully released game: https://www.youtube.com/watch?v=3Hzhqjiz-Wo https://www.youtube.com/watch?v=3Hzhqjiz-Wo > How has your experience been compared to your previous tech? IMO. Comparing to C++, Objective-C, Java, Python, JavaScript, Python, D. Nim is an amazing language from its design standpoint. First, why we have chosen Nim for a pretty significant commercial project 2 years ago? Even though at that time Nim was not as stable as it is now, the main bet was on its hackability and compilation through C. That means a lot of things. E.g. we can fix some bugs in Nim ourselves, because the entry level is much lower than, say, with LLVM-based compiler. And if things go completely wrong and we can't fix them, we could use Nim's {.emit.} pragma to actually inject C code. A hammer of last resort :). As it turned out, there were some minor problems, but all of them were fixed pretty quickly either by our team, or by friendly Nim community. As for the language itself, it's simply amazing. These key points about efficiency and expressiveness are 200% true. But you can easily learn that from some simple pet projects. > How mature is the standard library? How abundant are third party libraries? The standard lib is OK, still could be polished a bit. We haven't had any critical issues with it. As for the third-party libs. Of course you can't be serious comparing Nim ecosystem to some more mainstream one, like js, python, go, you name it. During our project we had to reinvent a lot. There's an interesting observation though that things in Nim may be invented a lot faster than in aforementioned techs, but yeah, someone has to do it =). To summarize. If you're thinking whether it is worth to start a real commercial project in Nim (the answer is of course YES! DEFINITELY! =), consider the following: 1. Of your products' 100% functionality how much can be done with third-party libs? If the answer is "you take ruby on rails, write a couple of lines of code, and done!" then unfortunately Nim is not your option yet. But if this is a game, or a backend with a lot of logic, an app with simple UI and a lot of business logic, there is a good chance that Nim is your option. 2. If this is embedded code (like firmware or driver) you'd otherwise write in C or C++, you should consider Nim in the first place. 3. If so happened that Nim is a good option for you (which is rather likely), make sure your team has one or two experienced developers which can handle unexpected issues. Such developers should be fluent with C/C++ and JS (if you're using Nim JS backend or asm.js compilers). They should know how stuff works for the case, when you need a lib which is not available in Nim, and you decide whether to bind an existing one from foreign ecosystem, or to write your own. 4. Don't be afraid of the fact that Nim is still pre-1.0. Minor things may break occasionally, but nothing that single developer could not fix in a couple of hours in a 100KLoc project. Such things happened pretty rarely in our case and they are becoming even less frequent as Nim develops.