News for hackers. Stuff that matters.
Re:3998-byte executable reduced to 45 bytes by ratsbane on Monday October 15, 2007 @12:35PM (#68074)
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
Re:3998-byte executable reduced to 45 bytes by e1ven on Monday October 15, 2007 @01:23PM (#68092)
That'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)

Re:3998-byte executable reduced to 45 bytes by brl on Monday October 15, 2007 @01:47PM (#68103)
This 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!