8 ms·
Computer Programming with Nim
- talloaktrees 5y agoThis is very exciting! I had no idea this book was being written.
- adenozine 5y agoSidebar: I’m excited to see Nim get LLVM support via nlvm. I haven’t read this document yet but I just remembered that Nim is an advancing language and checked GitHub for new developments. 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.
- michaelsbradley 5y agoLots of exciting work also being done in libs, e.g. chronos[1] (just one example), which is an alternative to std/asyncdispatch[2]. [1] https://forum.nim-lang.org/t/8950 https://forum.nim-lang.org/t/8950 [&] https://github.com/status-im/nim-chronos#readme https://github.com/status-im/nim-chronos#readme [2] https://nim-lang.org/docs/asyncdispatch.html https://nim-lang.org/docs/asyncdispatch.html
- mathverse 5y agoYeah they need at least one more big corporate sponsor besides Status.
- michaelsbradley 5y ago"One more" because, in your view, it's important to have 2+ or it's problematic to have Status as a/your-only sponsor? Just curious.
- _dain_ 5y agoThe only big sponsor being a cryptocoin startup doesn't inspire a lot of confidence.
- michaelsbradley 5y agoOn technical merits or.......? 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 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: https://github.com/status-im/nimbus-eth2#readme https://github.com/status-im/nimbus-eth2#readme
- adenozine 5y agoWhether or not you agree with the many people who think cryptocurrency is the biggest grifting scam to ever grace the internet or not, the bottom line is that as long as they think that and as long as Status is the sole corporate interest behind Nim, then it faces real and several difficulty in picking up steam. 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.
- michaelsbradley 5y agoI'm a 45+ yo fart, and all my learning, experiences, and talents have in many recent years been and are being poured wholeheartedly into blockchain/crypto-related tech (which is all Open Source software), no regrets on my part whatsoever. 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.
- nimmer 5y agoNim uses GCC and works very well. Nim is among the fastest languages both in runtime and compilation time also thanks to GCC. GCC supports way more architectures than LLVM.
- erwincoumans 5y agoAt a glance, the writing is very friendly, fun and sincere. Indeed, there is a lot of competition in computer languages, and you need some strong supporters (such as games or corporate sponsorship) to survive. 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.
- jonpalmisc 5y agoI’m always hesitant to start projects in less popular languages without knowing if they will stick around, etc. I don’t know much about Nim, but I have tons of respect for people who create excellent content like this that helps a language become more popular and mainstream by making it more accessible.
- ushakov 5y agoNim is 14 years old
- WesolyKubeczek 5y agoBut still pretty much one-man work. 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?)
- ushakov 5y agothere is one designer, but the same thing is true for Ruby, Python and many other programming languages
- monetus 5y agoyeah, definitely not the only one pushing the design as well - dominick has had a pretty big impact I think right? He's at least helped me.
- auxym 5y agoA lot of previous contributors to Nim are currently working on an experimental fork due to disagreements with the development of the official compiler: https://github.com/nim-works/nimskull https://github.com/nim-works/nimskull
- rpdillon 5y ago
- rajandatta 5y agoImpressive work. Seems very thorough.
- ajusa 5y agoThis is a really fantastic resource for learning programming with Nim. I've started recommending it to folks that are newer to programming that want to try Nim out for various reasons. The only downside is that it is written by a non-native english speaker, so some of the phrasing feels awkward at times. Of course, that's a non issue for this kind of technical material, it's very understandable and useful! You can also view the source of this material here: https://github.com/StefanSalewski/NimProgrammingBook https://github.com/StefanSalewski/NimProgrammingBook For folks that are more experienced and learn by doing, the two resources I would recommend are https://nim-by-example.github.io/ https://nim-by-example.github.io/ and https://xmonader.github.io/nimdays/ 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/ https://narimiran.github.io/nim-basics/ https://scripter.co/notes/nim https://scripter.co/notes/nim The official Nim tutorial: https://nim-lang.org/docs/tut1.html 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_language/ 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).
- dom96 5y ago> Nim in Action (book) Free chapters and some other resources available here: https://book.picheta.me/ https://book.picheta.me/ :)
- jasfi 5y agoI'm writing a cross-platform UI toolkit: https://nexusdev.tools/ https://nexusdev.tools/ 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.
- squarefoot 5y agoCheck also the guy's homepage as he's working on some interesting software and hardware projects. https://ssalewski.de/ https://ssalewski.de/ edit: He also wrote a GTK4 programming guide with Nim examples, which was already submitted here in 2020. https://ssalewski.de/gtkprogramming.html https://ssalewski.de/gtkprogramming.html Strangely, neither of those books is linked on his homepage.
- blondin 5y agonot sure if the author is reading, but i would love to buy a paper copy of this book :)
- nooorofe 5y agoI have mixed feeling about Nim. I've tried to learn it few years ago. It was "sold" like a Python replacement, it looks like a Python a bit, but when you write code it feels nothing like python at all. 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).
- zinclozenge 5y agoNim never looked even close to Python for me, no matter how hard I squinted.
- cb321 5y agoI think most confusions come from how divisive significant white space can be and Python being the most popular among that class of surface syntaxes. I am aware (and maybe you are, too) that there is a long list besides Nim: https://en.wikipedia.org/wiki/Off-side_rule https://en.wikipedia.org/wiki/Off-side_rule, but this does not seem to be very common knowledge.
- uncomputation 5y agoWow, this clearly took a lot of work and time. Great to see someone putting in that level of effort and teaching people nonetheless!
- brudgers 5y agoThis is not bad: 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.
- chaxor 5y agoThis is really fantastic. Nim is a beautiful language for getting very performance code easily. Also, there's some really nice projects that use Nim out there - I believe nitter.com and teddit.com use Nim, which are much better than using the original websites if you're not super keen on huge scripts dependencies and everything you do being tracked.
- amyjess 5y agoNim just looks like a dream language to me. It's a fusion of Python and Modula-3 with incredibly expressive macro support (almost as capable as Lisp!) and nifty features like UFCS. 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.
- ajusa 5y agohttps://github.com/yglukhov/nimpy https://github.com/yglukhov/nimpy gives very, very solid access to the Python ecosystem from Nim - I've copied code from Python docs and have had it work with hardly any changes. Hopefully that's a good enough excuse to try Nim out for a personal project!
- nyanpasu64 5y agoI think Nim compiles to native code, is orders of magnitude faster than Python without NumPy, and has no GIL unlike Python with NumPy. I'd check out Nim for a project that doesn't require real-time processing without GC (and for real-time audio processing, Nim may be an option but I haven't explored it yet: https://forum.nim-lang.org/t/8613 https://forum.nim-lang.org/t/8613).
- elcritch 5y agoIt's funny you linked to my random post. I should probably follow up on that as it'd be a nice way to ensure you're not allocating on hot-paths. It'd be for audio processing and such! 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. ;)
- bckr 5y ago
- sdmac99 5y agoI really need to thoroughly read this. I have scanned sections like the one on References and Pointers and found them useful, but only scratched the surface. 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.
- chillerman12 5y agoThe new dydx competitor builds there central order book in nim: https://twitter.com/jae_tacen/status/1497242050185498630 https://twitter.com/jae_tacen/status/1497242050185498630 tacen.com
- zanellia 5y agoPretty cool. Would love to use Nim for scientific computing, but I am not sure how mature are, e.g., Neo (https://github.com/andreaferretti/neo https://github.com/andreaferretti/neo) and alike. Any positive feedback?
- auxym 5y agoIt's definitely not at the level of numpy/scipy, probably not even Julia, but there's an active community developing Nim for scientific applications at https://github.com/scinim https://github.com/scinim
- ChrisRackauckas 5y agoWith the last update to repos in the org being 4 hours ago most no more than 5 contributors, that's about an order of magnitude less developers and development activity than just one Julia org (SciML) out of hundreds of orgs. For comparison, see https://github.com/SciML/ https://github.com/SciML/ which saw 15 repos with changes by more than 15 developers in that time span. So by numbers, definitely not even close to the activity of just one part of Julia.
- eigenspace 5y ago> With the last update to repos in the org being 4 hours ago 4 hours ago? It says 4 days for me.
- ChrisRackauckas 5y agoYeah that's a typo. 4 days ago. It's just so insane for me to see no changes to any repo in an org for 4 days that I guess my hands auto-completed the sentence to hours haha, sorry.
- V1ndaar 5y agoAs one of the main contributors to SciNim, let me tell you that we're painfully aware of the size of our community. 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 https://matrix.to/#/#nim-science:envs.net [1]: https://discord.gg/f5hA9UK3dY https://discord.gg/f5hA9UK3dY [2]: https://github.com/yglukhov/nimpy/ https://github.com/yglukhov/nimpy/ [3]: https://github.com/clonkk/nimjl https://github.com/clonkk/nimjl [4]: https://github.com/clonkk/nimjl https://github.com/clonkk/nimjl
- ZoomZoomZoom 5y agoThe book has a GitHub repo, but the author unfortunately hasn't decided on licensing yet and doesn't accept contributions. At least there's a place to suggest corrections and possibly have a discussion with the author. https://github.com/StefanSalewski/NimProgrammingBook https://github.com/StefanSalewski/NimProgrammingBook