Live data from Hacker News

Which programming language or compiler is faster

programming-language-benchmarks.vercel.app

41–50 of 90 posts

Re: Which programming language or compiler is faster

#42

Can anyone explain why C++ beats out C so clearly?

C++ is just a stricter C - if you write proper C, it will be a correct C++ program, therefore it would run at the same speed. There's no way C can be other than marginally faster than C++ - if you write C and compile it with a C++ compiler. Then you have various optimizations that come from things like templates, constexpr. Look at the qsort method - to have a modicum of genericity you need to pass a function that wi…

> There's no way C can be other than marginally faster than C++

In theory `restrict` (to disallow pointer aliasing like in Fortran) could lead to optimization gains, same as not having exceptions (the possibility of exceptions prohibits certain optimizations of the C++ compiler).

Re: Which programming language or compiler is faster

#43

Earlier quoted context omitted.

Do you have an example for minutes of compile time for a single line? Especially since 1.6 (march 2021), I haven't run into that (and I'm using Julia pretty much full-time).

So the compile times gotten better, but still are quite slow in comparison?

In comparison to what? I've found that it's very responsive in a repl/notebook for interactive work (especially with Revise). It's not good for running short scripts, but if you have something that's doing some real work, the compilation often isn't a big deal.

Re: Which programming language or compiler is faster

#44

I wonder where FPC stands. Original Pascal implementations were single pass and I've had Mloc delphi projects build in seconds.

I came here to ask the same. Pascal files are laid out in such a manner that the "implementation" section of the file is ready for compilation to bytes and any forward references just mean that it's code ends up later in the exe. Typical runtime speed has only ever been fractionally slower than c/c++.

Re: Which programming language or compiler is faster

#45

Julia always seems to rank #1 or close to it when compared to other interpreted languages but I only ever see it used for research and math. Why doesn’t anyone use it for anything else?

These are what i'd say, as someone who has tinkered with it a lot but uses python/C++ for $day_job:

- immature web/network services stack. For better or worse the lang seemed to focus on more number crunching throughput early than reliable distributed data processing, but the latter is a much larger market and what most enterprises care about.

It's the difference between a lang only having Matlab or R ceiling vs python-like ceiling.

- poor static compilation or static analysis story. this is what a lot of people needing to put code in production need.

It's also standard expectation now with a lot of dynamic language code (python or js) that aims to be in production.

- for certain types of realtime uses, more direct control of memory is doable, but you have to jump through hoops. Again, determinism is very important.

- historically, compile times were quite horrid. part of this was llvm, part of it was julia. It's gotten way better in 1.6 and 1.7, but compilation results need to be cached more than just precompilation.

however, all being said, I love the lang! There is a lot going for it especially how the package ecosystem works. There is also a lot of innovative projects.

Re: Which programming language or compiler is faster

#47

Earlier quoted context omitted.

Do you have an example for minutes of compile time for a single line? Especially since 1.6 (march 2021), I haven't run into that (and I'm using Julia pretty much full-time).

So the compile times gotten better, but still are quite slow in comparison?

Personally, I think interactive usage has improved quite a bit. I don't "feel" it that badly in 1.7. It was bad enough earlier in the 1.0 series that I stopped using it for a while (I used it before I think the problems were from:

1) llvm itself getting dramatically slower over time, before more focus upstream on compiler speed more recently: https://www.npopov.com/2020/05/10/Make-LLVM-fast-again.html

2) different types of invalidations

3) less than ideal precompilation of packages

I think all of it has been improved, and can certainly be improved further. That also includes improving the speed of its interpreter (vs the JIT), which exists but was never optimized for speed afaik.

Re: Which programming language or compiler is faster

#48

What matters to me is incremental build time. Rarely do I compule a big program in its entirety from scratch. I don't use Unison but I would love to for this reason.

unison cheats at this by being interpreted, if it weren’t it would have the same build times as everyone else (I suppose caching would be better in some cases, but i’m not sure if they’d be much better than what you get with nix?)

Re: Which programming language or compiler is faster

#49

What does it even mean for a language to be faster?

Not sure how technically accurate it is, but "language" usually implies more than just the syntax. I hear and say things like "compiled language", "interpreted language", "language VM", "garbage collected language", "dynamically typed language" and so on. Those things all say something about development speed and runtime speed.

Re: Which programming language or compiler is faster

#50

Earlier quoted context omitted.

C++ is just a stricter C - if you write proper C, it will be a correct C++ program, therefore it would run at the same speed. There's no way C can be other than marginally faster than C++ - if you write C and compile it with a C++ compiler. Then you have various optimizations that come from things like templates, constexpr. Look at the qsort method - to have a modicum of genericity you need to pass a function that wi…

> There's no way C can be other than marginally faster than C++ In theory `restrict` (to disallow pointer aliasing like in Fortran) could lead to optimization gains, same as not having exceptions (the possibility of exceptions prohibits certain optimizations of the C++ compiler).

I agree; of course, both clang and gcc extend C++ with __restrict__ if I remember correctly; from what I know, there are more things that can be done in C++ to improve over C than the other way around.
Post reply on HN