News for hackers. Stuff that matters.
Re:Sustainability with Rust by throwaway894345 on Saturday February 12, 2022 @12:05PM (#30314287)
> Go is not particularly efficient as a language and its compiler doesn't optimize much compared to the other "efficient" language compilers (even the JIT ones).

I mean, relative to many other mainstream languages including many of the JIT languages, Go is very efficient, but a lot of that efficiency comes from the language design (e.g., idiomatic value types) such that the compiler and runtime don’t need to be as smart.

Agreed that the benchmarks game is a pretty crumby measure of performance, but it typically imposes strange restrictions on Go that prevents it from showing its idiomatic performance (never mind its ceiling). For example, languages with garbage collectors aren’t allowed to preallocate memory for certain benchmarks even though that’s absolutely idiomatic in Go (because Go has value types) so you have languages with GCs optimized for languages where everything is an allocation which perform well and languages like C and Rust which are allowed to preallocate because they don’t have a GC (which is a weird criteria) and then you have Go which appears to be very slow because it’s forced to allocate in a tight loop.

Re:Sustainability with Rust by sirwhinesalot on Saturday February 12, 2022 @12:20PM (#30314423)
Yes Go's design is not bad as far as efficiency goes, but it's not amazing either.

From a language design perspective (when it comes to "ease of optimization") it's much better than Java and comparable to C#.

But compiling C# with CoreRT (which is basically .NET Core's RyuJIT configured as an AOT compiler) shows just how little Go's compiler optimizes. Go would need to be even more "easy to optimize" than it is to make up the difference. Rust and C++ are both easier to optimize and their compilers are in a whole other league entirely, and it shows on the horrific compilation speeds.

I'm not sure what the right way to do these "benchmarks" is. Some of the code I've seen there was more low level and convoluted than stuff I'd write in C. Not even remotely representative of how the languages are used. Stupid rules like that one you mentioned also don't help since some languages get to preallocate and others don't.

Re:Sustainability with Rust by throwaway894345 on Saturday February 12, 2022 @12:45PM (#30314650)
Agreed--Go isn't in the top tier of languages with respect to efficiency--the languages in this tier trade off a lot of other facets to get high performance, and those tradeoffs don't align well with Go's goals. That said, I would be curious what sorts of optimizations Go could add which would pay for themselves with respect to keeping compile times fast. I don't know a lot about compiler optimizations, but I find the topic very interesting at least as it pertains to languages I use (I really don't care much about Haskell or OCaml or any of the other PLT darlings).
Re:Sustainability with Rust by igouy on Saturday February 12, 2022 @01:29PM (#30314999)
> I'm not sure what the right way to do these…

In which case, maybe what you see is as good as you'll get.

> … some languages get to preallocate…

Here's Go using a library pool —

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:Sustainability with Rust by sirwhinesalot on Saturday February 12, 2022 @05:02PM (#30316971)
The sync library is part of Go's standard library and is meant to allow safe concurrent access by multiple goroutines. It's pretty idiomatic Go!
Re:Sustainability with Rust by igouy on Saturday February 12, 2022 @05:55PM (#30317202)
Yes — so "allowed to preallocate memory" ?
Re:Sustainability with Rust by igouy on Saturday February 12, 2022 @01:20PM (#30314925)
> … aren’t allowed to preallocate memory…

Because as-you-know the whole point is to "allocate zillions of short-lived nodes" —

https://news.ycombinator.com/item?id=29323468

Re:Sustainability with Rust by sirwhinesalot on Saturday February 12, 2022 @04:55PM (#30316918)
The C++ and Swift implementations use a node pool from the Apache Portable Runtime. This benchmark would be a lot more interesting if we got to see the price of C++'s RAII or Swift's reference counting.

The Swift Code looks like something you'd write in C.

Re:Sustainability with Rust by igouy on Sunday February 13, 2022 @04:37PM (#30325932)
> … the price of C++'s RAII…

Like this? (There are 8 other C++ binary trees programs.)

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

> … or Swift's reference counting.

Like this? (There are 4 other Swift binary trees programs.)

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:Sustainability with Rust by igouy on Saturday February 12, 2022 @08:11PM (#30318084)
You could ask the authors to update their study.

You could look at the different binary trees programs shown on the current benchmarks game.

Re:Sustainability with Rust by throwaway894345 on Saturday February 12, 2022 @02:14PM (#30315413)
“It’s not a bad benchmark, it’s just showcasing a contrived scenario with different sets of rules for different kinds of languages”.

Most people aren't building applications whose business requirements preclude preallocating memory except for languages which lack garbage collectors.

Re:Sustainability with Rust by igouy on Saturday February 12, 2022 @02:27PM (#30315516)
So those are scare quotes not actually quotation?

If we don't experience a performance problem, we don't need a workaround.

Re:Sustainability with Rust by throwaway894345 on Saturday February 12, 2022 @03:41PM (#30316185)
No, that’s not an actual quotation. I was having a laugh at the silly logic which attempts to justify the benchmark. And preallocating isn’t a workaround, it’s idiomatic in Go.
Re:Sustainability with Rust by igouy on Saturday February 12, 2022 @04:27PM (#30316681)
That is not a contradiction: it can be both idiomatic in Go and a workaround to avoid garbage collection.
Re:Sustainability with Rust by throwaway894345 on Saturday February 12, 2022 @04:53PM (#30316904)
And that’s a valid point for the set of applications whose purpose is generating garbage. But overwhelmingly this isn’t interesting and people mistake this benchmark for a useful indicator of programming language performance in the general case.
Re:Sustainability with Rust by igouy on Saturday February 12, 2022 @06:21PM (#30317378)
And the set of applications that will inevitably generate garbage, which might be left to automatic garbage collection.

Errare humanum est.

"Energy Efficiency across Programming Languages" not "programming language performance in the general case".

Re:Sustainability with Rust by throwaway894345 on Saturday February 12, 2022 @07:08PM (#30317685)
It’s not a very compelling defense of a benchmark to argue that it measures something different for some languages than others—in this case for Go the benchmark measures poorly/carelessly written code while for other languages it measures meticulously optimized code.

I maintain a contrived benchmark is not a useful benchmark.

Re:Sustainability with Rust by igouy on Saturday February 12, 2022 @08:20PM (#30318158)
In this case for Go, the same as other languages that provide automatic garbage collection.

In this case for Go, the same as other languages that provide a library pool implementation.

Apparently the study authors found a use.