News for hackers. Stuff that matters.
Re:Nim (formerly Nimrod) 0.10.2 released by qznc on Monday December 29, 2014 @07:49AM (#8809527)
There is no technical reason why Rust should be slower than Nim, as far as I know.
Re:Nim (formerly Nimrod) 0.10.2 released by def- on Monday December 29, 2014 @07:56AM (#8809544)
Nim has the advantage of compiling to/through C, for which compilers have been optimized for a long time.
Re:Nim (formerly Nimrod) 0.10.2 released by pcwalton on Monday December 29, 2014 @10:43AM (#8810195)
That isn't an advantage, IMHO. rustc generates LLVM IR, which allows it to take advantage of essentially all the same optimization passes that clang does. Generating LLVM IR instead of C has some advantages—debug information can be made more precise, precise aliasing metadata for optimization can be added to the output, accurate garbage collection is possible, there's no need to go through the C parser and semantic analyzer, etc.

Examples of features that rustc uses today for optimization beyond those available in C are the "nonnull" and "dereferenceable" attributes (along with some custom optimization passes to make non-null pointer optimizations stronger than what LLVM provides out of the box). An example of a feature beyond C that it could use, but does not today, is custom type-based alias analysis.

Re:Nim (formerly Nimrod) 0.10.2 released by def- on Monday December 29, 2014 @01:39PM (#8811088)
I'm currently working with the Xeon Phi and there you basically have to use Intel's C, C++ or Fortran compiler if you want good performance out of the box. Since Nim compiles to C I can write code that gets auto-vectorized and -optimized by the Intel compiler.
Re:Nim (formerly Nimrod) 0.10.2 released by dom96 on Monday December 29, 2014 @10:53AM (#8810234)
Perhaps it's not an advantage, but it certainly is not a disadvantage. An advantage that I can think of is portability as well as easier interfacing with C libraries.
Re:Nim (formerly Nimrod) 0.10.2 released by pcwalton on Monday December 29, 2014 @10:59AM (#8810259)
Almost all systems that matter have an LLVM port these days, so portability isn't really an issue in practice (though sometimes C can help with microcontrollers, etc.) Game consoles in particular are all x86 or PPC these days. Easier interfacing with C libraries is a fair point, although you still have to figure out how the two languages' type systems interact and presenting good error messages can be a pain if you're relying on the C compiler to do semantic analysis.
Re:Nim (formerly Nimrod) 0.10.2 released by eonil on Monday December 29, 2014 @01:22PM (#8811005)
I disagree to optimisation, but agree to portability. It's difference of 100% and 99%, but sometimes the 1% can be significant. And of course, it also can be insignificant.
Re:Nim (formerly Nimrod) 0.10.2 released by simias on Monday December 29, 2014 @08:15AM (#8809615)
Rust uses LLVM as a backend so it gets similar optimization passes as clang for instance, so it's not so different. Basically rustc generates LLVM IR where Nim generates C, apparently. In most of the benchmarks I've seen so far you could expect similar performances between C and Rust.

Not to start a language flamewar but I'd like to see hard numbers before I believe that in the general case Nim is faster than Rust.

Re:Nim (formerly Nimrod) 0.10.2 released by dom96 on Monday December 29, 2014 @08:21AM (#8809630)
Re:Nim (formerly Nimrod) 0.10.2 released by simias on Monday December 29, 2014 @10:03AM (#8810016)
I have not, I mostly glanced at http://benchmarksgame.alioth.debian.org/ where Rust generally matches C performance whithin a few %. But Nim is not part of this benchmark apparently.

I haven't looked at your link in details but the fact that one C++ implementation manages to outperform all the others (including other C and C++ implementations and of course Rust and Nim) by more than one order of magnitude leaves me perplex. It means there must be a huge room for improvement in a lot of those tests. Also the timing code is implemented in the tests themselves using each language's primitives which seems a bit risky to me when comparing language performances.

Also the unsafe rust version has exactly the same performance as the safe one which is weird. After looking at the unsafe version it appears that all the unsafe blocks are just here to remove the bound checks on the vector indexing and that's it. That seems like a weird choice for optimization, I'd have tried to make the recursive function iterative first, for instance. At least it goes to show that that particular check is not too expensive and it's better to stick to safe code when possible.

Re:Nim (formerly Nimrod) 0.10.2 released by perturbation on Monday December 29, 2014 @10:22AM (#8810093)
>...one C++ implementation manages to outperform all the others ... by more than one order of magnitude

As does the cached Javascript version. All of the implementations in the path benchmarking by fiat use a naiive algorithm (recompute the cost for each recursive traversal). The C++ and Javascript cached versions are supposed to show that algorithm choice is much more important than language choice (and do some memoization of the cost calculation).

https://github.com/logicchains/LPATHBench/blob/master/jscach...

Re:Nim (formerly Nimrod) 0.10.2 released by idlewan on Monday December 29, 2014 @10:23AM (#8810107)
> he fact that one C++ implementation manages to outperform all the others (including other C and C++ implementations and of course Rust and Nim) by more than one order of magnitude leaves me perplex.

This uses a "pruning" algorithm and is a different algorithm than all the other implementations use. It shouldn't be used to compare the different languages, as it's just not doing the same work.

Re:Nim (formerly Nimrod) 0.10.2 released by jgallag8 on Monday December 29, 2014 @08:15AM (#8809611)
Rust uses LLVM, I believe, and LLVM does as good a job optimizing as just about anything else out there.