3 ms·
> Existing libraries resorted to code generation a lot. guess what generics is in a lot of languages? code generation! the files just aren't saved to disk.
by naikrovek 5y ago
> Existing libraries resorted to code generation a lot.
guess what generics is in a lot of languages? code generation! the files just aren't saved to disk.
IIRC on a podcast I seem to recall hearing that it was implemented this way for Go, at least for the prototype, and it seems likely to me that it is also done this way in production, but not with textual code.
- akmittal 5y agoThats like saying lets just write assembly because eventually code will be converted to assembly. As a developer now we dont have to bother about codegen.
- BobbyJo 5y agoNo exactly. Assembly is more like the generated code than the generator code.
- uluyol 5y agoGo is not quite doing this level of expansion: https://github.com/golang/proposal/blob/master/design/generics-implementation-dictionaries-go1.18.md https://github.com/golang/proposal/blob/master/design/generi... In particular, a single expansion is shared for all pointer types.
- chakkepolja 5y agoI think the word you're looking for is Monomorphization, and AFAIK it's only C++ and Rust that completely monomorphize.
- erik_seaberg 5y ago> aren't saved to disk This is a big win. They can’t get stale, they don’t need review, and you don’t have to remind everyone which files should never be edited.