Metaprogramming for madmen
fgiesen.wordpress.com
fgiesen.wordpress.com
It's very interesting is the sort of extreme version of the idea that data model and code are inherently tied: Especially in functional programming circles it's a maxim that you design your data models first, specifically for your task, and then the rest of the code is pretty much pattern-matching around that. This takes that coupling and makes it even tighter, to serve a higher purpose. I almost feel like given enough time, this could be a JIT: an executable that adaptively strips code and self-minifies over time as you run it. :)
Also check out: - kkrieger (windows only 96kb 3D FPS, video here: https://www.youtube.com/watch?v=2NBG-sKFaB0) - the previous post (http://fgiesen.wordpress.com/2012/02/13/debris-opening-the-b...)
i wonder if a lot of the dead code paths are already eliminated at runtime by the branch predictors in modern CPUs/GPUs. of course it would make no difference for size on disk (which can be argued is mainly useful for code golf and edu these days), but it would be cool to get that feedback in some format without needing to exert any additional effort.
You can usually get the linker to either remove dead code or assist in its removal, though. "Nearly" dead code is the big pain (e.g. options that are never set but could be).
Yes, their tool is getting pretty similar to superoptimization and profile-guided optimization.
(Of course, you don't really want to self-minify over time: what if a new request comes in from a user exercising stripped functionality? You'd have to have some sort of fallback way to retrieve the original unoptimized code.)
(Also, take a look at the rest of Fabian's blog, it's extremely good.)
More info on it here. http://en.wikipedia.org/wiki/.kkrieger & makmanalp posted a youtube video.
Details: http://blog.golang.org/cover