News for hackers. Stuff that matters.
Re:The Next Step for Generics by chubot on Tuesday June 16, 2020 @05:51PM (#23544702)
The flip side was on the top of HN yesterday:

Generics and Compile-Time in Rust

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

It's easy for spectators / bystanders to call something a mistake because you don't understand the tradeoffs. Try designing and implementing a language and you'll see the tradeoffs more clearly.

Re:The Next Step for Generics by entha_saava on Wednesday June 17, 2020 @12:19AM (#23547742)
D has generics and compiles fast. There are probably other examples too.

The overlooked thing is rustc produces poor quality LLVM IR which is also mentioned in FAQ.

And generics reduce amount of manual for loop juggling code one has to write. I don't think adding generics makes much of a difference.

Re:The Next Step for Generics by 59nadir on Wednesday June 17, 2020 @07:21AM (#23550134)
> The overlooked thing is rustc produces poor quality LLVM IR which is also mentioned in FAQ.

LLVM is also slow in general. If you use it, it's likely the thing that's bottlenecking your language's compile-time unless you've done something insane like templates and `#include`, etc..

Inevitably it's the case that even if your source language doesn't do nearly as badly at the design stage when it comes to generics as C++ does, if you use LLVM your build stage is probably going to be unacceptably slow.

Re:The Next Step for Generics by entha_saava on Wednesday June 17, 2020 @08:39AM (#23550657)
> LLVM is also slow in general.

Agreed. But so is GCC. And I guess many of the 'zero cost' abstractions require some advanced optimizing compiler like LLVM to be zero cost (or move that complexity to compiler end).

They specifically mentioned the technical debt and poor LLVM IR Generation issue though. I wonder if it has yet gotten attention or fixed. Maybe @pcwalton knows.

Re:The Next Step for Generics by chubot on Wednesday June 17, 2020 @01:04PM (#23553791)
OK sure, now write your own backend or use one other than LLVM (which one?). Now you're going to learn about a different set of tradeoffs.
Re:The Next Step for Generics by entha_saava on Wednesday June 17, 2020 @11:32PM (#23559546)
Go and D made the tradeoff. And both have good compile times. Both of them have GCC and LLVM frontends as well as a homegrown one. And homegrown ones have fast compile times.

Edit: well fast compile times at the expense of optimization. But that kind of proves the point.