222 points · by michaelsbradley · 4y ago · 62 comments
For folks that are more experienced and learn by doing, the two resources I would recommend are https://nim-by-example.github.io/ and https://xmonader.github.io/nimdays/. The first is a solid overview of the basic language, while the second is a bunch of example projects. Other good resources if anyone is interested:
Nim in Action (book)
https://narimiran.github.io/nim-basics/
The official Nim tutorial: https://nim-lang.org/docs/tut1.html
Nim also had a devroom at FOSDEM this year! You can find it at https://fosdem.org/2022/schedule/track/nim_programming_langu....
My favorite talks were on Polymorph (a really fast compile time ECS), Pararules (a super cool implementation of a rules engine) and Nim Metaprogramming in the real world (very useful lesser known patterns for using Nim's capabilities in a variety of projects).
Free chapters and some other resources available here: https://book.picheta.me/ :)
It seems to be that Crystal has made some leaps and bounds in picking up some of the Ruby slack, though I see Nim lagging behind of taking up some Python users.
I’d feel 100000x more comfortable as a potential user if they had a little more corporate support and some mainstream use cases.
I think I’ll take this post as the wake up call to take Nim more seriously in my own hobby programming. I’ve had my eye on it since they changed the name and I discovered it; but I didn’t realize until today people were building such thorough resources.
GCC supports way more architectures than LLVM.
[1] https://forum.nim-lang.org/t/8950
I just wish I had the opportunity to use it. Every time I start working on a personal project, I always default to Python just because I know it well and I know the ecosystem has every library I could want. I need an excuse to write something in Nim.
Overall I'm finding Nim performs well at real-time style processing with ARC – even when allocating memory. Its memory allocator is taken from research for embedded real time allocation. Still the best pattern is to pass memory as mutable variables on hot processing paths:
proc processAudio(someBuffer: openArray[byte]) = ...
Next couple of weeks I'll using Nim on an MCU taking real-time ADC readings at ~64khz. That'll be fun as it'll require interfacing pre-allocated DMA buffers and with multithreaded ARC managed buffers. And they say it's all web programming nowadays. ;)At the very least, the book looks like a good introduction to computer programming in general (not just Nim).
My introduction long ago was the 'commodore 64 programmer reference guide'. The mix of hardware, graphics, sid sound, BASIC and assembly language was great for the curious, learning by taking things/programs apart (and sometimes put them back together) while small enough to fully grasp.
Then moved from basic to assembly, pascal, c, python, c++ (and cuda). Wouldn't mind trying Nim or Rust next. Reading such nice book makes it inviting.
Late last year I switched my work site from Go to Nim. Then this year, with the help of the community and library nimterop, I was able to wrap the duckdb C api and use it in my web app for really fast analytic queries. I really like Nim syntax and the routes in jester:
routes:
get "/":
resp "Wow, nice"
The false-positive virus issue affected my workstation as well, but after consulting with our security team we were able to resolve it.I would love Nim to have more funding and support.
I like the batteries included approach, but certainly there are some libraries that do things like json better.
The first supported back-end is Nim, which I use in my own projects. Python and other back-end languages will be easy enough to add. The initial front-end is Flutter.
Nim is a great language, very easy to learn and write in. I was a bit skeptical of using a non-OO language for large projects, but it's been fine, and I actually prefer it now.
edit:
He also wrote a GTK4 programming guide with Nim examples, which was already submitted here in 2020.
https://ssalewski.de/gtkprogramming.html
Strangely, neither of those books is linked on his homepage.
Few things made me confused a bit
* With objects, when I need to use ref and when not.
nim> type
.... Node = ref object
.... le, ri: Node
.... data: int
....
....
nim> var n = Node(data: 9)
nim> n.data
9 == type int
nim> type
.... NodeO = object
.... lw, ri: ref Node
.... data: int
....
....
nim> var no = NodeO(data: 9)
nim> no.data
9 == type int
nim>
* Two ways to import modules, specifically the C style import. I understand the need for it - applying macros and templates, but that makes Nim very different from big family of "no magic" languages. Ability to change syntax is very powerful and probably a big selling point of the language, but in the same time makes it hard to use Nim as casual language.That time development/coding wasn't my full time job, Python was the "to go" option of automating some tasks, sometimes Java. In both cases there was no magic in the code - `module.something` easy to track to the origin.
Nim's orientation to standard library is nice. I've started checking Nim when I need a faster alternative for parsing big json and csv (compressed and flat) files. I both cases to was easy to archive, easier than Java (with Java I need to match version and bring dependencies) and the speed was fantastic.
Probably the main reason I haven't continued with Nim, was the company's antivirus at some point started to blocks nimble.exe execution on Windows. Another reason is switching to work into data engineering aria and there is no real need for fast compiled program. IDE support wasn't great too, VScode suggested a lot of irrelevant things, but I think it is kind of broken for any language now (out of box).
The syntactic differences between Modula-3 and Nim don't mean much in the long run. It's just the fourth phase of this particular superfamily's syntax. It's a bit of an oversimplification, but the preceding syntactic phases can be clumped into "Algol", "Pascal", and "Modula". All of them have significant syntactic differences between them but ultimately come from the same heritage, and I see "Nim" as just the next phase of that.
(to elaborate a bit: when Wirth evolved Algol 60 into Algol W, he only made small tweaks to the fundamental syntax. He then siginificantly overhauled it when he evolved Algol W into Pascal and then Pascal into Modula(-2). Borland/Embarcadero's evolutions of Pascal are of the same category as Algol W in that they made small tweaks while keeping the core syntax the same. Wirth's further languages Oberon and Oberon-2 all kept the same fundamental structure as Modula-2, despite various small syntactic tweaks, as did Modula-3 which wasn't by Wirth but had his blessing.)
You can even use objects named "self" to ease the transition.
https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programm...
1. strong financial backing, with open governance and broad contributors, and
2. cool
... has only a thin sliver of overlap.
At some point, either you're motivated to tinker and explore, or you aren't. I can't say what the future holds for Nim, but I would wager that it's an order of magnitude more likely to be around in 20 years than any personal side project app that one of us writes.
I admit, it’s a true work of love.
However, its bus factor is 1. I would love to see some effort to make sure it has a future beyond that.
Humans are volatile.
(What’s up with projects maintained by the late Jörg Schilling?)
In some other programming languages like Python or Ruby we can define class methods or static methods which are bound to a class or type and can be called as MyType.myProc. In Nim we can do something similar by use of the typedesc proc parameter type:
But the boil-the-ocean first chapter, e.g. "what is an algorithm", should fall to the editor's pen. No good book is "for everyone." The first chapter misleads new programmers into the idea that the book is for them while they are beginners.
But when evaluating these things keep the following in mind:
- we're very active on matrix / discord [0][1] and more than willing to provide significant help to anyone who wishes to use Nim for scientific computing
- all of us that do use Nim for scientific computing wouldn't do it, if it wasn't feasible. While we're small, we do have all functionality that any of us need & in the cases where specific things are lacking, we have the ability to call Python [2], Julia [3] and R code [4].
And just keep in mind, every community starts small. :)
[0]: https://matrix.to/#/#nim-science:envs.net
[1]: https://discord.gg/f5hA9UK3dY
[2]: https://github.com/yglukhov/nimpy/
4 hours ago? It says 4 days for me.
https://twitter.com/jae_tacen/status/1497242050185498630
tacen.com