Fog Creek Software
Discussion Board




Smallest exe ?

hi,
please tell me which pogramming laguage can make SMALLEST exe, moreover it would be better if it doesn't require "runtime lib." like thing.

thanx a lot.
Sh0rt

Sh0rt
Thursday, September 11, 2003

That all depends on how small you need to go, or what you need to do.

Craig
Thursday, September 11, 2003

Short,

Purebasic is great for small, efficient exes.  It is also that
advantage of being a nice, easy language to learn.

In addition to a small tight executable, it also has commands for packing and including other resources within the executable.

Its also very affordable.  59 Euros for a full license and future upgrades.

http://www.purebasic.com

Ged Byrne
Thursday, September 11, 2003

Borland Delphi

If you use the VCL (the included library which is simply excellent) the smallest .EXE will be 400 KB.

If you don't use the VCL, and program only using Windows API, the smallest .EXE is something like 15 KB.

Darth Vader
Thursday, September 11, 2003

Sh0rt, you aren't trying to write a v1rus, are you?

Please do something useful!

Writing v1r11 is not useful!

Darth Vader
Thursday, September 11, 2003

Thanx Ged Byrne, Darth Vader
i am grateful to both of u, now i'll try both Purebasic & Delphi.
further commnts & suggestions will be alwayz welcomed, thanx once again.

Sh0rt

Sh0rt
Thursday, September 11, 2003

Short, when yur done, please be sure to let us know wear we can find yur warez on the Web, dude.

Long
Thursday, September 11, 2003

Hex!

olsson
Thursday, September 11, 2003

Your brain. Basically the more you know about windows (Win32 programming) and your application and your users, the more you can reduce the executable:

1. You can build a time bomb without the necessary assertions or with all post mortem bug reporting stripped out. You could use no icons. Forget about niceties like tooltipos and tearable drop down menus. Etc Etc. Because you happen to know enough Win32 to how to disable them.

2. You know your users enough to know when to disable them.

3. You know enough about your application to write highly optimizable code paths that you know a compiler need not auto-write a lot of code. Or you have hand written it in assembly.

Assembly is probably the smallest you can push it. But then you can make a small Python executable too. Remember, Windows XP is just a 2 gigabytes of DLL, so your Assembly executable linking to this 2 gigabyte DLL is no more impressive than a Python Program that needs no more than 2 Megs of platform-neutral DLL. The Python program will win the retail distribution war in size.

-- David

Li-fan Chen
Thursday, September 11, 2003

