News for hackers. Stuff that matters.
Re:Ruby Outperforms C: Breaking the Catch-22 by josephg on Saturday September 09, 2023 @02:51AM (#37442880)
Why would the performance of these languages be identical? These languages aren’t the same in lots of ways.

Golang has a GC and gives you much less control over memory layout than any of the other languages you mentioned. It also has a very different concurrency model, which will vastly change the performance characteristics of multithreaded code.

Rust is limited to llvm, while C can be compiled with many other compilers - some of which produce better code in many cases. (Eg icc)

Rust has much better noalias analysis - which allows the compiler to make optimizations that aren’t available in general purpose C or C++ code. (Since nobody adds noalias to all their variables in C, for a variety of reasons).

Unlike the others, C doesn’t support monomorphization (without disgusting macro tricks). Monomorphization cuts both ways with performance - since it bloats executables (and thus hurts the branch predictor and cache) while generating more efficient code.

These languages aren’t the same. There’s lots of reasons they will perform differently both at the limits of what we can optimize and in the average case of everyday code. It’s wild that you would consider them to all be the same.

Re:Ruby Outperforms C: Breaking the Catch-22 by PartiallyTyped on Saturday September 09, 2023 @02:59AM (#37442903)
> Rust is limited to llvm, while C can be compiled with many other compilers - some of which produce better code in many cases. (Eg icc)

There's a rust front-end for gcc as well.

Re:Ruby Outperforms C: Breaking the Catch-22 by josephg on Saturday September 09, 2023 @03:40AM (#37443136)
Is it ready for use? Last I saw it was far from feature complete.
Re:Ruby Outperforms C: Breaking the Catch-22 by PartiallyTyped on Saturday September 09, 2023 @04:39AM (#37443378)
Afaik the borrow-checker is missing - please correct me if I am wrong - but that doesn't stop you from using it. You could very well use `rustc` for the borrow-checker and compile with GCC on any other backend. The borrow-checker only expresses that your code is sound according the rust spec.
Re:Ruby Outperforms C: Breaking the Catch-22 by josephg on Saturday September 09, 2023 @05:33AM (#37443621)
> The borrow-checker only expresses that your code is sound according the rust spec.

Doesn’t the borrow checker also track when things fall out of scope, and thus control when Drop is called?

Re:Ruby Outperforms C: Breaking the Catch-22 by PartiallyTyped on Saturday September 09, 2023 @05:52AM (#37443705)
Afaik it tracks when objects go out of scope as that deals with ownership and lifetimes, but that's also part of the rust spec.

The drop is there for stuff that you can't just release the memory for, such as closing files and connections.

Re:Ruby Outperforms C: Breaking the Catch-22 by iudqnolq on Saturday September 09, 2023 @09:48AM (#37445362)
No. Drop has straightforward rules.

Find the scope you can refer to the variable in, i.e. the curly brackets it is contained in. That variable is dropped right before the closing curly bracket. Things are dropped in reverse order of creation.

(Similar rules apply to dropping temporaries)

https://doc.rust-lang.org/reference/destructors.html