Computer Programming with Nim
ssalewski.de
ssalewski.de
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.
[1] https://forum.nim-lang.org/t/8950
We use Nim to prototype many things (though not all things), and in many cases they go into production with `-d:release` just fine:
https://github.com/orgs/status-im/repositories
A good example is nimbus-eth2, which is one of the (The?) most energy-efficient Beacon Chain clients, with real money at stake:
The reality is that most people are not going to use cryptocurrency anytime in the next 10 years. Landlords won't take it, grocery stores won't take it, the whole thing is a mind-boggling waste of time and energy.
Even still, while the tech Status is producing might be cool, surely you can't be so naive as to overlook the obvious tinge it places on other potential Nim adopters.
I'm a crotchedy 50+ yo fart, so pay me no mind if what I say bothers you.
you can't be so naive as to overlook the obvious tinge it places on other potential Nim adopters
I've done a lot of soul-searching on this front, and I can't even conceive of a "tinge" on rational potential Nim adopters. Rational at times
I try to be, especially when on the clock :D Nim itself never felt tinged to me back when I tried (and enjoyed) it. But I generally won't touch anything "crypto".
Fair enough (I guess). But if you work/play-with with Nim these days, and the libs available from https://nimble.directory/, do you feel you're "touching crypto"? If so, why? huge number of crypto projects that are indistinguishable from Ponzis, vehicles for what would be a financial crime if done with regulated instruments, or just the counterproductive inclusion of a blockchain
Well... I feel I stand little chance of convincing you of anything, but feel free to checkout the status-im GitHub org I've linked to previously, and you're also very welcome to ask Status core contributors the most scorching questions you can think of via our desktop/mobile app, or on our Discord server, or on https://discuss.status.im/.I haven’t had to report to a traditional manager for some years, but I can imagine the guffawing of bosses I’ve worked for in the past if I was pitching Nim for something and explaining the lay of the land. Especially since those big buy/sell decisions are often made by non-technical people.
How am I supposed to convince someone to take a ride on Nim when they could point me at Go, or Clojure, or Elixir, etc? I’m just pointing out there’s a lot of choices with very strong corporate third-party adopters.
I’m not an advocate for the way things are, but it’s just a fact of the world that ecosystems with strong corporate backing have a higher likelihood of survival and success.
I hope Nim succeeds, as I assume you do also. I hope you personally succeed. Crypto though, I kinda just hope it all goes away soon, and people look to change society in more pragmatic ways. I know a young fella in a PhD program, goes to my church, he’s getting a tooth pulled because he can’t afford dental coverage. It’s not the fiat currency that’s the problem. Crypto won’t fix these kinds of problems. Anyhow.
If the Status team ever comes around Indiana I’ll take you all out to dinner!
Thanks I'll drop in there some time, always up for learning something new and it doesn't sound like it's ... the laser eyes crowd.
My own experience and interest in cryptocurrency is zero. But my interest in Nim is .GT. 0.
I will say it doesn't bother me personally about the current sponsorship, but I see your point. The linked book is in my reading list - it is the sort of online book that I would love to see professionally typeset for hardcopy.
Status only started sponsoring Nim in 2018[1]. Before that Nim was doing just fine. So the answer to your question is: nothing is going to happen to Nim if Status disappears.
1 - https://our.status.im/status-partners-with-the-team-behind-t...
GCC supports way more architectures than LLVM.
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).
You can even use objects named "self" to ease the transition.
https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programm...
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.)
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?)
> For now it's closer to an alternative with most deviations appearing in the standard library, mostly in the form of deleting much of it.
Yikes. I've found that languages with a small standard library have deep dependency trees for imported packages. I hope this is a stepping stone to a different standard library, rather than an end goal in-and-of itself.
Not really. The fork looks pretty dormant.
[1] https://forum.nim-lang.org/t/8540#55418
[2] https://github.com/nim-lang/Nim/commits/devel?author=Araq
[3] https://github.com/nim-lang/Nim/commits/devel?author=narimir...
Right now, it seems like most of the work on the mainline seems to be done by community members.
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.
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.
4 hours ago? It says 4 days for me.
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/
https://github.com/andreaferretti/nimblas
as well as LAPACK:
https://github.com/andreaferretti/nimlapack
For an example, consider calling the least squares routine `dgelsd` in arraymancer:
https://github.com/mratsim/Arraymancer/blob/master/src/array...
wrapped up in a nicer user facing API.
Feel free to hop onto matrix, if you have more questions!
https://twitter.com/jae_tacen/status/1497242050185498630
tacen.com