5 ms·
Would you kindly share you experience on using Nim for that project?
by nimmer 9y ago
Would you kindly share you experience on using Nim for that project?
- jamiesonbecker 9y agoFor that project, we had very specific requirements: easily handle SSL/TLS with contexts and control over self-signed vs certificate checking, JSON processing, speed, nice syntax, and one of the most challenging requirements: statically compiled, linkable against musl and libressl, while still supporting mingw_64 for windows. Only a few languages have flexible compilers that can do this; for example, rust can't (afaik). The experience so far has been outstanding. Nim has functioned flawlessly with a minimum of magic. It seems to work very cleanly and the compiler is cleanly integrated, but still swappable (ie between gcc, clang, ming..) Nicely color-coded, too. Exceptions are caught with full tracebacks, and pre-compile checks quickly point out exact location of syntax errors. (Good, clear error messages are surprisingly missing from many languages.) Here's an awesome example; in my first day of coding, I was able to replicate python's "+" string concatenator ("hello" + "world" versus "hello" & "world" in Nim) with a one-liner: proc `+` (x, y: string): string = x & y This is pretty amazing; not only is it readable and concise (and more than a passing similarity to python's lambda, of course) but nim comes with the ability to define new operators right in the language, and the compiler raises an error if operators, procs, types, etc would introduce ambiguity. Nim compiles quickly and its type inference (where it guesses what type of variable you're working with) makes strong typing mostly painless, and you still get all of the advantages (type safety, speed) of static typing. There are some trade-offs that are made (obviously), but the language designers seem to make trade-offs in favor of speed and robustness over language features -- but this still leaves a lot of room for features. I also like how the syntax has a lot of similarities to Python's. The only thing I've missed so far is a nim interpreter, so that I can get up to speed faster on the syntax or try things out quickly. The tutorial on the Nim website is definitely not for beginning coders (who would probably be quickly scared off by words like lexical), but it quickly covers the language syntax for experienced coders and seems to borrow a lot of the best ideas from other languages. Nim is basically awesome. The few downsides are that the standard library is still pretty light (but that gives you an opportunity to build something great and have it be widely adopted), that there's no interpreter, and that the tooling is still a bit lighter than older languages. All of these will be improved with time. And, it's fast. Really fast. Compare nim in these benchmarks[1] to any other mid-level (or even low-level) language and it really shines. It's generally much faster than Go, for instance. 1. https://github.com/kostya/benchmarks https://github.com/kostya/benchmarks
- Tiberium 9y agoIf you do concatenation a lot, it's better (for performance, of course) if you make it a template (so Nim will just replace a + b with a & b): template `+`(a, b: string): string = a & b But probably C compiler is smart enough to inline your proc :)
- jamiesonbecker 9y agoAh, brilliant! thanks!!
- Tiberium 9y agoYou can also check out this: https://github.com/Yardanico/nimpylib https://github.com/Yardanico/nimpylib But there's almost no features in it as I'm lazy :) I think that the best feature in this lib is a python-like range type: https://github.com/Yardanico/nimpylib/blob/master/src/pylib/range.nim https://github.com/Yardanico/nimpylib/blob/master/src/pylib/...
- jamiesonbecker 9y agohttps://github.com/Yardanico/nimpylib/blob/master/examples/example2.nim https://github.com/Yardanico/nimpylib/blob/master/examples/e... is really slick... looks so much like Python.
- bronze 9y ago> no interpreter Try running `nim secret` on the command line, it's not perfect but it's enough to play around a bit.
- jamiesonbecker 9y agoThank you!
- steveklabnik 9y agoRust can do what you asked, as far as I know.