Live data from Hacker News

Choosing Nim out of a crowded market for systems programming languages

forum.nim-lang.org

221–230 of 271 posts

Re: Choosing Nim out of a crowded market for systems programming languages

#221
I recently started using nim for some little side projects and I am having so much fun. Somehow they’ve managed to combine the strengths of high level languages such as python with those of low level, systems languages like C with few (if any) of the drawbacks. It’s pretty amazing to be honest.

Programming in nim feels a lot like programming in a statically typed Python, except that you get small, fast, single file executables out of the box.

Compared to C++ you don’t need to worry about memory allocations too much except when you really want to, and when you do it is much simpler than in C or C++. It is also much easier to control mutability and the type system is much better. Also you can use most of the language at compile time in a much more elegant way than in modern C++.

Another surprising thing is that while the ecosystem is obviously much smaller than on more popular languages, the fact that it has a built-in package manager gives you access to it much more easily than in C++. There are a lot of high quality packages (such as datamancer, arraymancer and ggplotnim) which makes nim very productive in a lot of domains.

That’s not even including advanced things such as nim’s excellent macro system which I personally don’t use (but which enable some of the best nim libraries).

Oh, and I _love_ nim’s uniform function call syntax. Every other language should copy that feature.

I almost forgot to list the drawbacks. The main one of course is that it is not the most popular language (but the ecosystem is big enough that I didn’t find it is a big problem for my use case in practice). Other than that the editing and debugging experience could be improved. There is a decent VS Code plug-in (look for the one made by “saem”) but it is just OK, not great. There is some integration with gdb but it is a bit rough. I usually end up adding logs when I need to debug something.

Re: Choosing Nim out of a crowded market for systems programming languages

#222

What’s the LSP and linter/formatter story these days? Last time I tried it the lsp was miles behind what I am used to from TypeScript land in vscode. I have gotten sooo used to all the auto completion, helpful error tooltips and auto imports and formatting on save that it felt tedious not to have that in a similar capacity. Maybe I was just doing things wrong and it’s been a while. In general I am super intrigued by…

Its ok. A developer was recently hired to work on it full time though!

On it or with it?

Re: Choosing Nim out of a crowded market for systems programming languages

#223
post #46

The best language to learn and use right now for systems programming is C/C++. It is by far the most marketable skill with 99.999999% of all low level systems written in C or C++. Large scale systems used by companies that pay top salaries for developers (Google/Meta) are written in C++. There is more material out there for learning and mastering these languages than any other language save maybe Python or JavaScript…

The Rust community is however, an excellent community to be part of. And it's future proof. Everyone knows Rust is the future. I'd say, for most college students, Rust would be the one you'd advise today.

College students learning mostly Rust -- that would be a blessing. We would get rid of the typical "every noun is a class" type of thinking that students tend to have going through a Javaducation. We would get them to see the correspondence with structs, procedures and traits and we would get them more often to reach for the simpler solution that way.

Re: Choosing Nim out of a crowded market for systems programming languages

#224
post #34

Earlier quoted context omitted.

I'm learning Rust now, I can say Nim is much harder. Maybe the language itself is simpler, but the documentation is just not very good. Very unpolished and amateurish. I actually forked out fifty quid for Araq's "Mastering Nim" book; it is atrocious. Spelling and grammatical errors on every page. The very first code example did not compile. I also regularly run into utterly infuriating bugs while trying to accomplish…

