4 ms·
> That's kind of expected right? I'm not sure. The following claim is being made on Nim's website: > Modern concepts like zero-overhead iterators and compile-
by capableweb 5y ago
> That's kind of expected right?
I'm not sure. The following claim is being made on Nim's website:
> Modern concepts like zero-overhead iterators and compile-time evaluation of user-defined functions, in combination with the preference of value-based datatypes allocated on the stack, lead to extremely performant code.
> Efficient, expressive, elegant
> Nim is a statically typed compiled systems programming language
A systems programming language need to have exceptionally good performance, so not sure it's to be expected that the performance is so different than Rust.
Apparently the Rust versions have received more optimization efforts compared to the Nim code as well, and it seems some people are working on optimizing the Nim versions so we'll see where it lands in the future I guess: https://news.ycombinator.com/item?id=30244188 https://news.ycombinator.com/item?id=30244188
- carlmr 5y ago>Apparently the Rust versions have received more optimization efforts compared to the Nim code as well Having programmed in both I think Rust often makes it easier to write fast code by making all the copying vs borrowing more explicit. Nim is obviously still very fast and much easier to pick up, so there are trade-offs here.
- gameswithgo 5y agoI've been programming for like 30 years and I've seen dozens of language show up claiming "C like performance" and so far Rust is the only one where that has been true.
- capableweb 5y agoIndeed, probably the most overused selling pitch for programming languages has to be "C like performance", while only providing evidence for a few smaller use cases. I've only dabbled with Rust enough to grok the ownership parts, but I'm happy to hear you feel it lives up to that. As an aside, I'm not expecting a lot of languages to live up to the "C like performance" claim when they make it, as C has been receiving optimizations for over 50 years by now, so it makes sense it's still the fastest around, at least until there is some major breakthrough in programming language design.
- wyldfire 5y agoBut Nim uses a C backend, right? So this should put it in a good position to compare well with C, I'd assume. EDIT: Downvoters - is that not the case?
- TheCoelacanth 5y agoNo. By that logic, all languages should have equivalent performance because they all ultimately turn into machine code. C isn't inherently fast, commonly used constructs in C just tend to match up well with semantics that can be turned into high-performance machine code. For a language that compiles to C to be fast, its commonly used constructs would need to have semantics that match up well with what can be turned into high-performance C, which is often not the case. There are many examples of languages that compile to C, but are still very slow.
- dahfizz 5y agoI would argue that C is inheritance fast. C puts the least amount of shit between the code and the CPU. There is no runtime, GC, expensive abstractions, etc. Your code more or less directly becomes machine code and is executed. Maybe a better way to frame it is that most other languages are inherently slow. Garabge collection will always be slower than non-GC. JIT and interpreted languages will always be slower than ahead-of-time compiled languages. etc etc.
- staticassertion 5y agoThe point is that C isn't inherently fast ie: by simple virtue of translating a program from one language to C you are not producing a faster program. x86 has the least amount of shit between the code and the cpu, but we can see that many programs that compile to x86 are not fast.
- dahfizz 5y agoThat is a fair point, and looking back I misread the context of the comment I replied to. You should not expect free performance gains from transpiling to C.
- ReleaseCandidat 5y agoYou should have heard of 'Fortran', the language that had C like performance before C even existed ;). But no, Fortran is not an alternative to C (und vice versa).
- gameswithgo 5y agoC has fortran like performance =)
- Rendello 5y agoZig as well.
- galangalalgol 5y agoI haven't seen a shootout like this with zig, is it comparable?
- Rendello 5y agoZig is as fast as C, occasionally faster.