= Nim day 1 = Ratfactor doesn't know his favorite language In my third ever phlog post[1], I made a passing remark or two in praise of the programming language 'Nim'. But what I didn't bother to mention was that I've already learned and forgotten it twice. How can I claim to like it so much when I keep forgetting it? I could make excuses a mile long, but the truth is, I haven't made a devoted effort to keep Nim loaded in my brain by actually _using_ it frequently. I woke this morning with my mind just buzzing with ideas for that AsciiDoc-to-Gopher-text formatter I've vaguely blathered on about before[2] *and* ideas for a Gopher client that would be like a cross between of Lynx (using ncurses) and VF-1 (keyboard-driven, etc.) - and I totally have a cool name for it and everything, "Vole!", so the hard part's done, you know? But I want to write both of those things in Nim. I can't very well do that if I can't actually remember the language, can I? Well, it's time to fix that ("and this time, once and for all," said Ratfactor with a big grin that exposed his sharp rodent teeth.) The journey so far I've been off-and-on obsessed with finding the "one true programming language" for at least 15 years now, learning and forgotten more languages than I'd like to admit. I've picked up all sorts of useful things along the way, but still the treasure I seek continues to alude me: a casual mastery of a language that is "pretty good at everything." For you see, I have learned at least one thing on my journey: there _is no_ "one true programming language." Mind you, I have fluent competence with the technologies I use for work. But that's for, like, making applications for the _suits_, you know? That's work for _the man_. That's the stuff that needs to be done yesterday and nobody cares how it was written. I want something I can love the way I've loved Scheme and Forth and OCaml. Why Nim? When I finally came around to deciding that I needed a "modern" compiled language under my belt, there were four big contenders who rose to the top: Rust, D, Go, and Nim (still called "Nimrod" at the time). Each of those languages is great in its own way, but Nim not only stuck out as having the right features (compiles to C, garbage collected (optional), interesting type system, package manager, etc.) but _also_ emphasizes clean, expressive programming. Let's take Rust and Nim for example: I did not find Rust particularly _fun_ to write. The syntax is heavy with sigils and brackets as if C++ had made sweet love to Perl. In order to guarantee memory safety without garbage collection, it requires you to manually track things like lifetimes of borrowed pointers. Mind you, I think Rust is an absolutely amazing language by amazing people with wonderful documentation and community. I would like to take another stab at working with it some day in the future. But writing Nim feels more like the Python whose syntax it most closely resembles. Only a master of C could write idiomatic C as fast as Nim can generate it for me while letting me concentrate on solving the problem at hand. Some additional features in no particular order: - statically typed (with inference) - iterators - macros - generics - first-class functions - operator overloading - foreign function interface (FFI) to use C libraries - many common C library bindings already available It supports all of the paradigms I'm most comfortable and productive using. It has a very clean syntax. It's fast. The only real downside to Nim is that the community is relatively small. Oh, and the significant whitespace (inspired by Python) is a deal-breaker for some folks. What's the plan? I learn best by writing. Specifically, when I write about what I'm learning as if _I_ already knew what I was talking about and was authoring a book for _other people_ who don't. It's a helpful lie and one that works even better when the outcome is a document that is genuinely useful to others. I do it all the time on my website[3]. Since this will be rough, I think I'll just write it as a phlog mini-series. Then, when I actually feel more confident with Nim, maybe I'll clean it up a bit and package it up as some sort of document. So join me for Nim Day 2, and let's learn Nim together! [1] gopher://sdf.org/0/users/ratfactor/phlog/2018-08-12-Weekend-Tech-Scramble [2] gopher://sdf.org/0/users/ratfactor/phlog/2018-08-15-Text-has-styles [3] http://ratfactor.com/slackware/pkgblog/ By the way, my "PkgBlog" (short for Slackware "Package Blog") in link [3] above is finally live and I'm currently writing the entry for the 'bash' package! I'll be mirroring here on Gopher as soon as I have an AsciiDoc-to-text formatter!