Nim; The Multi-Platform Compiled Systems Lang
2021-06-08 at 3:41 PM UTCI just learned about this language and it's the best thing since sliced bread. It supports every mainstream OS and even some platforms beyond that. The language itself is intuitive, whether you come from a C, Python or NodeJS background. Over the last few years i have devoted a lot of my time into getting more proficient at C and Node, and of course i have continued working on my Python skills. The combination of which sets me up in a great way to start seriously getting into Nim.
I am very glad i put in the time and effort to do so with regards to the other langs i mentioned, and i will of course continue to strive for excellence when it comes to those. As you know i aspire to be a full stack dev in the sense that i want to be able to proficiently code in most modern programming languages. I've come pretty far in my humble opinion, but there is much yet to learn, very much in fact, and i will of course endeavor to continue to improve, to the point of having a high degree of expertise in software/security engineering and Systems Architecture. Basically expert level DevSecOps.
Anyway that was a bit of a tangent. I think for every day use i'll start making the switch to Nim, from Python.
Nim combines the best of Python, Rust, Modula, Ada, and has a package manager that works much like NPM for NodeJS. Which is why i mentioned those langs in the beginning of the thread. As opposed to Python it's a compiled language however. But it takes a lot of cool stuff from python and makes it better. The syntax is relatively similar.
Interestingly it's kind of like a meta language. A JS backend is provided for client and server targeting. It wraps C,C++, and Objective C, allowing it to make use of libraries native to those langs, vastly increasing it's capabilities. And it comes with a small core that is easily extendable.
A Nim core program looks like this:
import macros, strutils
macro toEnum(words: static[string]): untyped =
result = newTree(nnkEnumTy, newEmptyNode())
for w in splitWhitespace(words):
Color = toEnum"Red Green Blue Indigo"
var color = Indigo
Very similar to Python as you can see. A Nimble package looks like this:
version = "v0.1.0"
author = "Benedict Cumberbatch"
description = "Sample package."
license = "MIT"
requires "nim >= 0.13.0", "jester >= 0.1.0"
task test, "Run the tester!":
exec "nim c -r tester"
And operates a lot like a Node package would.
Now since i just came across this language i am probably missing a bunch. But so far it looks pretty good to me. If you're interested checkout the official site here https://nim-lang.org/
2021-06-09 at 9:21 AM UTCCheck this out. The Nimble package manager has packages for just about anything you'd wish to write, below are just some examples that i installed in preparation for starting to work with Nim. Some crypto, networking, low level stuff and a package for writing a GUI.
The Nim Core Cli, also comes with options to start a project in a directory. You can pick a base template with a dependency package/compiler script. Say you wish to create a GUI application, you pass the appropriate flags to the Nim CLI and it will generate a build script complete with entries for the various dependencies. The Dep Package allows for easy installation of the deps in question as well.
The compiler itself is feature rich too, and allows you to select a support backend, in order to compile Nim to C, C++, JS(And more) and various binary types. Pre-processing output can be derived as well. And i think you can even work with Asm and the Assembler itself.
Like i said in the OP i am just getting into the lang so it may be a bitmore nuanced/complicated than the way i have portrayed it here. But i am pretty sure most of what i just mentioned is correct.
Nim is awesome.
2021-06-13 at 8:48 PM UTCI worked with someone that was big into nim, looked into it a little but have yet to write anything in it. To be honest, from a PLT or ergonomics standpoint it seems pretty boring, middle of the road on everything, nothing unique or even really uncommon. It lacks a "headline" feature like e.g. Rust's "zero cost abstractions"/borrow checker, lisp macros, haskell's type system etc.
But from talking to people who are into nim, I think that's supposed to be its appeal. Like Python is kind of in the same place these days, not exciting, but also predictable and pretty expressive so it's a reliable workhorse language. Nim sorta seems like python but compiled and with a one true package management solution.
Which oddly is kind of a very ambitious project, because the goal seems to compete with incumbents rather than carve out a niche. I could see nim doing well, as evidenced by things like pypy there's a demand for "python but faster" so maybe it could work.
2021-06-14 at 9:45 AM UTCAbsolutely. One of the things i like about it as well is that i can compile a Nim program to DLL for Windows or Shared library for *Nix something you can't do with Python. I use Python for a lot, since it is a generalist language, or workhorse language as you put it. In that regard Nim is similar but better.
I intend to switch from Python for all the things to Nim for all the things, unless a certain project warrants the use of Python specifically of course. As far as an everyday languages go, expressive, predictable and reliable is what i like in that
Oh and i do think Nim has a Macro system i am not that familiar with lisp, or lisp macros to say whether the two are similar in that regard though. Are you familiar with GPC? It's a language used in game console hacking, Nim Macros work kind of like GPC macros from what i have seen so far.