4 ms·
I use Nim at work. I've built a backend CLI program that processes signal data collected from instruments. That CLI program is used in many contexts, but is pri
by netbioserror 3y ago
I use Nim at work. I've built a backend CLI program that processes signal data collected from instruments. That CLI program is used in many contexts, but is primarily called through a PHP API by many of our web services. The executable has no dependencies (compiled with musl-libc and statically-compiled libraries).
Modeling problems is almost as powerful as a Lisp: It prefers stack allocation, immutable data, and referentially transparent procedures, but all of that can be short-circuited when necessary. The type system is simple and clear. The syntax is Pythonic and easy to make readable and self-documenting. Magic is not required. The Datamancer data frame library is incredibly robust. The standard library is quite extensive, and the included JSON data structure functions well as a dynamic, heterogenous structure when needed. Turning Nim objects and data into JSON is so trivially easy that it's a no-brainer for my use case, and probably web-focused use cases as well. Nimja templating is incredibly good and great for building pages or documents, so long as you're preprocessing as much as possible (as with most templating libraries). C interop is also trivially easy, requiring no more than a function signature in most cases.
I can absolutely say that Nim has been a secret weapon for tackling the specific data processing problem I've been solving. Highly recommended, especially if you can invoke it from the CLI using other languages to solve things such as UI. I'm building an Electron app around it currently, and the NodeJS backend invokes my Nim program.
- wodenokoto 3y agoHow is it for data exploration? Can you run things in a repl?
- netbioserror 3y agoIt has a very rudimentary REPL in the form of `nim secret`; however, the compiler internals are being revamped a bit in the coming versions to make room for full-featured incremental compilation and REPL support.
- netbioserror 3y agoSorry, to answer your question about data exploration, quite good. Reading files is a single procedure call which slurps into strings. Parsing JSON (or Datamancer parsing CSV) is a single procedure call. Nim objects and most compound data structures such as JsonNodes and DataFrames have printing support build in, using the `$` proc which is the language's equivalent to `toString()` and should be defined on every type possible. In short: It's great.
- archargelod 3y agoFor REPL you have three options: - [0] `nim secret` : code is interpreted with Nim's vm. It is limited to compile-time evaluations (e.g. no C/C++ interop). - [1] `nlvm r` : nlvm backend supports JIT compilation and repl-like interface was added in latest release. - [2] inim : supports all nim code, but it's not really a true repl. It adds code to a file and recompiles it (you can see the source file with `ctrl+x`). I'd recommend to use it with clang compiler, because it's a bit faster than gcc in my experience. It's the best option right now. And I use it almost daily. First two options have rudimentary input system. But you can get command history and left-right navigation by wrapping them with rlwrap (should be preinstalled on most *nixes): `rlwrap nim secret`, `rlwrap nlvm r`. There are plans to support incremental compilation for the next Nim release (it is currently broken). That would improve inim and other repls experience significantly. [0]: https://nim-lang.org/docs/manual.html#restrictions-on-compileminustime-execution https://nim-lang.org/docs/manual.html#restrictions-on-compil... [1]: https://forum.nim-lang.org/t/10697 https://forum.nim-lang.org/t/10697 [2]: https://github.com/inim-repl/INim https://github.com/inim-repl/INim
- V1ndaar 3y ago> The Datamancer data frame library is incredibly robust. Thank you for the kind words! :) Especially given that it's a one-man side-project always makes me a bit worried people will stumble over all sorts of issues.
- netbioserror 3y agoThe only thing I could ask for is categorization in the API docs. They're a bit hard to search or discover. Some of that is just the Nim automatic docs though. Other than that, fantastic library.