And you will have to distribute Python, too. :-(

BJ
Thursday, September 11, 2003

I saw an amazing 3d graphics demo in 64 K once.  I think it was written in assembler, and used Direct 3D to do the graphics.  The assembly was then compressed (the decompresser also had to be included in the 64K).  It ran for several minutes, and rotated through at least a half dozen scenes, with music. 

Keith Wright
Thursday, September 11, 2003

On www.linuxassenmbly.org there is an article about creating a 45 byte program which is certainly the smallest it is possible to create on Linux and probably any other OS as well, of course it only returns the number 42 but its one eigth the size of the standard executable header so what do you expect?

bil
Thursday, September 11, 2003

What do you mean "only" returns 42? That's the most important answer you will ever need!


Thursday, September 11, 2003

To the original poster: use any language and then apply UPX -- http://upx.sourceforge.net/

Martin Dittus
Thursday, September 11, 2003

Read this:
http://www.jrsoftware.org/striprlc.php#execomp
about UPX and other EXE compressors.

John Topley (www.johntopley.com)
Thursday, September 11, 2003

Check out the 256 byte programming contest:
http://www.256b.com/

Some amazing textured, 3d graphics in under 256bytes!

Nepherim
Thursday, September 11, 2003

The 256 byte page had a link to the exact 64k I was talking about. http://www.theproduct.de/  -- The one called .theproduct.  The other one is pretty impressive too.  It's amazing what some people can do in 256 bytes, and some people can't do in no matter hom many megs!

Keith Wright
Thursday, September 11, 2003

And you will have to distribute Python, too. :-( :

Actually no. It works kinda like VB, you'll need to bundle a library that runs bytecode. So no you don't need to distribute an entire Python development kit.

Li-fan Chen
Thursday, September 11, 2003

Since the question specified EXE, I'm going to assume Windows and no scripting.  Visual C++ 6 (haven't tried it in 7) can produce EXEs smaller than 1 KB by tweaking some options.  Playing around for a few minutes, I managed to get an EXE that does nothing other than return 42 down to 480 bytes.  I'm not going to go into further detail because of the vagueness of the question and the concerns already brought up.

SomeBody
Thursday, September 11, 2003

There are obscure assembly coders parties, like "Assembly 2002", "The Party 2002", etc.

People there present stuff like:

- 64 KB demos
- 4 KB demos (!!!!!!!!!!!!!!)

The results are usually really c00l!

Bad Blood
Thursday, September 11, 2003

Just to clarify -- the URL I provided above has coding demos of 256 BYTES -- not 256k BYTES!

Nepherim
Thursday, September 11, 2003

Any old-timers remember Beagle Bros?  It was an off-beat company that developed utilities for Apple II programmers.  In their newsletter, they always had fun little code samples written in no more than two lines of Applesoft Basic.

http://www.panic.com/~stevenf/beagle/jackzip.html

Robert Jacobson
Thursday, September 11, 2003

SomeBody,

How did you manage to have a .exe smaller than 16 Kb with VC++. It seems for me that whatever you do, VC won't generate an executable smaller than 16 Kb!

FireMode
Thursday, September 11, 2003

"On www.linuxassenmbly.org there is an article about creating a 45 byte program which is certainly the smallest it is possible to create on Linux and probably any other OS as well"

You can create .COM files, which are DOS executables. Returning 42 would be less than 45 bytes, for sure, probably more like a dozen. All you're doing it loading a couple registers and calling a DOS function via an interrupt.

Brad Wilson (dotnetguy.techieswithcats.com)
Thursday, September 11, 2003

The smallest exe has got to be something like

hlt

No, the smallest exe that does something is another story.

pdq
Thursday, September 11, 2003

Law #1: every program can be reduced in size by one instruction.

Law #2: every program has at least one bug.

By applying law #1 recursively, and introducing law #2, we derive the following theorem: every program can be optimized down to one instruction, which does not work.

Alyosha`
Thursday, September 11, 2003

FireMode,

I just found this article on MSDN that explains some of same techniques I used (plus some more that I didn't):
http://msdn.microsoft.com/msdnmag/issues/01/01/hood/default.aspx

The biggies for me were eliminating the runtime ("Ignore all default libraries" linker option and a custom entry point) and setting the linker file alignment to 4 bytes using /align:4.  Setting it this low is dubious but I didn't encounter any problems with the few things I tried (like displaying a message box).  Using the /opt:nowin98 linker option is probably much safer but will push the alignment up to 512 bytes.  I managed to get as low as 1024 with this option. 

SomeBody
Thursday, September 11, 2003

Try http://www.freepascal.org

Wayne
Friday, September 12, 2003

I must say that I dislike the assumption that just because somebodys values a tightly bound, independant
executable that they must be writing a virus or something.

For many the efficient use of resources is artistically pleasing.

Mark Singleton squeezed the entire kingdom of Icemark into 48k with his game Lords of Midnight.

Ian Bell and David Braben did even better than that : Elite had 8 galaxies.

Now were impressed because somebody can return 42 in 64k!  This is progress?

Ged Byrne
Friday, September 12, 2003

Ok, 42 bytes.  You know what I mean.

Ged Byrne
Friday, September 12, 2003

It’s really fantastic, thanx everybody…it’s really a gr8 forum.
Thanx once again

Yours truly;)
Sh0rt

Sh0rt
Friday, September 12, 2003

Check out the "Zoom3" 64kB intro from Assembly 2003:
http://and.intercon.ru/

Amazing! The thing even has a speech synthesizer. I couldn't believe my eyes when I saw it.

YF
Sunday, September 14, 2003


try http://www.grc.com/smgassembly.htm and check out the V2 OS - a complete operating system w/windows etc. in a few kb of assembler code
find it here: http://v2os.v2.nl/

obviously if you intend to write small programs, asm is the only choice.

R
Thursday, March 25, 2004

*  Recent Topics

*  Fog Creek Home