Hacker News new | ask | show | jobs
by warent 1649 days ago
I've vaguely heard of Nim in the past and for some reason always thought it was some limited scripting language. But this looks like a pretty serious candidate for a nice backend language.

I'm getting tired of how cumbersome Go is and have had my eye on Crystal. Anyone have any insight on how Nim stacks up to Crystal?

2 comments

I have written toy programs in Nim and Crystal, and the Nim experience is much more polished.

The Nim compiler is as fast as the Crystal compiler is slow!

I think Crystal is more enjoyable to use, personally. I am not a Ruby programmer, but Crystal just somehow feels fun to use. Nim by contrast feels very utilitarian, and frankly more practical.

I found the Nim language documentation better than Crystal, the Crystal standard library docs are just as good as Nim.

Nim overall feels like an "early 1.0-ish" language. Crystal feels like they went to 1.0 m too early. I would probably consider using Nim in a medium-sized application for work, whereas I wouldn't feel comfortable with Crystal for more than a personal hobby project.

They do have some things in common (macros, C interop, static types), but aren't really similar languages. I used to lump them together in my head as "those two new languages", but I don't anymore after trying them both.

If you are checking out new-ish languages, I hear Kotlin has some good design decisions that people appreciate (but that the tooling is pretty bad outside of Jetbrains IDEs).

There's Kotlin script if I recall correctly. But not that developed yet nor easy to use outside jetbrains ecosystem (IDEA).
In case you want a quick example of a backend application in Nim, I've written a small post[1] describing how to create a room based chat using it and HTMX. In total, it's around 70 lines of code (though it doesn't cover more advanced use cases, like username collision). I too have moved from Go to Nim, the syntax and ease in which I can turn a feature into code has been much better.

[1]: https://arhamjain.com/2021/11/22/nim-simple-chat.html