News for hackers. Stuff that matters.
Re:How generics are implemented in Go 1.18 by FooBarWidget on Tuesday March 01, 2022 @03:30PM (#30519582)
Rust also has (relatively) bad compile times due to generics. Not as bad as C++, but you can notice it's significantly worse than Go.
Re:How generics are implemented in Go 1.18 by yakubin on Tuesday March 01, 2022 @04:26PM (#30520232)
Rust does compile slower than Go, but it's not due to generics. It's mostly due to LLVM codegen and procedural macros. Go has the benefit of not relying on LLVM and not having procedural macros.
Re:How generics are implemented in Go 1.18 by edflsafoiewq on Tuesday March 01, 2022 @06:41PM (#30521600)
A lot of the IR comes from expanding huge stacks of generic functions. I don't think the issue can't be neatly partitioned up like that.
Re:How generics are implemented in Go 1.18 by codeflo on Tuesday March 01, 2022 @04:48PM (#30520488)
Absolutely true. I’d add that Rust is also doing a lot more expensive optimizations in release builds.
Re:How generics are implemented in Go 1.18 by jcelerier on Tuesday March 01, 2022 @04:56PM (#30520599)
Until recently Go didn't even use registers for passing arguments, it just put everything on the stack like in a 1965 textbook (https://go.googlesource.com/proposal/+/refs/changes/78/24817...)
Re:How generics are implemented in Go 1.18 by eloff on Tuesday March 01, 2022 @05:04PM (#30520672)
If you mean for function calls, I believe you're correct, not taking into account inline functions.

However, for code generation Go obviously uses registers since way before the 1.0 days.

Re:How generics are implemented in Go 1.18 by geodel on Tuesday March 01, 2022 @08:04PM (#30522324)
You are right of course about LLVM being source of slowness.

In general discussion I see around is that all Rust's perf optimizations are to Rust's credit (nothing about LLVM optimization) while all woes around Rust's compile time lay at step of LLVM and Rust is not be blamed.

Re:How generics are implemented in Go 1.18 by pjmlp on Tuesday March 01, 2022 @03:45PM (#30519759)
D, Ada, Eiffel, Delphi go as counter example, and C++ modules are already proving a much better experience in VC++.
Re:How generics are implemented in Go 1.18 by FooBarWidget on Wednesday March 02, 2022 @06:06AM (#30526020)
Delphi didn't have generics. Not sure about more modern versions, but the power of the generics also impacts compile times. Java generics barely impact compile times at all but they're also nowhere as powerful as Rust and C++ ones.
Re:How generics are implemented in Go 1.18 by pjmlp on Wednesday March 02, 2022 @07:50AM (#30526760)
You stop using Delphi long time ago, I would say.

To pick one of my examples, D templates and compile time metaprogramming are even more powerfull than Rust and C++ ones, yet it compiles just as fast.

Re:How generics are implemented in Go 1.18 by benibela on Wednesday March 02, 2022 @01:57PM (#30531269)
Delphi added generics in 2009

So it had them roughly as long as Go existed

Re:How generics are implemented in Go 1.18 by vyskocilm on Wednesday March 02, 2022 @02:10AM (#30524626)
There is tinygo with llvm backend and the build times are abysmal.