Quickie: #rakulang vs #nim vs #rust vs #cpplang

I basically consider myself a C++ programmer, having decided to “standardise” on it a few years ago. I am a fan of Python, too.

I tried Rust, but in the end couldn’t see the point. Rust’s big idea is immutability. I don’t think it’s a big win, because C++ has “const”, so by careful programming, you can get C++ to behave properly. I understand that Rust has some other nice features to it as well. But in the end, C++ is the standard compiler. The standardisation efforts on C++ from 2011 has really sorted out C++ a lot. C++ gets you halfway to Python. In fact, I think it gets you more than halfway.

I am not a Perl 5 programmer, but I used it to rewrite my accounting module. Perl 5 scores big when programs are simple, and need to run fast, and where sed and awk aren’t quite up to snuff.

So, having touched on Perl 5, I decided to give Perl 6 (aka Raku) a go, and rewrite my accounting module in it. There are certainly some nice touches to Raku, like being able to bind multiple variables to results. And, if things don’t quite work, it gives sensible results.

Raku really does have some nice touches. Another one is gather/take. This is really cool, because of instead of a loop only accumulating an element on each iteration, you can accumulate as many, or as few as you want.

As I had said in a previous post, Raku has a lot of “do what I mean” to it, and it has a certain way to it. I describe it as having the quality that the language “thinks like a programmer thinks”.

Having said that, the language is dead slow, some of the syntax still puzzles me, and it won’t work on 32-bit Windows. I haven’t used Windows for at least 6 months now, but it would be nice to know that I could use Raku on it if I wanted to.

Whilst messing around with Raku, I heard of Nim. Initially, I wasn’t interested, figuring it was just another of those goofy languages. Here we go again, I thought, someone’s arbitrarily cobbled together syntax that largely does what every other programming language else does. But I looked at a few videos, and I became intrigued.

I am in the process of translating my accounting program. The syntax is intuitive, and approaches the brevity of Raku. Again, it has some nice features. I don’t really approve of space indentation as a syntax idea, especially when spaces are mandated instead of tabs. It makes it a fiddle for me to edit.

Other than that, the syntax is quite intuitive.

Although I haven’t explored the possibilities yet, what I’m really interested in is the notion of “types”. It has sum types (aka ADTs, abstract data types, or “variants”), and, get this, you can have recursive types. Hallelujah! Basically, Haskell typeclasses. This is one thing that C++ really needs, I think. The variants are a real pain to work with in C++. Lacking recursive types, it is also difficult for C++ to express the notion of a tree, which I want for doing parsing work.

I’ve expressed the view in the past that the ideal language would be some kind of “C++ meets Haskell”. Nim seems to have that idea in mind.

Nim also has templates. Not so much C++ templates on steroids, but C++ templates without the mind-splitting migraine. I haven’t explored Nim’s templates yet, though. What also intrigues me is that Nim has macros, something that Raku doesn’t have. Well, I still think Raku is trying to work out how macros are supposed to work. I think they’re going to be a bit fiddly, whatever they decide.

Nim is also way faster than Raku, on account of it being compiled.

Another nice touch about Nim is the ability to crosscompile easily. Cool! Now I can develop on my x86_64 machine, and create an executable for my Raspberry Pi. Very nice.

So, yeah, Nim is definitely interesting, and something that I want to dive into deeper.

If I had to choose only one language in the world, it would still probably be C++. C++ is absolutely ubiquitous, it’s modernisation efforts have really improved it, and, well, it gets the job done. Nevertheless, I intend exploring Nime further.

Just my 2 cents.

About mcturra2000

Computer programmer living in Scotland.
This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to Quickie: #rakulang vs #nim vs #rust vs #cpplang

  1. Pingback: 2020.02 Important Things – Weekly Rakudo News

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s