Did we read the same book? I find Mastering Nim a pretty excellent reference. (And you have to install the pixels library :-P) The online documentation, certainly, could be better. I sometimes find standard library documentation lacking in examples, and compiler documentation is currently undergoing a massive refactoring effort on a couple of fronts. But the manual ( https://nim-lang.github.io/Nim/manual.html ) isn't…

>(And you have to install the pixels library :-P)

I knew someone would say this: it doesn't tell you that, does it? It's supposed to be an introductory reference work, so surely "how to install the 3rd party package required by our hello world example" should be included?

And anyway, even after I installed pixels the code still didn't run right.

I honestly found it insulting that such an expensive book would have such obvious oversights. It's like nobody proofread it at all.

Re: Choosing Nim out of a crowded market for systems programming languages

#225

Earlier quoted context omitted.

I had one experience with Go. It was slow because the GC kept kicking in. So we won’t use Go again in favor of time-tested C++. GC is a major reason we are using C++ over Go. In my mind it’s a half-speed language. I’m also very put off by Rob Pike’s “Look, we replaced C++!” attitude when he somehow doesn’t seem to grok zero-cost abstractions. C++ has plenty of issues, but it doesn’t have GC and it goes further, provi…

Rob pike said they intended to replace c++, that didn't happen to his own accord.

Right. It seems like they set out to replace some misunderstood or outdated view of C++. They’ve clearly had success, but it’s no C++ successor.

Re: Choosing Nim out of a crowded market for systems programming languages

#226

Earlier quoted context omitted.

What's wrong with C++ stability? You think things are looking better in JS/Python world? They both changed tons and the knowledge you accumulate constantly needs to be tweaked and relearned.

> You think things are looking better in JS/Python world? Yes.

[deleted]

Re: Choosing Nim out of a crowded market for systems programming languages

#227

Earlier quoted context omitted.

It's not even the right category of criticism. The author talks about 'mathematical purity' which is something Rust sneers at. Spend just a little while with Rust and you can see that when the language is getting in your way, the driving direction it is pushing you in is towards code that will be maintainable . Which is still not about getting shit done, and is still a valid axis to prefer Go's rapid development cycl…

I kinda agree, it's weird to me how people make a big deal about the borrow checker as if it's an evil spirit gatekeeping your code. And if you wanna go fast instead of writing maintainable code you surely can with stuff like unwrap(), clone(), Copy. In a way I think most people expect to pick up Rust more easily because they have expertise in other languages and are surprised when Rust feels like learning to code ag…

>And if you wanna go fast instead of writing maintainable code you surely can with stuff like unwrap(), clone(), Copy.

That's a good approach to learning the language, but it breaks down as soon as async comes into the picture. It's basically impossible to be fluent writing async rust without a very healthy understanding of complex types, how the borrow checker works passing things across closures, etc.

Re: Choosing Nim out of a crowded market for systems programming languages

#228
post #165

Earlier quoted context omitted.

> Also does every criticism of Rust have to have a prominent rebuttal? Ha, sorry - I just really love Rust and want others to at least try it. I passed on it for _years_ because I thought like the OP (I used to code in Scala - I personally find THAT takes cognitive load to remember all the features. Rust feels small to me in comparison). Rust made me LOVE to code again and I just think there must be others out there…

Maybe you should try a language where people get a lot of work done in the day to day ? E.g: Python, Go... It seems crazy to me someone who code in Scala, now loves Rust. Brains are really something else :)

I've written extensively in about 10 languages including the two you mentioned.

The current project I'm writing is migrating from Python to Rust. Python is not appropriate for large projects IMO and this one I wrote and am now porting to Rust is no exception. I do love Python for things up to 1000 lines or so, but after that you really need to test every single line, which is just a PITA. Mypy and now others help, but the typing isn't strong enough (although I've heard good things about some newer static typing addons).

I have a love/hate relationship with Go, but after I found Rust I'll never touch it again. It simply isn't expressive enough which leads to code that is overly verbose. The lack of a decent enum, repeating nil pointer mistake, verbose and error prone error handling, the constant copy/paste (now semi fixed with generics). I do love that it strives to be a simple language, but strangely the Rust tooling is much easier to use, so I'm not convinced it hits the mark. I do love how fast it compiles, and that is the one thing I hate about Rust.

Re: Choosing Nim out of a crowded market for systems programming languages

#229
post #111

Earlier quoted context omitted.

Thanks for sharing your experience. OP in particular seems like someone who is familiar with a variety of languages, hence my comment. In addition, given that their requirements lined up with what Rust is good at, the time investment would be worth it. When it comes to learning Rust in general, I think the difficulty and amount of time required depends on one’s background and overall learning style. If you are the ty…

Your response seemed to fall into a category common amongst Rust enthusiasts, which is to assume anyone resistant to the lure is ipso facto lazy or misguided. Your own question was a hint at laziness. I have no idea how much effort the writer put into evaluating Rust. I doubt you do either. I don't know why some of us find Rust difficult. Perhaps it just is, or isn't, or is for some people and not for others, or perh…

Nowhere did I say or even imply that people are “lazy or misguided” for not learning Rust.

Re: Choosing Nim out of a crowded market for systems programming languages

#230
post #111

Earlier quoted context omitted.

Thanks for sharing your experience. OP in particular seems like someone who is familiar with a variety of languages, hence my comment. In addition, given that their requirements lined up with what Rust is good at, the time investment would be worth it. When it comes to learning Rust in general, I think the difficulty and amount of time required depends on one’s background and overall learning style. If you are the ty…

> given that their requirements lined up with what Rust is good at I would say the opposite. OP stress on the C/C++ interoperability. In rust, you need to either (1) wrap the API in something Rust-like / Borrowchecker-friendly - which need lots of planning ; or (2) Do it with lots of unsafe code - which make the memory safety lots more complicated to reason about For memory safety, you can get it from any GC language…

(1) is a one-time investment and allows you to take advantage of compiler guarantees. (2) is what every other language does for FFI anyways. In Rust, you could have a lightweight wrapper around the C API, but you would lose out on some benefits.

OP said performance was critical, so why would they use a GC language?

Post reply on HN