Hacker News new | ask | show | jobs
by uwu 2919 days ago
when i was a full-time hobbyist webdev i was surprised when i learned c compilers don't do whole-program optimization by default but limit themselves by optimizing each translation unit separately (i guess it makes things simpler)

you can get "LTO" in javascript by using a minifier together with something like webpack which can inline modules when it's safe to do so (instead of putting them in functions that are called by the module loader and can't be minified away), so i assumed "real" compilers must do that stuff a lot better with the language being less dynamic

1 comments

In addition to simplicity it cuts down on compilation time. You can checkout MLTon or Felix to get a feel for whole program optimizing compilers, they can do optimizations that are impossible without LTO and hard to do with.

https://github.com/felix-lang/felix

http://felix-documentation-master.readthedocs.io/en/latest/m...

http://mlton.org