4 ms·
Neat! Optimization is fun. But you can also shrink code by going to higher-level languages... (yes, I know, it won't run as fast and will take a lot more memo
by ratsbane 19y ago
Neat! Optimization is fun. But you can also shrink code by going to higher-level languages... (yes, I know, it won't run as fast and will take a lot more memory when it runs, but still...)
mbp:~/test doug$ cat tiny.pl
return 42;
mbp:~/test doug$ ls -la tiny.pl
-rw-r--r-- 1 doug doug 12 Oct 15 11:31 tiny.pl
- e1ven 19y agoThat's an interesting point, and certainly true in some areas, but having thought about it, I don't think it's fair. The point of theexercise is to reduce to the smallest bit of program.. Your version should count the size of the interpeter as well, since it's necessary for execution. Under that model, I could use a program of 1 I'll run this program with my new SwankyCool intrepreter [tm] which returns 42 if it sees a program comprising only "1"; Otherwise it calls perl to exec the rest of the file. Now, in both cases, we're accepting that the entire OS is already there, but that was stated in his example. (ELF on Linux)
- brl 19y agoThis is an awesome old classic which is required reading for anybody who wants to understand how ELF object files are loaded and executed. This is pretty far beyond 'optimization'. The executable is 7 bytes smaller than the minimum legal size for the object file header!