Live data from Hacker News

A Quick Comparison of Nim vs. Rust

arthurtw.github.io

61–70 of 94 posts

Re: A Quick Comparison of Nim vs. Rust

#61
post #35

Earlier quoted context omitted.

On the other hand, it's quite convenient if you can't remember the exact name and it saves you a look-up e.g. quick_sort vs quicksort vs quickSort - either work

That means that all three forms will wind up in any Nim project that gets large enough, though. Hardly a good thing.

If they all work, does it even make a difference? Besides it would be trivial to write a refactoring tool that can autoreplace all instances with the preferred form.

Re: A Quick Comparison of Nim vs. Rust

#63
post #54

Earlier quoted context omitted.

That's partially outdated for Rust, but I guess Rust is too much of a moving target. For example `from_str:: ` should be `.parse()` today.

The code samples are from the RosettaCode[1]. They are probably lacking a frequent contributor for making and fixing Rust code examples. [1]: http://rosettacode.org/wiki/Rosetta_Code

There's a repository where Rust versions are being worked on: https://github.com/Hoverbear/rust-rosetta

Re: A Quick Comparison of Nim vs. Rust

#64

I really wouldn't consider it reasonable comparison, when one language has a sufficient compiler that is written in itself for most part, and the other still only compiles to C.

Go's compiler was entirely C until just recently... What does it matter? It's hard to write a compiler in a language that doesn't exist yet, and one you have the language, why bother with a rewrite?

Re: A Quick Comparison of Nim vs. Rust

#65
post #9

Earlier quoted context omitted.

Oh, my bad. The numbers differ a lot (2~2.5x faster). I’ve updated the article.

Now it's more in line with my experience of Nim usually being quite a bit faster than Rust, not to mention much easier to write and less verbose (text munging code in Rust seemed to be about 15% calls to as_slice() and to_string ()).

The as_slice situation was acknowledged to be deplorable, and is being vastly improved in the runup to 1.0.

As for speed, please file a performance bug! We love to know where we're missing out on optimizations.

https://github.com/rust-lang/rust/issues

Re: A Quick Comparison of Nim vs. Rust

#66
post #60
post #27

It's feels like a shame to me that the one Python maxim that Nim has chosen to reject is "there should be one and preferably only one way to do it" - from this flows so much of the other goodness of the Python ecosystem. I worry that some of the metaprogramming magic that Nim allows will result in the loss of that feeling that I can view source on almost any 3rd party Python code and immediately feel like I can follo…

> "there should be one and preferably only one way to do it" In my very humble opinion this idiom is amazing at the start of a language and then it handcuffs it and that is why we have Python 2 or Python 3 issues. I use to use Python for statistical work and about 2 years ago I switched to R. R is VERY flexible and seen a huge change over the last 5 or so years. It has changed for me especially in the last 6 months w…

When you write code that's intended to be maintained for years, a degree of resistance to shifting language idioms should be considered a feature. That's not to say that Python itself is the greatest language for long-term maintainability, but I personally have both years-old Python code and years-old R code, and any thoughts of doing maintenance on the latter fills me with trepidation.

But when it comes to short-term, one-off, or unimportant tasks, I agree that an emphasis on flexibility is welcome. There's a reason that TIMTOWTDI works so well for Perl in its original role as a shell scripting language.

Re: A Quick Comparison of Nim vs. Rust

#67

Earlier quoted context omitted.

That means that all three forms will wind up in any Nim project that gets large enough, though. Hardly a good thing.

If they all work, does it even make a difference? Besides it would be trivial to write a refactoring tool that can autoreplace all instances with the preferred form.

Well, it's harder to grep, for one (although far from impossible).

Re: A Quick Comparison of Nim vs. Rust

#68
post #49
post #27

It's feels like a shame to me that the one Python maxim that Nim has chosen to reject is "there should be one and preferably only one way to do it" - from this flows so much of the other goodness of the Python ecosystem. I worry that some of the metaprogramming magic that Nim allows will result in the loss of that feeling that I can view source on almost any 3rd party Python code and immediately feel like I can follo…

It allows you to use your own style everywhere, instead of relying on the specific styles of the library you used (so you don't end up in your code with camelCase AND snake_case). It's definitely unusual, but I think it works quite well.

This makes a lot of sense, and makes me appreciate the choice more (although my gut feeling was that it was a good idea).

Re: A Quick Comparison of Nim vs. Rust

#69
post #13
post #7

I'm starting to really wish there was a GC-free (or at least) GC optional version of Nim. Nim with Rust's memory semantics would just be the best of everything.

I believe you can turn off the GC for Nim. Then you're just limited to libraries that don't rely on the GC, and fully manual memory management.

That isn't Rust's semantics though (as specified in the parent post): Rust's semantics are about ensuring safe manual memory management.

Re: A Quick Comparison of Nim vs. Rust

#70
The first benchmark is primarily a comparison of Nim's PEG package to Rust's libregex package. The two have very different algorithms, and libregex is optimized to avoid exponential blowup on pathological regexes. It's missing a fallback to the backtracking algorithm at present.

Using rust-pcre would probably mitigate this problem.

Post reply on HN