> 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 help…
> 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.
Ask HN: Does anyone use Nim language in production?
41–50 of 86 posts
Re: Ask HN: Does anyone use Nim language in production?
#42Not myself personally, but I know this game was written with nim: https://impbox.itch.io/vektor2089 .
Re: Ask HN: Does anyone use Nim language in production?
#43Yes, 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 (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…
Being a hosted language (compiles to C/C++/Javascript) which are the biggest pains? Is there any way to ensure type checking for the exposed interfaces in runtime? Let's say, exposing a function to the host language (C or Javascript) which accepts a String and then passing an integer in the host language. Did you ever use the javascript backend? How is the experience having a shared code base among very different pla…
With the C backend, the Nim code is transpiled to C code (surprisingly readable C code, as far as auto-generated C goes), which is then compiled to one of: a binary executable, a shared C library, or a static C library: https://nim-lang.org/docs/nimc.html#compiler-usage
In fact, Nim-Pymod relies upon the Nim->C->library compilation, because it uses the Python C API to produce Python extension modules: https://docs.python.org/2/extending/extending.html , https://docs.python.org/2/c-api/
If you want to see a shared C library produced by Nim, have a play with some of the examples provided with Nim-Pymod: https://github.com/jboy/nim-pymod/tree/master/examples It auto-generates the appropriate Python C API boilerplate functions around your Nim functions, then compiles the whole thing as a shared C library, exposing the auto-generated functions in the shared library.
Regarding runtime type-checking: Again, I can only talk about the C backend. The type checking provided by shared or static C libraries will be whatever the C compiler enforces... I haven't tested whether (or how much) this can be violated.
Nim-Pymod does auto-generate the Python->C type-checking code for you, so you can't (for example) pass in a Python string when an int is expected by your Nim function.
Re: Ask HN: Does anyone use Nim language in production?
#44Earlier quoted context omitted.
* 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 d…
Being 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 dif…
I don't like Go's explicit error handling because (1) I think it clutters up your main code path with error-handling logic, and (2) it forces you to always handle errors locally (even if that local code does not have the context to know how to handle the error) or return the error code through multiple layers of functions (back to where it can be handled).
That said, I completely agree that exceptions are also problematic. As you say, you can never really be sure of what exceptions can be thrown. Some languages have a "throw" keyword, in which you're meant to enumerate the list of possible exceptions; but of course, that's a headache to maintain, and is affected by inner code (such as library code) that might be completely out of your control or review. And when should the "throw" keyword be enforced, at compile time or runtime? And what should happen if the "throw" keyword's list of possible exceptions is violated?
Then of course there is the other problem with exceptions, the flip-side to being forced to handle an error locally: As your exception unwinds the stack, it might obliterate some local context that is needed to decide how to handle the error; or it might obliterate some local context that is needed to continue with your original task after the error has been handled!
The most interesting (and least broken) error-handling mechanism I've encountered is Common Lisp's "condition" system: http://www.gigamonkeys.com/book/beyond-exception-handling-co...
I see C++'s `std::set_new_handler` function [0] as C++'s less-capable equivalent to Lisp condition handlers. But the function invoked by `std::set_new_handler` lacks the ability to assess local context to decide how to handle the problem.
[0] http://www.cplusplus.com/reference/new/set_new_handler/
EDIT: I would love to see a language like Nim incorporate something like Lisp's condition system. Nim already offers "procedural types" (function pointers) [1] and closures [2] to capture variables from the enclosing scope. Nim even offers "anonymous procs" [3], to avoid the need to define new error-handling functions everywhere.
[1] https://nim-lang.org/docs/manual.html#types-procedural-type
[2] https://nim-lang.org/docs/manual.html#procedures-closures
[3] https://nim-lang.org/docs/manual.html#procedures-anonymous-p...
Re: Ask HN: Does anyone use Nim language in production?
#45Earlier quoted context omitted.
Being 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 dif…
Even though I don't like Go's explicit error handling, I think this is a very reasonable comment. I don't like Go's explicit error handling because (1) I think it clutters up your main code path with error-handling logic, and (2) it forces you to always handle errors locally (even if that local code does not have the context to know how to handle the error) or return the error code through multiple layers of function…
This is something that Nim offers via the `raises` pragma[1]. It is enforced at compile-time and in my experience works rather well.
1 - https://nim-lang.org/docs/manual.html#effect-system-exceptio...
Re: Ask HN: Does anyone use Nim language in production?
#46Earlier quoted context omitted.
Happy 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 powe…
> Lack of exceptions Go does support multiple return values, commonly (T, error). If you think about it for a while, you will realize a exception is just a type of return value. Regarding generics, the more I used golang, the less I had a need for generics. Also, there is solutions if you insist, such as https://github.com/cheekybits/genny
No, they are part of the syntax. The compiler (in Nim and other languages) can track which exceptions are allowed to be raised in a procedure and which aren't at compile time:
https://nim-lang.org/docs/tut2.html#exceptions-annotating-pr...
Re: Ask HN: Does anyone use Nim language in production?
#47Noob question: differences between Nim and Crystal?
One prominent difference is that Crystal compiles to LLVM whereas Nim compiles to C/C++ (and also JS).
Re: Ask HN: Does anyone use Nim language in production?
#48Earlier quoted context omitted.
Even though I don't like Go's explicit error handling, I think this is a very reasonable comment. I don't like Go's explicit error handling because (1) I think it clutters up your main code path with error-handling logic, and (2) it forces you to always handle errors locally (even if that local code does not have the context to know how to handle the error) or return the error code through multiple layers of function…
> That said, I completely agree that exceptions are also problematic. As you say, you can never really be sure of what exceptions can be thrown. Some languages have a "throw" keyword, in which you're meant to enumerate the list of possible exceptions; but of course, that's a headache to maintain, and is affected by inner code (such as library code) that might be completely out of your control or review. And when shou…
[0] http://www.gigamonkeys.com/book/beyond-exception-handling-co...
Re: Ask HN: Does anyone use Nim language in production?
#49Earlier quoted context omitted.
Happy 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 powe…
* 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 d…
Can we please let go of this meme? Many polyglot developers complain about the lack of generics, and how Go code ends up being more verbose and less expressive than languages like Python.
Things like interfaces and pointers to interfaces, structs vs slies and maps are not consistent.
Re: Ask HN: Does anyone use Nim language in production?
#50Earlier quoted context omitted.
Seconded. Being able to insert an underscore and have the code still compile sounds like a strange design choice to me. dom96, could you write more on this?
A lot of people have this reaction, but I am still yet to find a single person that gave Nim a proper try only to decide that it is not for them because of style insensitivity. It's definitely weird and I personally could take it or leave it. But don't let it dissuade you from trying the language. The idea behind this feature is to let you choose which style you want to write code in.