Hacker News new | ask | show | jobs
by bluejekyll 3397 days ago
Right. The only thing C had going for it was that it was the fastest non-assembly language.

I'm biased, I want all C development halted and moved over to Rust. If C is no longer the fastest, for some definition of that, then no one should be defending it at this point.

Honestly, I want the LLVM optimized C version specifically so that this last argument for C in any context will be taken off the table. I'm sure there are some people saying, "but it's not using the same compiler backend and optimizer...", I want this to counter that.

Rust all the things.

3 comments

>Right. The only thing C had going for it was that it was the fastest non-assembly language.

Not really. C has lots of existing code, lots of developers who know it, and for many platforms it is the only language for which you'll find a compiler. As a language it is a trainwreck, but it does have a sizeable moat.

Yes. And I recently did an experiment at work using corrode on some existing software, with some decent results. I was able to easily translate one source file to Rust, and then link that into the existing make based build.

I've also experimented with just FFI for similar integration, with similar ease.

The point is, even with large code bases in C, you can start to migrate and stop feeding the beast.

I am asking this genuinely, I always thought and heard LLVM optimizer is inferior to GCC's. Am I wrong ? is there any scientific benchmark for this ?
It's really hard to quantify enormous (millions-of-lines) complex pieces of code that simply. LLVM and GCC take broadly the same approach to optimization: an SSA-based IR with dozens of passes, followed by lowering to a machine-specific IR with many more passes, followed by machine code generation, register allocation, and cleanup optimizations.

Basically, all you can really say is: LLVM is better at some code; GCC is better at other code. The differences are at the level of highly situational details at this point, not broad strokes.

My understanding was that GCC was better in more scenarios most of the time, but now it seems like Clang has caught up. and Maybe Clang 4.0 is even faster in more.

Here are some recent benchmarks from phoronix: http://www.phoronix.com/scan.php?page=article&item=gcc7-clan...

Yeah. But in this kind of tuned benchmark, I doubt clang will do any better across the board - especially not considering the fact that the current programs are likely to be at least somewhat tuned specifically for gcc.
Clang does well enough to be the default compiler for Apple and Google. It can't be that far behind.
Oh yeah, I have no reason to believe it's worse; it's just that I also doubt it's going to help much either.

But... trial and error and all ;-).

I think they make different choices in different situations. My understanding has been that they are generally the same, with one doing much better in different situations.

But I have nothing to back this up. Wouldn't it be cool if the benchmark game provided a datapoint on this?

"If you're interested in something not shown on the benchmarks game website then please take the program source code and the measurement scripts and publish your own measurements."

http://benchmarksgame.alioth.debian.org/play.html#languagex

> The only thing C had going for it was that it was the fastest non-assembly language.

Which only happened after the widespread of UNIX clones into the industry.

Back in the 80's and early 90's, the C compilers for 8 and 16 bit home computers generated pretty crappy code, versus what humans were able to write in Assembly.