Slashdot Mirror


Smallest Possible ELF Executable?

taviso writes "I recently stumbled across this paper (google cache), where the author investigates the smallest possible ELF executable on linux, some interesting stuff, and well worth a read. The author concludes, 'every single byte in this executable file can be accounted for and justified. How many executables have you created lately that you can say that about?'

173 of 451 comments (clear)

  1. Not good enough by mesocyclone · · Score: 5, Funny

    It isn't amazing until its also palindromic!

    --

    The only good weather is bad weather.

    1. Re:Not good enough by Anonymous Coward · · Score: 5, Funny

      aibohphobia-the fear of palindromes. get it?

    2. Re:Not good enough by red_dragon · · Score: 5, Funny

      Weird... I read that as "aibophobia", and thought it was the fear of electronic pets.

      --
      In Soviet Russia, Jesus asks: "What Would You Do?"
  2. smallest elf execution by Anonymous Coward · · Score: 5, Funny

    I just heard the news on slashdot -- Frodo Baggins, the smallest elf, was just executed! No other details were available.

    1. Re: smallest elf execution by Black+Parrot · · Score: 5, Funny


      > I just heard the news on slashdot -- Frodo Baggins, the smallest elf, was just executed! No other details were available.

      In my own research I have discovered that the average Hobbit executable is barely half the size of the average Elf executable.

      They're faster to run in a tight spot, too!

      --
      Sheesh, evil *and* a jerk. -- Jade
    2. Re:smallest elf execution by mbogosian · · Score: 5, Funny

      Frodo Baggins, the smallest elf, was just executed!

      Unfortunately, the article was incorrect then. Frodo is a hobbit. Furthermore, he is far from the smallest hobbit.

      However, he was executed. By two elves. By way of trampling.

      Does that mean we can assume that ELF binaries run on Hobbits?

      (Sorry, I couldn't resist.)

    3. Re:smallest elf execution by skaffen42 · · Score: 2, Funny

      I'm confused. Is this a troll or not?

      --
      People couldn't type. We realized: Death would eventually take care of this.
    4. Re:smallest elf execution by mbogosian · · Score: 5, Funny

      I'm confused. Is this a troll or not?

      No. Trolls are completely different creatures from hobbits and elves.

    5. Re:smallest elf execution by Isle · · Score: 2

      I thought he was made honourary elf like Bilbo.

  3. No law on repeat articles? by ebuck · · Score: 4, Interesting

    Last time I read this on slash dot was less than a year ago. I imagine in 4 or 5 months we'll see it again.

    The article is great. It really is a good intro to refresh that assembly / understand ELF / do neat stuff. I still have the tiny assembler installed on my machine from the last go round.

    I've heard of a guy who is trying to make the world's smallest 'cat' program. I wonder how many other utilities have been similiarly "optimized"

  4. Turbo Pascal by DNS-and-BIND · · Score: 2, Interesting

    I seem to remember making some damn small Turbo Pascal .COM files. Under 4096 bytes, IIRC.

    --
    Shutting down free speech with violence isn't fighting fascism. It IS fascism!
    1. Re:Turbo Pascal by compwizrd · · Score: 5, Interesting

      Some of the old-time Demo groups (and warez groups) would put very nice VGA demos in 4k as well.

    2. Re:Turbo Pascal by dknj · · Score: 3, Interesting

      They still do pack some nice effects into 40k windows binaries now.. I'm still amazed

      -dk

    3. Re:Turbo Pascal by irc.goatse.cx+troll · · Score: 3, Interesting

      40k? luxury!
      try 256 bytes ;)

      --
      Pain lasts, kid. Its how you know you're alive. Sometimes I think this growing up thing is just pain management-TheMaxx
    4. Re:Turbo Pascal by cvore · · Score: 5, Informative

      A dos .com file does not have a lower limit. .COM files are without headers, so having a realy tiny .com file is not very hard ;) It sais more about the crap turbo pascal puts in the .com file.. a .com file that returns correctly can just have one byte in it: 0xc3 (RET)

    5. Re:Turbo Pascal by Anonymous Coward · · Score: 3, Informative

      - I seem to remember making some damn small Turbo Pascal .COM files. Under 4096 bytes, IIRC.

      The Amiga E language (sort of a Pascal+C+whatever like beast) compiler stuffed a hello world program in 80 bytes or so. Pure executable, no external libraries needed.
      The author's list of self-designed languages is definitely worth a look.

    6. Re:Turbo Pascal by p3d0 · · Score: 2

      4k is "damn small"? Methinks you have not read the article. He ended up with a 45-byte executable.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    7. Re:Turbo Pascal by taliver · · Score: 3, Funny

      4 bytes! My family would dream of 4 bytes. We had to get up in the morning, defrag the file system, decrypt RSA-65 for 23 hours and then go back to the boot sector where we would be erased. And we had to do it all in 4 bits of space!

      4 bytes. Hmph.

      --

      I demand a million helicopters and a DOLLAR!

    8. Re:Turbo Pascal by Sir+Tristam · · Score: 2
      Right! Our programs had to finish in the morning, at ten o'clock at night, half an hour before they were submitted, solve NP-complete problems, leave more memory free than the computer had, and when we'd go to the computer room the operator would kill us and dance around on our graves, singing Hallelujah!

      And you try and tell the young people of today that, and they won't believe you!

  5. You disgust me... by tuxedo-steve · · Score: 5, Funny

    ... wanting to execute the smallest possible elf. You Americans and your bloodsports. Barbarians.

    If you guys go ahead with your cold-hearted plan to execute this elf, the Olsen twins better watch their backs next time they're in Ireland, if you catch my drift.

    --
    - SMJ - (It's not just a name: it's a bad aftertaste.)
    1. Re:You disgust me... by jdkincad · · Score: 3, Funny

      And you think we would care if something happened to the Olsen twins?

      --
      The great advantage of having a reputation for being stupid: People are less suspicious of you.
  6. Small virus catcher (for DOS) by Fuzzums · · Score: 5, Interesting

    in assembly: RET

    All this one byte program does is terminate execution. If it's infected by a virus you'll see soon enough if the size has increased.

    ofcourse with todays macroviruses this doesn't work anymore :(

    --
    Privacy is terrorism.
    1. Re:Small virus catcher (for DOS) by Trusty+Penfold · · Score: 2, Funny

      Some viruses wouldn't infect suspected goat files; files with 'obvious' sizes. AV researchers would get the virus to infect the files - since the contents were known beforehand any changes were due to the infection.

      Of course this AV avoidance didn't work, as evidenced by the fact that viruses are now extinct and a footnote in the history of computer security.

    2. Re:Small virus catcher (for DOS) by RinkSpringer · · Score: 4, Insightful

      Uhrm, not really. Almost any COM file infecting virus will read the first 3 bytes and check whether it's a JMP instruction (0xEB and 0xE9 opcode). If they are not, they usually refuse to infect the file.

      Therefore, this file wouldn't be infected by like 99% of all COM infecting virii...

    3. Re:Small virus catcher (for DOS) by reynaert · · Score: 2

      Not to mention that most viruses hide their modifications when active.

  7. good, bloat sucks by Anonymous Coward · · Score: 3, Funny

    Linux software is horribly bloated, like even "ls" is above 30k, thats just insane for a program thats supposed to just list files in a directory. About time someone did something about it.

    1. Re:good, bloat sucks by mickwd · · Score: 3, Funny

      Well it still manages to list files faster than my eyes can read them.

      So don't expect me to do anything about it.

    2. Re:good, bloat sucks by peter · · Score: 2

      > Who uses the -i (--inode) option?

      You can use it to identify hard links.

      > Linux 2.4.19 is 24.8 MB!

      They could probably shrink that a bit if they looked for multiple implementations of the same thing. Rumour has it that Linux used to include four copies of zlib :) Farming out some of the /proc stuff to user space might help too. (and might reduce the amount of unpageable memory needed by the kernel.) Most of the space is in the source tree (as opposed to a compiled binary) is architecture and hardware specific code, though. (There are 16 subdirs in linux/arch, and 16 corresponding include/asm-* directories.)

      llama]~$ du -s /usr/src/linux/*
      6076 /usr/src/linux/Documentation
      31176 /usr/src/linux/arch
      83420 /usr/src/linux/drivers
      14208 /usr/src/linux/fs
      29304 /usr/src/linux/include [19MB of this is arch-specific include/asm-*]
      48 /usr/src/linux/init
      96 /usr/src/linux/ipc
      520 /usr/src/linux/kernel
      128 /usr/src/linux/lib
      436 /usr/src/linux/mm
      7604 /usr/src/linux/net
      560 /usr/src/linux/scripts

      (This is 2.4.19 with RML's preempt patch, after compiling on my PIII.)

      Having all the drivers included with the kernel source is kind of a mixed blessing. It makes the kernel source really big, but you don't have to worry about driver-vs.-kernel version compatibility. Linux's monolithic kernel design would make that a serious problem otherwise.

      --
      #define X(x,y) x##y
      Peter Cordes ; e-mail: X(peter@cordes , .ca)
    3. Re:good, bloat sucks by mcrbids · · Score: 2

      ls is 45k!

      -rwxr-xr-x 1 root root 45948 Aug 9 2001 /bin/ls

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
  8. I feel guilty by Anonymous Coward · · Score: 5, Funny

    This makes my new 100-gig hard drive seem WAY too big.

    1. Re:I feel guilty by Kenshin · · Score: 3, Funny

      Don't feel so bad, you could alays fill it up with porn. That's why they keep boosting the capacity.

      --

      Does it make you happy you're so strange?

    2. Re:I feel guilty by p3d0 · · Score: 3, Funny

      Porn jokes are the "imagine a beowulf cluster" for the 21st century.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    3. Re:I feel guilty by Alien+Being · · Score: 2

      In other words, nothing but the "naughty bits"?

  9. Glibc is the thief! by Goodbyte · · Score: 2, Informative

    I've always wondered what all the glibc overhead (compared to f.i. uClibc) does. I've never noticed any functional difference when setting up a initrd image by using uClibc instead of glibc.

  10. Interesting topic... by AtariDatacenter · · Score: 2

    There isn't much practical here more than it is an ELF education. But it was a very interesting read... and being able to stuff a payload into the header. Nicely done. But given that, in most cases, disk space is vast, and memory is plentiful, there isn't much in the way of usefulness. Maybe in some niche' applications running on tight hardware... but running Linux.

    1. Re:Interesting topic... by Blkdeath · · Score: 3, Interesting
      But given that, in most cases, disk space is vast, and memory is plentiful, there isn't much in the way of usefulness. Maybe in some niche' applications running on tight hardware... but running Linux.
      Consider for a moment what the GNU world would be like if every byte, primarily of our base system, was accounted for. Imagine a Linux distribution on the shelf with a "Zero Overhead" label on it - and be able to mean it!

      Consider Linux 2.4.x running on a 486 with 16MB of RAM - and having 14 of it free for applications even with init and Bash running.

      Now expand the concept to GUI applications, XFree86, etc. and think of how blazingly FAST the entire Linux experience would be, even on the most mediocre hardware. People would get a CPU upgrade and their systems would boot to KDM as if it was already loaded.

      Considering too the fact that every (assuming based on my own HDDs and limited knowledge of IDE transfer code) 8KB of program code requires a separate disk read operation to load to cache. Every 8KB that's shaved off an application's startup routines is one less disk read, which means those dusty old ATA33 hard drives would suddenly seem a lot more worthwhile to keep around (not to mention they'd be big enough, what with reduced size constraints) - an especially Good Thing<TM> considering recent changes in manufacturer policy where new drives are concerned.

      The excuse that CPU/RAM/HDD is inexpensive is a lousy one at best. It's cheap because bloated programs and operating systems have driven up demand, which has caused a surge in supply, which has dropped the prices. Imagine a world though where it was only the Windows weenies who had to trundle out to their resident computer store every other month to accomodate their latest cabre of software updates? We'd be able to laugh at them, knowing full-well that our K62-400s were smoking their brand-new P4-3.0GHz super-screamer systems.

      </RANT>

      --
      BD Phone Home!

      Shameless plug. Like you weren't expecting it.

    2. Re:Interesting topic... by Blkdeath · · Score: 2
      To follow-up with my previous post..

      If programmers all started poring over their code to the degree that they were shaving off bits and bytes around every corner, chances are they'd become so completely familiar with every nook and cranny of their code that duplication of effort would be eliminated (an obvious benefeit), but also that the codebase could shrink and bugs could be easier to zoom in on. A world in which bugs are fixed before they're reported is my idea of computer utopia.

      --
      BD Phone Home!

      Shameless plug. Like you weren't expecting it.

    3. Re:Interesting topic... by topham · · Score: 4, Insightful

      If you ever found a bug in code optimized to that degree you would NOT want to fix it as it could require a complete rewrite from scratch.

    4. Re:Interesting topic... by Blkdeath · · Score: 2
      If you ever found a bug in code optimized to that degree you would NOT want to fix it as it could require a complete rewrite from scratch.
      You sound like Ford Motor Company back when the Pinto was causing {eh-hem} problems. They decided that it would cost less to handle the lawsuits than the recall.
      --
      BD Phone Home!

      Shameless plug. Like you weren't expecting it.

    5. Re:Interesting topic... by topham · · Score: 2

      No, code optimized to the degree shown here is entirly impracticle.

      Good optimized code is a seperate discussion.

  11. umm.... yeah? by Lxy · · Score: 2, Insightful

    Basically what the other is saying is that by default, C is somewhat bloated (you need to include massive libraries just to use one function). Writing system level calls in assembly can replace the unnecesary bloat of a library that's only being used by one function.

    I remember this trick wehn I was learning x86 assembly. I wrote a hello world program in assembly. Assembled, it came to something like 35 bytes. In C++, it took over 10K.

    Now, also see the statement that he is abandoning portability, because he's using linux-specific system calls. So, in a nutchell, C++ makes big code that's portable, assembly makes tiny code that's static.

    Did I miss something or was this a long winded article about why assembly is better than C++?

    --

    There is no reasonable defense against an idiot with an agenda
    :wq
    1. Re:umm.... yeah? by Leonel · · Score: 4, Interesting
      Did you bother to read it?

      From the article, after the first try in asm:

      Looks like we shaved off a measly twelve bytes. So much for all the extra overhead that C automatically incurs, eh?
    2. Re:umm.... yeah? by mbogosian · · Score: 2, Troll

      Assembled, it came to something like 35 bytes. In C++, it took over 10K.

      Obviously you weren't using the ELF format then:

      There is no getting around the fact that the 45th byte in the file, which specifies the number of entries in the program header table, needs to be non-zero, needs to be present, and needs to be in the 45th position from the start of the ELF header.

      Maybe ELF is just too inefficient. :)

    3. Re:umm.... yeah? by Lxy · · Score: 2

      Yes, but he continues to say that he's using a C library function to END the program, with is how he knocked off 2K+ of space when he wrote it in assembly, forcing incompatibility with othe platforms.

      --

      There is no reasonable defense against an idiot with an agenda
      :wq
  12. Correction by ebuck · · Score: 3, Interesting

    Well, someone will point it out soon, so I might as well do it myself.

    nasm is the name of the assembler, not tiny.

    You can make a 45 byte version of the 'true' and 'false' utilities by changing the output to 1 or 0 respectively. Some shells implement these as builtin functions, but it does show a pratical (albeit odd) way to save a few bytes of disk space.

    1. Re:Correction by gorilla · · Score: 2

      You can get a 0 byte version of true. An empty file will execute as a shellscript and return true, and this was the traditional true until after v7 Unix.

  13. Smallest Posible Post by Anonymous Coward · · Score: 5, Funny
    1. Re:Smallest Posible Post by moonbender · · Score: 5, Funny

      Wow, you even saved a byte by mis-spelling "Possible" - awesome!

      --
      Switch back to Slashdot's D1 system.
  14. Bloat...now a worldwide concept! by Masque · · Score: 4, Funny

    This guy clearly doesn't get the point!

    67% of Americans are overweight. They can't account for most of the bites they use. By developing software that is just as bloated, the users feel good about themselves.

    This kind of skinny programming is very insensitive to the fatass society we Americans live in! Hopefully the U.S. Congress hears of this soon, so that they may legislate this kind of software right off the face of the earth.

    Masque, head of the Sensitive Programming Foundation*

    [*A division of Maxtor Corporation; come check out our new 320GB drives, featuring room for tomorrow's applications...today.]

  15. Windows exe by Sivar · · Score: 4, Interesting

    Cas, or StorageReview.com's forums, created a 324 bytes Windows 2000 PE executeable. It completely blew away all of mine, the smallest of which were about ~700 bytes.

    --
    Computer Science is no more about computers than astronomy is about telescopes. --E. W. Dijkstra
    1. Re:Windows exe by Sivar · · Score: 2

      or = of

      --
      Computer Science is no more about computers than astronomy is about telescopes. --E. W. Dijkstra
    2. Re:Windows exe by rnd() · · Score: 2

      Smallest Word 2000 File: 19KB
      Smallest Word HTML File: 1.5KB

      --

      Amazing magic tricks

  16. justification by mbogosian · · Score: 5, Funny

    every single byte in this executable file can be accounted for and justified

    The author's sanity, however, cannot.

  17. Re:No law on repeat articles (An apology) by ebuck · · Score: 2

    My sincere apologies,

    I read this article months ago, but it was not a Slashdot link. It was a link from another tech news source.

  18. Optimized Executables by aking137 · · Score: 5, Informative

    I think there are quite a few. It's seen as a challenge, and does have practical uses. Have a look at Toms Rootboot disk - it includes a web server, a telnet server, a telnet client, an nfs client, wget, gzip, bzip2, vi, a whole load of network drivers, and a tonne of other stuff, all compressed down onto one floppy disk. Only I've never quite been able to find the source code for any of it despite spending a small amount of time looking - possibly someone would be able to put me right on that one.

    There are also lots of interesting articles on linuxassembly.org.

    Andrew

    1. Re:Optimized Executables by op00to · · Score: 2, Informative

      The problem is that the FILESYSTEM itself cannot allocate a smaller amount of bytes than, say, n. So, if you have a program that is n-1, it still takes up n bytes. So, it's really not all that practical in 99.999999% of uses (that includes boot disks.)

    2. Re:Optimized Executables by Sparr0 · · Score: 5, Informative

      You are incorrect. The filesystem is stored on the disk in a compressed form, it is decompressed to a RAM drive. Every byte DOES count.

    3. Re:Optimized Executables by Fastolfe · · Score: 5, Informative

      Your information is dated. There are smarter filesystems nowadays that can allocate data from more than one file into a single "cluster". ReiserFS is one such filesystem for Linux, but there are surely others.

    4. Re:Optimized Executables by aking137 · · Score: 2, Insightful

      Yes thankyou, I am. I have used both successfully - download the image and try it. They're there, and they do have very real uses in terms of rescuing machines, which is simply to allow one to transfer files across a network. If I remember rightly, the web server executable is significantly less than 1k in size. And why not have a telnetd if you can fit it into a few kB?

      The whole disk has become so useful that it has virtually removed any need for an MS-DOS disk on the network I'm looking after. Running an rm -rf /mnt/c for a multi-gigabyte FAT32 filesystem takes seconds, as opposed to a deltree c:\*.* from a DOS disk, which can take literally hours, for example.

      Andrew

    5. Re:Optimized Executables by Anonymous Coward · · Score: 2, Informative

      Ah, yes, I remmember jet. Jet was a fun flight simulator when graphics were at their most primitive. The program was copy protected, so it wasn't easy to just copy the 360k floppy. The 76k you are refering to was just the loader, the full program resided hidden on the rest of the disk that DOS could not see. I had a copy a while back but alas, finally decided to format over it.

      Anyone know where a site is with that program?

    6. Re:Optimized Executables by scrytch · · Score: 2

      The problem is that the FILESYSTEM itself cannot allocate a smaller amount of bytes than, say, n. So, if you have a program that is n-1, it still takes up n bytes. So, it's really not all that practical in 99.999999% of uses (that includes boot disks.)

      This is why you stuff them all into one file. Everything in FreeBSD's /stand is a hardlink to the same file (which is just big enough to fit on one floppy). Busybox has the same philosophy.

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
  19. Not bad... by Captain+Pedantic · · Score: 5, Interesting

    But I'd like to see them get a Breakout clone in 1K

    --

    None are more hopelessly enslaved than those who falsely believe they are free. Johann Wolfgang von Goethe.
  20. Even Shorter... by MarvinMouse · · Score: 3, Interesting

    While the program would be completely useless.

    You could make it even shorter by having it return absolutely nothing (Just having it execute and finish.)

    It could be useful to catch when anything starts to modify programs on your computer, because if the "thing" just modifies programs, it will recognize it as a program, and increase the size notably.

    I really like the 45 byte program though, too bad that after you passed 100 bytes, it became totally non-compliant.

    --
    ~ kjrose
    1. Re:Even Shorter... by zsmooth · · Score: 3, Informative

      No, I don't think you can make it any shorter even by removing that call. The program is 45 bytes, and the 45th byte is required to be there (a critical part of the ELF header), or else it won't execute at all.

    2. Re:Even Shorter... by flossie · · Score: 2

      If the file can't get any smaller (and I believe the author, I think he knows what he's talking about!) then I suppose the next question must be, how much extra functionality can be fitted into those 45 bytes. Surely the program can be made to do more than just return 42.

  21. No need to be smaller than 512 really... by Anonymous Coward · · Score: 5, Interesting

    Harddrive sizes being what they are now, the smallest sector size I see is 512 bytes. If the file stored in that sector is smaller than 512, it still takes up 512 bytes. Very intersting article however.

    1. Re:No need to be smaller than 512 really... by Russ+Steffen · · Score: 3, Informative

      Unless, of course, you're using ReiserFS with tail packing turned on.

    2. Re:No need to be smaller than 512 really... by the+way,+what're+you · · Score: 5, Funny
      Unless, of course, you're using ReiserFS with tail packing turned on.

      This should really be added to the Linux Gay Conspiracy.

      --
      example.org - powered by Linux!
    3. Re:No need to be smaller than 512 really... by reitoei1971 · · Score: 2, Informative

      true, but a small elf still takes up less memory once loaded from disk. though with 512mb+ in todays systems, people can even afford to run more than one office Xp app.

    4. Re:No need to be smaller than 512 really... by shird · · Score: 2

      Like people have said, many filesystems allow you to store the information in the inode or equivalent. Also, when your transmitting data over a network, or tar/zipping the file up with many others, you will also see the benefits. OR if your storing it in FlashROM on a PDA or something.

      --
      I.O.U One Sig.
  22. Bigger is Sometimes Better by ksw2 · · Score: 5, Informative
    I used to kill myself trying to strip a few lines of code from my programs... in my mind, I was trying to emulate the PDP hackers of the 60s (my heros) by finding the one "Right Thing" for each program.

    Soon I realized that smaller programs are not the end-all goal of programming. If a slightly bigger program is easier to understand for the next person who modifies/maintains it, then that is the new "Right Thing" for that application... and I realized the efficient progamming of the PDP days was a biproduct of necessity more than anything else. It's seldom needed with today's blazing hardware capabilities.

    This isn't to say that many of today's programs are over-bloated, but just to reinforce the trade-off between small and easy to understand.

    1. Re:Bigger is Sometimes Better by Fastolfe · · Score: 2

      While I agree with what you're saying, bear in mind that this article is discussing compactness of machine code, not source code. A good compiler/optimizer will produce tight, efficient and compact machine code, even if you have to be a little more verbose in your source code so as to preserve the ability to easily read and maintain it. Nowadays (on Windows especially), even small or trivial functions invariably cause the executable to contain an enormous amount of bloat. The author here is simply making a point (at least at the start of the page) that a lot of this bloat is unnecessary and just needlessly consumes disk space.

  23. Microsoft. Yes, Microsoft by tomoose · · Score: 4, Insightful

    Reminds me of one of Bill Gates' first programs - Micro-Soft's 1975 Altair BASIC. Unfortuantly the page I wanted to link to has gone, but this is something from the register at the time: http://www.theregister.co.uk/content/4/18949.html

    Finally found a web archive of the page I wanted: http://web.archive.org/web/20011031094552/www.rjh. org.uk/altair/4k/index2.html

    A real pity that standards have slipped so much since then.

    (I refuse to post anonymously even though I have mentioned Microsoft in a thread about Small Exes. So there :p )

  24. Efficiancy in OS programming needed by TibbonZero · · Score: 5, Insightful

    We really need more efficiant programming in OSes today. Look at the system requirements for OSes over the past few years. It's gone crazy. Check out the requirements for NT Workstation 4.0, Windows XP Pro and Windows 2000 Pro.

    Doesn't something seem messed up? What have we really gained since 4.0 that causes 4x the memory, 3x the procecssor, and almost 15x the harddrive space? Is USB and Firewire support really that big? And have you ever tried to run XP on the min system? It doesn't work so well. I remember being able to tweak a system to run Windows 95 on a 386 with 5mb memory and a 45mb harddrive. It wasn't pretty but it could run. Today if you aren't going 1ghz+, then they want to leave you behind.

    They are just using really fast hardware as an excuse for bloating the code.
    Even Linux (redhat moreso) is guilty of this.
    Remember when awesome games could fit on a handful of floppies? I think that could fly today if they tried. Look at the Demo scene. 64k can do alot of graphics. The most awesome games like Betrayal at Krondor were only a few floppies. Sure, if you have big hardware use it, but don't waste it. Programmers are just getting slack and including (literally) everything in the world, and not writing anything for themselves. They aren't looking to optimize stuff, just to kick it out and make money (obviously open source isn't guilty of the money or the fast kickout thing)...

    --
    Tibbon
    tibbon.com
    1. Re:Efficiancy in OS programming needed by Zaiff+Urgulbunger · · Score: 2, Insightful

      It'll go full circle at some point. A kind-of-example, might be PalmOS in so far as it is wildly stripped down and slim when compared with WindowsCE. The problem is that it costs at lot to develop really beautifully engineered code. Some day it'll happen though - like a nice, tight office suite that loads ridulously quickly and does everything you want.

    2. Re:Efficiancy in OS programming needed by coupland · · Score: 5, Insightful

      Unfortunately my take on this situation is a bit more sinister. Your post mentions that NT 5.0 (Windows 2000 Pro) requires 64M of RAM, yet NT 5.1 (Windows XP) requires 128M of RAM. Why the twofold increase for a minor upgrade? Well, consider two things:

      1. Windows XP was released during one of the slowest hardware sales slumps in PC history. All the big players were hoping to see XP spur sales. Not coincidentally, for many people XP required a new PC.
      2. Microsoft can only stand to benefit from these PC sales in the form of OEM licenses.

      Yes I'm cynical but I've always been of the belief that the bloat in XP is engineered, not the simple result of bad programming. To think that the project managers and marketing don't talk about these sorts of things is naive

    3. Re:Efficiancy in OS programming needed by Fastolfe · · Score: 4, Insightful

      I think a lot of it is due to pressure to get a product out. Developers are relying exclusively nowadays on high-level languages, even in OS design, and those that write the compilers don't spend as much time on getting good, compact, precise and optimized code out of high-level code. Nobody cares. CPU is cheap, hard disk is cheap. Why should they work to make their stuff efficient when they can just claim their product is so advanced it requires twice the resources.

      Part of it also lies on the shoulders of developers. A lot of developers today are simply programmers that learned C in high school. They have little understanding of machine languages, assembly, or the CPU architectures they're coding for. They know just what the high-level languages look like and one or two ways of accomplishing their goal. What they need to know is how their software design decisions actually get implemented by the assembler and executed by the architecture. Memory efficiency never even crosses their mind. Who wants to pay for programmers that actually know their shit when they can just claim their product is so advanced it now requires four times the resources?

      Perhaps this is another area in which OpenSource software can shine some day...

    4. Re:Efficiancy in OS programming needed by timeOday · · Score: 2
      My experience with Linux has been different. Until recently I was running a 486 100 laptop on 48 megs of ram (quite a bit for such an old laptop). I found that newer Linux kernels (2.4 series) actually ran BETTER than the old ones; seemed more responsive. I couldn't use XFree86 4; for some reason it wouldn't work. But 3.x worked fine. And of course fvwm2 is fast on anything. Applications? I mostly used it as a remote desktop (using 802.11b) and in this capacity it could host Mozilla etc. just fine. Ocassionally I needed to go mobile and found that emacs, octave, scheme, etc. etc. worked fine.

      Windows 2000 on a 64 meg 233 mhz laptop, on the other hand, is agony. The hard drive just spins and spins. The top memory hog is explorer.exe, even when I'm not running the web browser. I can't figure it out; Windows NT didn't hog RAM like that.

      Anyways, I'm not saying OSS is inherintly more memory-efficient, just that it's much more modular; you can choose to run a GUI, or not. You can choose Mozilla, or opera or lynx (whereas, as I said, Windows 2000 seems to integrate some part of the browser with the shell (?). If I'm wrong, please tell me how I can make Windows 2000 run better on my 64 meg laptop!)

    5. Re:Efficiancy in OS programming needed by eggstasy · · Score: 2

      Awesome games still fit on a floppy. Bridge-Builder is less than 150k I think and its sequel Pontifex is less than one meg.Both of them are 3D OpenGL games for building bridges. On especially large bridges they slow down my 1333 Tbird like nothing else ever has due to their realistic physics model.
      Go check them out at the company's website, www.chroniclogic.com or a very popular fansite www.bridgebuilder-game.com - Their next game, Pontifex 2, will be 20 megs and feature a Linux version. Can't wait for it to be released!

    6. Re:Efficiancy in OS programming needed by Kashif+Shaikh · · Score: 2, Insightful

      Yes I'm cynical but I've always been of the belief that the bloat in XP is engineered, not the simple result of bad programming.

      Woah...isn't "engineering" and "bad programming" synonymous to Microsoft? Look at all the stuff they engineered over the years!

    7. Re:Efficiancy in OS programming needed by flossie · · Score: 2
      My theory is that Microsoft is absolutely correct in the minimum requirements for running the OS. But when they say minimum, they mean OS only.

      You may well be right, but what is the point of running an OS if you can't run any applications? The OS is there to support the apps. Not many people buy a computer just to load an OS.

    8. Re:Efficiancy in OS programming needed by rnd() · · Score: 2
      Some of the other posts below border on the bizarre and discuss conspiracy theories, so I'll reply to yours:

      Think of all of the processing power and lines of code that go into the little gui effects in Windows XP or KDE. Think of the extra clock cycles and bytes of code required to run a ReiserFS filesystem than to run a minix filesystem.

      Some people's ideal would be to have everything written in assembly. In my opinion, languages like Java, LISP, Objective C, and C# allow for much greater efficiency in the programming and design of systems, but at some cost in terms of the overall efficiency of the code. Despite this, Common Lisp and any of the other languages mentioned above can do many things as fast as well-written C, and even faster than the kind of C written by many programmers.

      In order to make higher level languages practical, the hardware has to be capable of more than if it only had to run well-written assembly.

      Of course, some people like to see their menus animated, etc., and that is a residual effect.

      --

      Amazing magic tricks

    9. Re:Efficiancy in OS programming needed by rnd() · · Score: 2
      You are way too cynical for your own good. Next thing you know you'll be sitting in a log cabin somewhere writing a manifesto. But seriously:

      Of course companies like Dell are happy to hear that Microsoft is coming out with a new OS that will require more hardware... they'd be stupid not to.

      Likewise, I'm sure that Linus, the developers of Apache, and anyone who uses Linux is pleased to hear that bigger/better hardware is coming out because it brings Linux one step closer to winning at the enterprise level.

      Sure, Microsoft puts a fair bit of fluff into Windows XP. I'm talking about heavily animated menus, menus that "forget" about programs you haven't used in a while, etc. But don't think for a moment that Windows XP doesn't solve MANY of the problems that exist in Windows 95, 98, and ME. Doing all this and maintaining compatibility does require a lot of code and a fair bit of bloat.

      Yes, if you're upgrading from Windows 98 to Windows XP then you'll likely need a new PC, but for what you're getting it's money well spent. NT5 and newer have been pretty solid operating systems, and running them takes decent hardware. Please don't tell me that you're under the impression that that old machine that's running Windows 98 is going to be able to easily handle the latest RedHat or Mandrake and XFree 4.2?

      --

      Amazing magic tricks

    10. Re:Efficiancy in OS programming needed by mcrbids · · Score: 2

      Remember when awesome games could fit on a handful of floppies?

      Pull out those floppies, and load the game. You'll see why 4x the RAM isn't so unreasonable! The "old favorites" by today's standards suck.

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
    11. Re:Efficiancy in OS programming needed by coupland · · Score: 2

      Actually, I think you need to be more cynical, to suggest XP bloat wasn't engineered is highly, highly implausible. For this to happen we need to assume that the big-wigs in Redmond got into a room together to discuss a major slump in OEM sales and the following two questions were never asked:

      1. "Could this possibly be related to the massive PC purchase slump affecting everyone in our industry?"

      Also, no one asked:

      2. "I wonder if there's any way we can fix the problem?"

      To suggest that companies have this sort of fatalistic "we're screwed and there's nothing we can do to fix it" mentality is simplistic at best. Do you honestly think companies don't have these discussions?

    12. Re:Efficiancy in OS programming needed by rnd() · · Score: 2
      I still don't buy your argument. If you buy a new PC from an OEM, you get a copy of the latest Microsoft OS included.

      What you really appear to be saying is that you think most consumers are sheep who see an ad for Windows XP and run out and spend their money on a new PC that they don't need.

      Of course Microsoft wants to sell as much software as possible. That's why they keep putting new features and functionality into it. They do sell a lot of software via hardware OEMs, but a lot is sold directly to businesses.

      If all you needed to do to get the additional functionality was pay $150 for a new copy of windows, why would Microsoft be so stupid as to effectively make the cost of having the new features be $150 + the cost of a new pc? This multiplies the price by a factor of 7 to 10 in most cases.

      Sure, Microsoft is glad to have companies like Dell, Gateway, and HP mass producing x86 PCs pre-loaded with Windows... these companies advertise and support the hardware at a much lower profit margin than Microsoft has on its software.

      Your argument just doesn't make economic sense. If I sell software and profit ONLY from software sales, why would I force you to pay for additional products in order to use that software? If the software is salable on its own, then your argument fails. If Microsoft could sell its software to run on bigger/better hardware, then your agument fails again. And if Microsoft sells the software at roughly the same price as the previous version, then your argument fails again.

      --

      Amazing magic tricks

    13. Re:Efficiancy in OS programming needed by coupland · · Score: 2

      >If I sell software and profit ONLY from software sales, why would I force you to pay for additional products in order to use that software? If the software is salable on its own, then your argument fails.

      No, this is in fact the strength of the argument. Picture it like this: you go out and buy Windows XP because you're an average Joe and think it's the only way you can use your new digital camera, and after all, Microsoft is promising you it's faster than all previous versions of Windows. (A whole thread in itself...) You get it home and realize it's slower than snot on your Pentium 400. So what do you do? Either you write off the $150 for the software or you go buy a new computer. When you buy the new computer, guess what? You buy a second copy of XP!

      Now I know what you're thinking, no company can afford to be so contrarian and abusive to users. To knowingly force you to buy two copies of their product. But they can. Microsoft is a monopoly and knows it. They know you can't take your toys and go home. You want a computer? Buy Windows. For the average Joe there is absolutely no choice.

      And lastly, Microsoft profits directly from hardware sales, you can't oversimplify by calling them a software-only company. Because they force every PC to be shipped with an OEM license. Hence hardware sales are part of their bottom line.

  25. That goes to show those C bigots by Anonymous Coward · · Score: 2, Insightful

    You know -- the bullshitters that say: "Optimizing C compilers write small/better/faster code than hand-tuned assembly."

    Hand-tuned assembler is always faster/smaller/better than C code, except when it comes to portability.

    And this just goes to show that fact again!

    1. Re:That goes to show those C bigots by Waffle+Iron · · Score: 5, Insightful
      Hand-tuned assembler is always faster/smaller/better than C code, except when it comes to portability.

      Maybe in theory. In practice, once your program gets too big to fit it all in your head at once, you're going to run out of the mental energy required to stay ahead of the C compiler (and remain bug-free).

      If you've disassembled the output of a good optimizing compiler lately, you'd see that it usually produces pretty good code. Except for the inner loops of numerical algorithms, I doubt that anyone will consistently be able to produce code that is more than 25% faster than the C compiler.

      The thing is, the compiler is able to spit out this code at thousands of lines per minute all day long. It doesn't get tired. The human programmer is going to get tired of the boredom, and will start creating higher level abstractions in assembly. He'll start using macros. He'll use a simplified parameter passing protocol so that he doesn't have to inline and hand-allocate the registers for every little subroutine call.

      Before long, he's fallen behind, and the C code will run faster overall. And the C program will have taken less time to write, as well.

    2. Re:That goes to show those C bigots by p3d0 · · Score: 2

      Obviously, a human can write any code a compiler can given enough time and effort. I think realistically, what is more important is that time spent on improving compilers will provide more benefit to more software than time spent rewriting that software in asm by hand.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    3. Re:That goes to show those C bigots by pclminion · · Score: 2
      If you've disassembled the output of a good optimizing compiler lately, you'd see that it usually produces pretty good code.

      Indeed. Try looking at the gcc-optimized assembly for the following:

      x ^= y;
      y ^= x;
      x ^= y;

      It may not be immediately obvious, but if you work it out you'll see that this swaps x and y.

      The compiler, of course, figures this out and just uses an XCHG instruction (on x86, at least).

    4. Re:That goes to show those C bigots by jpmorgan · · Score: 2
      Nice troll. I like how you conclude that since the smallest ELF executable is written in assembly, assembly coders are better at writing fast code than optimizing compilers.

      Optimizing C compilers don't produce smaller code, and I don't know anybody who claims they do. They're optimizing for speed, size is rarely a significant concern. Writing fast assembly these days is a lot different from what it used to be, and a lot of speed penalties and gains are very non-obvious and requires a highly detailed understanding of the way the processor is implemented. The guys who write optimisers tend to know these, but in my experience most so called assembly programmers don't (although there are notable exceptions).

  26. Smallest possible size by SeanTobin · · Score: 2

    Now, the author has to shrink the cluster size of his hard drive, and make up some new indexing structure that is more efficient so any shrinking of the executable actually matters.... It doesn't help if the executable is 32 bytes or 4096 bytes if you only have 4k clusters, you're still eating the same amount of space.

    --
    Karma: SELECT `karma` FROM `users` WHERE `userid`=138474;
    1. Re:Smallest possible size by mikewas · · Score: 2

      Not when it's executing in memory. I've yet to see RAM with clusters.

      --

      "Glory is fleeting, but obscurity is forever." --Napoleon Bonaparte
    2. Re:Smallest possible size by FredGray · · Score: 2
      Not when it's executing in memory. I've yet to see RAM with clusters.

      Well, they're typically called "pages" in that context: the minimal unit of virtual-to-physical address mapping. On x86 Linux, the page size is 4096 bytes.

    3. Re:Smallest possible size by kscguru · · Score: 2, Informative
      No, but RAM has pages. 4K on x86, as I recall. You can't pull anything smaller out of the kernel - though you could pack it into another process's address space (but that defeats the purpose of a small executable anyway).

      And no, you can't change the page table size, it's hardware-dependent. Most of the other archs seem to have similar or larger pages, too.

      Why do I know this? It's "write your own VM" month in my OS class. Next week we get to start swapping out to disk...

      --

      A witty [sig] proves nothing. --Voltaire

    4. Re:Smallest possible size by SeanTobin · · Score: 2
      ...assuming you're using a file system that only permits a single file's data in one cluster. There are more intelligent file systems out there.
      such as? All the filesystems I know of divide the hard drive into portions and assign one or more of those portions to each file. Even the newer database driven filesystems do this. Weather they are called clusters, or inodes, the result is the same. Of course, I'm only familiar with the more mainstream filesystems... I'd love an example of a filesystem that did something differently.
      --
      Karma: SELECT `karma` FROM `users` WHERE `userid`=138474;
  27. nasm by elykyllek · · Score: 3, Informative

    The nasm assembly compiler site that he mentions in the article seems /.'d, theres a sourgeforge project site instead.

  28. Re:Largest? by FreeLinux · · Score: 2

    WIN2KSP3.exe 124.68MB
    GW6SP2M.EXE 302.10MB
    Favorite_ISO.zip.exe 700MB

  29. Even smaller by ggeens · · Score: 3, Interesting
    :
    w

    The colon on the first line is an older version of the #! line, but only works for sh. And of course, `w' is one character less than `ls'.

    On systems that automatically use /bin/sh on unknown files, the smallest possible shell script is:

    w

    Yes, a single character.

    --
    WWTTD?
    1. Re:Even smaller by cjpez · · Score: 2
      Ah, but then you've gotta take into account the size of the shell running your one-character shell script. On my system, /bin/bash (/bin/sh is typically just a symlink to bash nowadays) is 588340 characters. Plus your shell script is, in turn, executing /usr/bin/w, which in turn on my system is 8932 characters.

      You might say, "that's not fair, it gets run, doesn't it?" Well then try running it pedantically:

      $ /lib/ld-linux.so.2 your_script
      Doesn't work so well anymore, does it? :)
    2. Re:Even smaller by ShavenYak · · Score: 3, Funny

      On systems that automatically use /bin/sh on unknown files, the smallest possible shell script is:

      w
      Yes, a single character.


      Actually, a zero-byte file will work as well. Granted, it doesn't do much. But at least it is guaranteed to be bug-free.

      --

      Hey kids, there's only 5 days left 'til Yak Shaving Day!
  30. 32 byte run-length decompressor? by Zaiff+Urgulbunger · · Score: 2, Interesting

    I remember years ago writting a run-length decompressor in Z80 asm that was 32 bytes. I think the compressor was 50 something bytes!

    I also recall adding up the clock cycles for all of this to try and find the fastest implementation!

    I'm over it now though!

    I'm just glad to forget those cassette-tape based, hand coded assembler days, but it is kind of a shame to see how bloated code has got. If only I'd had a macro-assembler on my Sinclair ZX Spectrum (Timex something or other in the US) in those days... oh the world could've been mine!!

  31. Of course shortly thereafter... by 4minus0 · · Score: 3, Funny

    Linus wept.

    linuxdoc.org
    Chapter 11
    Verse 35

    --
    You've got an easy breezy wind at your back...most of the time.
  32. proccessing in today's world by eng69 · · Score: 5, Funny

    The current state of elf proccessors demands an astounding amount of system resources. When combined with dwarf co processor, it provides for unparalleled carnie access.

    1. Re:proccessing in today's world by El_Nofx · · Score: 2

      His first post everybody! Give him a round of applause for nailing a 5.

      --
      It's not the OS it's the user that sucks. If it's user friendly, you get stupider people. - clinko
  33. its not executable size that matters by Capt.+Beyond · · Score: 2, Interesting

    Its not so much the executable size that really matters (when talking about bloat), its the memory consumption of the program that really matters.I could write a very small program size wise that would drain your memory and crash your system, or make it slow down to a crawl.

    --
    -- "Perceptions create reality. By changing your perceptions you change your reality."
  34. MenuetOS by jaaron · · Score: 4, Interesting

    On a similar topic, MenuetOS is a full OS written in assembly and fits on a floppy. Yeah, lots of OS's used to fit on floppies, but it's still cool. It's amazing what all you can fit into a small space if you're careful.

    --
    Who said Freedom was Fair?
  35. On bloatnesses by Ektanoor · · Score: 4, Insightful

    Well this reminds me the golden days of DOS (not Denial Of Service but Disk Operating System... well, anyway it didn't made a difference). Back then people fought for every bit of code. And assembler was as popular as C or Pascal.

    However, using assembler this way is not the most optimal resource. Frankly this piece of code is only useful if you need some real tiny program and you are running out of space and speed. But, today, 99.99...% of tasks don't need it. The optimal way to use such tricks is to concentrate in tasks that really need "the best and fastest code ever". These are drivers and situations where speed's price costs gold. Usually this is done by injecting the necessary asm directives into C or any other language. Writing everything in pure Assembler is unpractical and the result may become harder to understand than the Rosetta Stone.

    However the article is making a point - how unoptimised are the present compilers. For example, GCC is mostly C in C. It makes it highly portable, but, if anyone decided to repeat Turbo Pascal feat (most of its base code was Assembler), I know that binary code would shrink to the impossible. Right now we may not be feeling this drawback as bloatness still doesn't clog everything. In the future this situation may change if speed and reliability turn to higher priorities.

    Some note for the bloat FUDders: This is not a reason for Linux distros being bloat. First learn to be rational on your needs and don't install everything in one box. Second, learn a little bit of administration, maybe some programming and kick that (mega_kernel) + (some_highly_featured_libs) + (several_unuseful_apps) out of your box. Then you will know that Linux can help fry eggs on your processor with lightning speed. Till then, keep the flame for yourself and read "Why I switched from Mac to Windows".

  36. i love this by sysrequest · · Score: 2, Insightful

    it may not be all TOO practical, since a lot of people try to ensure that their program runs on multiple architectures and platforms, but I also miss the old (DOS) days when the demo scene tried to optimize their intros to fit a half an hour of entertainment into 64k, with full sound blaster support. the registers of the vga cards were abused to no end, lightening fast assembler procedures were optimized either for size, or for speed by unrolling loops, etc.

    while that isn't practical anymore these days, a LOT of code has become very sloppy. More than once have i stumbled over some college kids c app that was supposed to demonstrate linked lists, and instead, it was using one class with an array.

    programming is an art, like acting. many try and are good enough for some purposes, but only a selected few are masters. sounds pretty damn philosophical, don't read too much into it :)

  37. Could be used to make "true" smaller. by hey · · Score: 3, Funny

    On Red Hat 8.0 I get:

    $ wc -c /bin/true
    9752 /bin/true

    That's thousands of extra bytes - eek.

    1. Re:Could be used to make "true" smaller. by Jeremy+Erwin · · Score: 2

      I seem to recall that GNU true responds to the "--help" flag.

      On MacOSX:
      wc -c /usr/bin/true
      9572 /usr/bin/true

  38. People are missing the point by Kenneth+Stephen · · Score: 5, Insightful

    Looking through the comments here I see two main threads : (1) Squeezing out the last few overhead in a program leads to hard to understand / maintain program and thus is not worth the effort. (2) Whats the big deal anyway in this era of 100 GB disks and 2GHz processors?

    While both these criticisms are valid, they miss the point. Firstly, it wasnt the objective of the author to squeeze the last few bytes out of that program to save resources. He was just putting his hard-earned knowledge to use. He was doing it because he could! This is the same motivation for people who climb mountains : because the mountain is there, and because they can climb it. Indeed, if the author were seriously looking into saving resources, he'd hardly be wasting his time on a trivial program, would he?

    Secondly, one of the authors intentions was to demonstrate the limits to which austerity could be taken to. Certainly, this was a trivial program - but the same principles could be used to shrink larger non-trivial programs, and it those cases, the savings could possibly be larger. Of course, it those cases, the largest savings would come from a good optimizing compiler rather than crunching the headers together. More importantly, the author has exposed whole new ideas and lines of possibilities to programmers.

    --

    There is no such thing as luck. Luck is nothing but an absence of bad luck.

  39. Excellent troll! by PurpleFloyd · · Score: 4, Insightful
    Linux software is horribly bloated, like even "ls" is above 30k
    ls is probably statically linked (all necessary libs reside within the executable), so it will function in almost any circumstance where the executable itself is not corrupted. Would you really want to try to repair a broken system without ls? Most critical utilites and shells are available in statically-linked forms (if not, you can do it yourself). While executable size is an important consideration, it isn't the only one. I would rather have a set of basic programs (like ls) that work even if all the lib directories are toasted, than to save a few K here and there, and have a system that could never pull itself back up if broken.
    --

    That's it. I'm no longer part of Team Sanity.
    1. Re:Excellent troll! by DeeKayWon · · Score: 5, Informative
      Funny. My /bin/ls (Debian unstable) is nearly 60k, yet is dynamically linked, and is even stripped.

      % ls -l /bin/ls
      -rwxr-xr-x 1 root root 59592 Oct 8 20:17 /bin/ls*

      % ldd /bin/ls
      librt.so.1 => /lib/librt.so.1 (0x40022000)
      libc.so.6 => /lib/libc.so.6 (0x40034000)
      libpthread.so.0 => /lib/libpthread.so.0 (0x40147000)
      /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

      % file /bin/ls
      /bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), stripped
    2. Re:Excellent troll! by rplacd · · Score: 2, Interesting

      > Would you really want to try to repair a broken system without ls?

      I've had to -- echo * works well enough, sometimes. Some Linux install disks give you a shell, but few utilities other than mount, mknod, cat, etc. Now, if they gave us ed I wouldn't have to "cat >> /mnt/etc/fstab" and the like.

      If you search the FreeBSD freebsd-hackers mailing list, you'll even find a "more" command implemented with shell builtins (at least, I don't remember it using cat). It's too long to remember, though.

    3. Re:Excellent troll! by Dahamma · · Score: 2, Insightful
      Can't believe this was modded up to 5!

      The first post called Linux software bloated (oh come on, glibc is VERY bloated - try using at uclibc or dietlibc - they don't have 100% of glibc's functionality, but for embedded systems it's amazing how much space they save) and it's a troll?? Then he makes a statement that starts with "probably" and turns out to be wrong - Debian and RedHat 'ls' definitely link with several libs. I won't say "probably", but who wants to bet on how many of the other major distros do as well?

      Ok, to put something less whiny in my post - if you're worried about having a functional set of utils for emergency use, install busybox. For ~800k statically linked you get a ton of utils in a multicall binary, along with a shell. Available from the RedHat install CDs, in fact.

    4. Re:Excellent troll! by ShavenYak · · Score: 3, Funny

      Is that why it took Deep Thought so long to execute it?

      --

      Hey kids, there's only 5 days left 'til Yak Shaving Day!
    5. Re:Excellent troll! by Tony+Hoyle · · Score: 2

      Repair a broken filesystem without ls?

      echo *

    6. Re:Excellent troll! by Tony+Hoyle · · Score: 2

      > Some Linux install disks give you a shell, but
      > few utilities other than mount, mknod, cat, etc.
      > Now, if they gave us ed I wouldn't have to "cat
      > >> /mnt/etc/fstab" and the like.

      Boot knoppix - you get a fully installed KDE desktop... (OK overkill I know).

    7. Re:Excellent troll! by Tet · · Score: 3, Interesting
      I've had to -- echo * works well enough, sometimes. Some Linux install disks give you a shell, but few utilities other than mount, mknod, cat, etc. Now, if they gave us ed I wouldn't have to "cat >> /mnt/etc/fstab" and the like.

      For probably the ultimate description of recovering from a screwed system without access to the normal tools, see Al Viro's inhuman heroics here.

      --
      "The invisible and the non-existent look very much alike." -- Delos B. McKown
    8. Re:Excellent troll! by FooBarWidget · · Score: 2

      ls does more than simply listing some files! Try ls --help. It supports sorting (by name, size, time, etc.), coloring, display sizes in different formats, display control, recursive listing, show/hide backup/hidden files, etc. etc. The 30 KB is completely justified when you look at all the features! This is the Unix philosophy: do only one thing, but do it [b]as well as you can[/b].

      Really... 30 KB is "bloat"? Hello? What's 30 KB compared to 80 GB? Everquest, which takes more than 1 GB on your harddisk, now THAT's bloat!

    9. Re:Excellent troll! by vidarh · · Score: 2

      Of course if you're running bash or another shell with tab expansion, all you really need is to type a character or two and press tab twice.

  40. It doesn't save any disk space by Gerry+Gleason · · Score: 5, Insightful
    Below the filesystem size quantum, you don't save anything anymore. You can't allocate less than a page of memory either.

    Beyond some point, the article is really just silliness, interesting or not. Below 512 bytes, your not going to save anything on any system. Ok, there are filesystems that compress things further for squeezing into flash memory and such, so maybe there are some marginally useful applications, but still the header overlapping is a bit much to be worth considering.

    1. Re:It doesn't save any disk space by p3d0 · · Score: 5, Informative
      Consider:
      1. If you compress these things onto a floppy, every byte counts.
      2. Some filesystems like ReiserFS use tail packing to put multiple files (or file tails) into a single block.
      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    2. Re:It doesn't save any disk space by mirabilos · · Score: 2

      Try romfs then. I built a GNU/Linux distro in 2000
      which used romfs and ext2fs (only because xiafs is
      orphaned) natively and could be installed into a
      ext2fs partition or a loopback-root image on, e.g.
      a FAT partition.

      Maybe I'll upload it one time.

      --
      My Karma isn't excellent, damn it! (And /. still does not get UTF-8 right in 2012. Wow.)
  41. 4K Demos by Wraithlyn · · Score: 5, Interesting

    Some of the 4K demos I've seen written for ASM competitions completely blow my mind... check out this one, it's basically a flythrough of the first level of Descent, with texture mapping, source lighting, animated lava and recharger field, a MIDI soundtrack, etc... all in 4095 bytes!!!

    Here is Sanction's home page, it contains a couple more very impressive 4K demos.

    --
    "Mind, as manifested by the capacity to make choices, is to some extent present in every electron." -Freeman Dyson
    1. Re:4K Demos by Ektanoor · · Score: 3, Informative

      The Demo scene had always beat the usual coders. Not long ago we had a national festival with guys coming all over from Russia. Some demos, mainly Amiga and Spectrum, were impressive. Some 3D effects were shown on machines that lack any types of acceleration. And these things ran nearly with the same speeds we frequently saw in some powerful Pentiums. Besides, the PC demo presented things shrinked to the impossible with a speed, sound, space and color effect that beated many popular games.

      I wonder the speed and the effects some Doom III would have if it was written mainly in Asm...

    2. Re:4K Demos by Wraithlyn · · Score: 3, Interesting

      Do you remember Future Crew? And the legendary Second Reality demo of '93? (Available here, but can be hard to run properly on modern systems) Apparently many of those guys are now working at Remedy... which may explain why Max Payne is such a graphically beautiful game... I wouldn't be surprised in the slightest if the Max FX engine employs some nice ASM routines. Also, check out their Final Reality benchmark, the final "cityscape flythrough" is a homage to a nearly identical (albeit flat shaded) sequence in Second Reality. Cool shit.

      --
      "Mind, as manifested by the capacity to make choices, is to some extent present in every electron." -Freeman Dyson
    3. Re:4K Demos by /dev/trash · · Score: 2, Insightful
      I wonder the speed and the effects some Doom III would have if it was written mainly in Asm...

      I wonder if we'd even HAVE Doom III now if it was written in asm.

    4. Re:4K Demos by scrytch · · Score: 2

      > Apparently many of those guys are now working at Remedy

      First thing I thought was "damn, I can't think of a bigger mismatch than demoscene coders working for Remedy Corp" ... yah I think in HTML :)

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    5. Re:4K Demos by Broccolist · · Score: 2
      I wonder the speed and the effects some Doom III would have if it was written mainly in Asm...

      It would just take a lot longer to write. The reason demo efficiency blows the socks off anything in games is because demos are specifically designed to render a single scene and nothing else, not because demo coders are that much better at optimization than game coders (they are often the same people). What makes the difference is the various hacks demo programmers can pull off because they only have to worry about a single situation.

      Anyway, with the advent of 3d accelerators, the whole scene has become rather meaningless --- the bottleneck of Doom 3 will be your GPU, not the efficiency of the x86 asm.

  42. What about the Visual Studio .NET compiler? by Jugalator · · Score: 5, Interesting
    Stand-alone console EXE (Release Build):
    #include "stdafx.h"

    int _tmain(int argc, _TCHAR* argv[])
    {
    return 42;
    }
    Size: 20,992 bytes

    To be compared with the non-optimized gcc version at 3,998 bytes. :-)

    I wonder how small you can make a Windows EXE..
    --
    Beware: In C++, your friends can see your privates!
    1. Re:What about the Visual Studio .NET compiler? by Jugalator · · Score: 5, Interesting

      Hm... I stripped the code from stdio.h, replaced _TCHAR* with char* so the stdafx.h doesn't really do much at all. Then turned on size optimizations and turned off boundary checks etc in the compiler. Still exactly 20992 bytes. Huh?? Browsed the exe and there's full text messages like "ooh something corrupted the state of this program and it cannot safely continue". Which is actually a great addition by Microsoft, but can't you remove such things? :-)

      But I guess the .NET compiler has its lower limits where bloat get called feature, just surprising that it seems to compile at the minimum size by default... Or perhaps it use some kind of silly padding so even if there's less code, the physical size isn't reduced.

      --
      Beware: In C++, your friends can see your privates!
    2. Re:What about the Visual Studio .NET compiler? by djmurdoch · · Score: 2

      I wonder how small you can make a Windows EXE.

      Windows supports 3 or 4 different formats of .EXEs. The oldest format (what used to be .COM programs in DOS) lets you write that program in 5 bytes, B8 2A 4C CD 21. (Maybe less, my DOS programming skills are a little rusty.)

  43. Any program can be written using one less byte by shoppa · · Score: 3, Funny
    It's a well known fact that
    Any program can have at least one reduncdant byte removed or optimized away and still function

    In fact, just apply this fact iteratively and you'll find that any program can be written in zero bytes!

    1. Re:Any program can be written using one less byte by Anonymous Coward · · Score: 2, Funny

      furthermore, it is well known that any program will inevitably have at least one bug.

      hence, we can deduce that *all programs can be reduced to a single byte... which won't work!*

    2. Re:Any program can be written using one less byte by Eythian · · Score: 2, Funny

      Any program can have at least one reduncdant byte removed or optimized away and still function

      Actually, I believe it is this:

      Axioms:

      1. Every program can be shrunk by at least one intsruction.
      2. There is always one more bug.

      From this, we can conclude that any program can be written as one byte that doesn't work.

  44. A great site concerning this theme by cvore · · Score: 2, Interesting

    www.linuxassembly.org/ - Go there, its free and fun :-)

  45. asmutils does a good portion of this by cgleba · · Score: 5, Informative

    http://linuxassembly.org/asmutils.html

    Check it out, download it and assemble it.
    They create the smalles set of binaries for the basic linux tools that I have found and they employ a good portion of the stuff mentioned in this paper.

    They make busybox look bloated by comparison.

    Another neat trick is to use the ld options "-Wl, gc-sections" when linking a static binary -- it tries to weed out all the unused portions of the libraries it links against.

    The last trick I usually use is to link against uClibc or dietlibc rather then glibc. Makes a noticeable difference. RedHat has been working on a program called "newlib" which is supposed to do the same thing as uClibc or dietlibc but better (for embedded stuff).

  46. auuugh! by quarter · · Score: 3, Funny

    where's your spoiler alert?!!?!?

  47. Tiny Programs that Suck Memory by duck_prime · · Score: 2, Funny
    [...] I could write a very small program size wise that would drain your memory and crash your system, or make it slow down to a crawl.
    Dammit Gates, I *told* you to stop posting here!
  48. My priorities by sjbe · · Score: 2
    This is what I want in a program in rank order. Please note that this is speaking from the standpoint of someone working/programming primarily with general purpose computers, not embedded system, supercomputers, etc. Nor is this an exhaustive list, it's just generally what I want to see.
    1. Functional. If if the program doesn't do what it is supposed to do, nothing else matters.
    2. Reliable. The program should do what it is supposed to do predictably and without crashing.
    3. Easy to use & easy to learn. Kind of a tie, depending on what I'm doing and how much I use the program. I should not have to memorize a huge command set. (though if appropriate it should be an option) Blind navigation spaces should be avoided whenever practical but available if appropriate.
    4. Maintainable. If the programmers can't fix problems or update things, it is unlikely to remain useful. As an end user this is not something I'll see except as the program evolves. Being maintainable for the programmer should NEVER overshadow the importance of a good user interface. A bad interface wastes my time. However, if the program is maintainable, it is likely that problems can be addressed so this maintainability is very important.
    5. Speed. Performs requested functions quickly. Obviously desireable, but not at the expense of the above.
    6. Minimal resources. Uses as little computer resources as appropriate, given the other constraints. I don't really care how small a program is if the system it is running on can handle it and it doesn't interfere with my work.

    Tiny, compact code is neat but I don't care about it. Folks here complain about bloat constantly but unless a program's size is actively interfering with your ability to do work and the program's functionality (and I don't mean taking an extra 2 seconds to load) who really cares? If it won't run on your machine, that is one thing. If it's just big, there are probably more important things to worry about. For example I don't really care that Mozilla is big compared to some other browsers. My machine can handle that and it's speed is adequate to my needs. I do care that the program is functional, reliable, easy to use and maintainable, which fortunately it is.
    1. Re:My priorities by p3d0 · · Score: 2
      Tiny, compact code is neat but I don't care about it.
      Then don't read the article, genius. The author is shrinking executables because it's fun and he's learning something, not because he thinks it's the best software engineering approach.
      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
  49. Small size != More efficient by yorgasor · · Score: 5, Insightful

    Just because a program or executable file is smaller, doesn't necessarily mean it's more efficient. For instance, some compiler optimizations actually produce larger executables. If you unroll a loop, it actually generates code for each iteration of the loop, but saves time because it's faster to keep going forward than to branch backwards to run through the code again.

    Similarly, you can have inline functions that insert the inline function directly into the function calling it. Every function that calls an inline function would get a copy of it, which produces larger code, but saves a lot of time since it doesn't need to push the arguments on the stack, branch to the new function, and return with the value.

    Finally, the biggest speed gains you can get are generally algorithmic in nature. You can do a bubble sort with just a few lines of code. It's a lot simpler code and smaller than the larger and more complicated quick sort or merge sort. I know which one I'd rather wait for with a million items to sort.

    So remember, just because something is bigger, doesn't mean it's more bloated, and just because something is smaller doesn't mean it's faster or more efficient.

    --
    Looking for a computer support specialist for your small business? Check out
  50. Yes, yes. We all know Frodo was a hobbit. . . by kfg · · Score: 3, Funny

    not an elf.

    Rumors of his being a fairy persist, however.

    KFG

  51. Re:Linux zealots. by khuber · · Score: 2, Funny
    45 bytes ought to be enough for anybody.

    -Kevin

  52. Kids don't try this at home :-) by Antity · · Score: 5, Interesting

    The first few examples are quite noteworthy, but when the author starts to put code inside the ELF header, it gets really ugly..

    Saying that these bytes are "only padding anyway for future extensions" doesn't feel that good. :-)

    This remembers me of early attempts on AmigaOS to shorten and fasten executables where people could be sure that all available Amigas would only use the lower 24 bits of 32 bit address registers since the machines could only address 24 bits physically. So they put application data into the upper 8 bits of registers. Worked fine.

    Then came newer machines which really used the full set of 32 address lines and all those dirty programs crashed without obvious reason..

    The author says "if we leave compatibility behind.." but what he's doing is not only leaving inter-OS compatibility behind - what he creates isn't even an ELF executable anymore. It's just something that happens to work with this special Linux version.

    So since this isn't even an ELF executable any more, there's no reason not just to write "exit 42" in bash (which would be an amazing 8 bytes in size *g*).

    Don't misunderstand me, I really like those hacks. But I myself will never, ever again code something that is prone to break in the future just because I didn't follow standards.

    One could say that this is what programming is about. :-) No offence meant.

    --
    42. Easy. What is 32 + 8 + 2?
  53. Job Security by vena · · Score: 2, Funny

    the real reason to obfuscate through efficiency! :)

  54. Saturday, saturday, saturday! Race race! by yerricde · · Score: 2

    (context for mods) let's see... ELF... elves... races in fantasy and science fiction:

    No. Trolls

    Look at that troll. Isn't it Qt?

    are completely different creatures from hobbits and elves.

    let's see... among (semi) intelligent roughly-humanoid races, the fantasy multiverse has at least humans, dwarves, elves, hobbits, ents, weebles, smurfs, cyclopes, gnomes (pronounced g; 90 cm tall), gnomes (silent g; 15 cm tall), trolls, orcs, merfolk, selkies, marsh-wiggles, nerdlucks, jawas, tuskens, wookiees, ewoks, teeks, borrowers, morlocks, and eloi.

    Saturday, Saturday, Saturday! Watch the Race Race at the Motor Speedway!

    Be there.


    --
    define MAX_CHRISTS 5
    --
    Will I retire or break 10K?
  55. 26 bytes by bcrowell · · Score: 4, Funny
    Yeah, and now here's a thumb in the eye for all those C bigots and all those assembler bigots:

    $ cat >a.pl
    #!/usr/bin/perl
    exit(42);

    $ chmod +x a.pl
    $ ./a.pl
    $ echo $?
    42
    $ ls -l a.pl
    -rwxr-xr-x 1 bcrowell bcrowell 26 Oct 19 12:41 a.pl

    Only takes up 26 bytes on my hard disk!

    1. Re:26 bytes by Citizen+of+Earth · · Score: 2

      $ ls -l a.pl
      -rwxr-xr-x 1 bcrowell bcrowell 26 Oct 19 12:41 a.pl


      $ ls -l /usr/bin/perl
      -rwxr-xr-x 2 root 13798 Sep 2 00:16 /usr/bin/perl
      $ ldd /usr/bin/perl
      libperl.so => /usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE/ libperl.so (0x40014000)
      libnsl.so.1 => /lib/libnsl.so.1 (0x4013f000)
      libdl.so.2 => /lib/libdl.so.2 (0x40154000)
      libm.so.6 => /lib/i686/libm.so.6 (0x40157000)
      libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40179000)
      libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
      libcrypt.so.1 => /lib/libcrypt.so.1 (0x401a9000)
      libutil.so.1 => /lib/libutil.so.1 (0x401d7000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
      $ ls -l /usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE/ libperl.so
      -r-xr-xr-x 1 root 1213788 Sep 2 00:14 /usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE/ libperl.so

  56. Embedded systems need efficiency by yerricde · · Score: 4, Interesting

    CPU is cheap, hard disk is cheap.

    Maybe on PCs, but not on embedded systems, handheld systems, or game consoles. The Game Boy Advance, for instance, has only 384 KB of RAM, and all but 32 KB are 16-bit bus width with muchos wait states. Many microcontrollers inside such things as microwave ovens are as powerful as an Atari 2600 VCS, with 128 bytes of RAM and about 12 bytes of VRAM (if that).

    --
    Will I retire or break 10K?
  57. That's nothing by 0x0d0a · · Score: 2

    The author concludes, 'every single byte in this executable file can be accounted for and justified. How many executables have you created lately that you can say that about?'

    Heck, Microsoft fits that profile. Every byte accounted for? "One enormous pile of garbage."

  58. I remember this by X-Nc · · Score: 2

    I saw this years ago. Sometime in the late 90's. It's very interesting and cool stuff, thouhg.

    --
    --
    If I actually could spell I'd have spelled it right in the first place.
  59. OT: Re:What about the Visual Studio .NET compiler? by WhaDaYaKnow · · Score: 5, Informative
    Yeah, look at this example for the printf implementation:
    extern "C" int __cdecl printf(const char * format, ...)
    {
    char szBuff[1024];
    int retValue;
    DWORD cbWritten;
    va_list argptr;

    va_start( argptr, format );
    retValue = wvsprintf( szBuff, format, argptr );
    va_end( argptr );

    WriteFile( GetStdHandle(STD_OUTPUT_HANDLE), szBuff, retValue,
    &cbWritten, 0 );

    return retValue;
    }
    Gosh, I wonder how come M$ has so many problems with secoority. 1024 bytes on the stack, without overrun checking. Wonderful stuff indeed.

    You may say, yeah but how often will you printf more than 1024 bytes? Exactly,- practically never. Which is why this sort of crap is not showing up in testing and DOES show up when people are trying to crack it.
  60. Several things by Sycraft-fu · · Score: 3, Informative

    1) The increase in OS requirements is partially due to the increase in OS functions. XP provides a lot more eye candy than NT, which needs more processor power to handle. You may not think it's a good idea, but most people like it.

    2) The increase in OS requirements is mainly due to an increase in software requirements as a whole. An OS is worthless if you can't run anything on it, so you need to set your requirements with software in mind. MS made this mistake with Windows 95. Yes, technically IT would run with 4MB of ram, but that wasn't enough to load anything else. XP's stated minimum isn't the actual minimum, but a practical one wheny ou account for applications.

    3) As others have mentioned, compact code comes at the price of maintainability. Sure, I can write a program in 100% assembly, and then if I'm realyl good tweak the machine code to make sure it is as efficient as possable. Now try and maintain that. This is hard enough if it's a tiny app, but if it is something large like, say, Mozilla even the orignal programmer would find matenence very difficult and anyone else would find it almost impossable.

    4) Along those line, portability requires that you code in a higher level language, and often that you make some changes that increase your code size. If you do everything in optimised assembly, well it's a one platform thing. I can gaurentee that you have to do a massive rewrite of an assembly Windows app if you want to make it run on x86 Linux just because of the API differences. If you are talking another hardware platform, then it's a total and complete rewrite.

    5) Your 64k demo thing I'm assuming is refering to the now infamous Farbrausch demos. It is simply stunning what they can get done in 64k BUT it comes at a huge price. First there is the memory usage, look at your task manager sometime when one of those is running, they use like 80MB. Because of their tiny disk usage they can to decompress to memory. Second their compatibility is horrable, their newer one FR22 works properly on my sytstem at work, but not at home, the only big difference being at home a have a geForce 4 at work I have a GeForce 3. Finally, these thigns are only made possable by the "bloated" Windows framework with things like DirectX to simplfy low level access.

    6) Most people see little point in trying to make things run well on a 386 when you can get an entire system running at over 1ghz for about $500.

  61. Small demos aht the like... by the_arrow · · Score: 2, Interesting

    I remember in the "good old days" (tm) on the Amiga, when some (well, quite a lot actually :) people managed to make small intros with sine-scrolling multi-colored text in less than 512 bytes, all done in the bootblock which also had a loader for whatever game/demo was on the disk.

    --
    / The Arrow
    "How lovely you are. So lovely in my straightjacket..." - Nny
  62. Wired 1995 by lonedfx · · Score: 2, Informative

    Wired 1995 Surprize coding compo :

    Write the smallest possible .com program that does the following :
    1, Input a number from the keyboard, call it N
    2, Go in mode 13 (vga), draw N 3x3 squares without the central pixel (N * 8 pixels to draw), no square should be adjascent to another.
    3, Wait for Enter
    4, Exit

    Results were

    1: Walken/Impact Studios, 48 bytes
    1: (ex aequo) Paranoia, 48 bytes
    2: KLF, 51 bytes

    For info, Walken's version was drawing the squares at different positions every time his program was ran (don't ask me how) :-)

    Our own attempt (aegis) yielded 52 bytes, but we were disqualified because we did not support the key "0" :-)

    ahh... fun...

    lone, dfx.

  63. bash beats perl (18 bytes) by flossie · · Score: 2

    $ cat>a.sh
    #!/bin/sh
    exit 42
    $ chmod +x a.sh
    $ ./a.sh ; echo $?
    42
    $ wc -c a.sh
    18 a.sh

    1. Re:bash beats perl (18 bytes) by FooBarWidget · · Score: 2

      Even smaller:
      $ cat>b.sh
      exit 42
      $ sh ./b.sh; echo $?
      42
      $ wc -c b.sh
      7 b.sh


      Who needs #!/bin.sh?

  64. Re:I ask out of total ignorance... by flossie · · Score: 3, Informative

    No. The 45th byte of the resultant program is required to be there as part of the ELF header (Linux won't run the program otherwise). The code which generates the value 42 occurs way before the 45th byte of the program in an unused portion of the header. In fact, the return value could be a couple of bytes longer without changing the length of the overall program.

  65. Re:I ask out of total ignorance... by flossie · · Score: 2
    But 45 bytes still beats true and false on my system (Debian):

    $ wc -c /bin/true
    9704 /bin/true

    That's 9659 wasted bytes!

  66. But wait a minute... by soulctcher · · Score: 2, Funny

    ...nobody has yet said whether the smallest elf is executable or not? I would imagine that unless he's a water bear, we're probably still going to be able to execute him.

  67. What about emacs executables ? by Billly+Gates · · Score: 3, Funny
    Its a much better os. I just wish I had a good editor on it.

  68. Re:Going for massively off-topic here but... by Nexx · · Score: 2, Informative

    "Ah, kamisama! Ore no atama ni ono ga arimasu yo!" is quite correct. To my ears, the use of "wa" makes the rhythm of the sentence quite lethargic. Though it may not be correct textbook Japanese (the use of the word "yo" already makes it conversational, and thus, some leeway in grammar is allowed), between peers, this usage will be quite acceptable.

    Yes, I do speak Japanese fluently :-P

  69. O'Reilly True In Nutshell book by truth_revealed · · Score: 2, Funny

    This one went around the internet a thousand times already, but in case you haven't seen it:

    True in a Nutshell

  70. make it even smaller by prockcore · · Score: 2

    Make it even smaller by doing this:

    cp /usr/bin/perl /p

    and editing your shabang to be #!/p

  71. Common misconception by vlad_petric · · Score: 2
    Small code != fast code !!

    While it's true that quite a few optimizations not only improve the runtime but also reduce the code size, this is not generally true. An important optimization, for instance, is loop unrolling - which more than doubles the codesize of a loop. Its purpose is to reduce the number of branches, as jumps in superscalar out-of-order processors are performance killers.

    Small executables are important for machines where the program is stored in flash (like microcontrollers). The compilers for those architectures are optimized to produce small code (as a matter of fact some of them are gcc-based). When storage is cheap, program size is rather irrelevant (keep in mind that OSs do paging, they only keep a working set of the program in memory).

    The Raven.

    --

    The Raven

  72. Misguided minimalism by Junks+Jerzey · · Score: 2

    While nostalgic, this kind of minimalism is misplaced in modern operating systems. When you write an application, even a small application, think of everything that goes on behind the scenes:

    1. Using a single function in shared library brings in the entire library.
    2. You're at the mercy of the code in shared libraries and drivers. Even if you write code in hand-optimized assembly language, what's the point when you have to call the OS or a driver in order to do graphics and I/O?
    3. There's a relatively large cluster size under most filesystems, so saving a few bytes or even a few K can often be irrelevant.
    4. Even simple things like memory access can cause interrupts during which the virtual memory system intervenes.

    All the posts about "returning to the days of performance" and all that rubbish are completely off the mark.

  73. Re:nasm? yuchhhhh! :) by vidarh · · Score: 2

    The point was that if you have binutils installed, you already have gas, and practically anyone using a Linux box for development will have bintuils installed, so why bother with nasm?

  74. A compiler developer begs to differ... by Doug+Merritt · · Score: 2
    those that write the compilers don't spend as much time on getting good, compact, precise and optimized code out of high-level code. Nobody cares.

    Speaking as a compiler developer, who as a contractor has done major compiler work in recent years for HP, Microsoft, SGI, etc, I strongly disagree.

    The speed of generated code is very important to hardware vendors (because it is essential to the speed of their hardware), to software developers (because the easiest way to get faster code is with zero effort -- buy a compiler that generates better code), and to compiler developers because they sell to the other two camps. (Or often, are also one of the other camps.)

    Sure, we all know that programmers in general don't care about speed of generated code the way we did back when it was truly critical to literally count every cpu cycle burned. But don't blame us compiler guys -- we're the good guys!

    On the other hand, you've a more legitimate complaint in talking about no one caring about the size of generated code. If you check the literature, you'll find that the almost the only famous reference on the subject of compilers minimizing code size was the landmark Bliss compiler, circa 1970.

    It's almost never been a concern. (I know there have always been exceptions to that, but I can't remember any exceptions that were famous, whereas issues of code speed are extremely famous.)

    --
    Professional Wild-Eyed Visionary