What makes a small program?

Started by
20 comments, last by NaliXL 22 years ago
Or, what makes an executable grow bigger? Say that if I want to write a 64K OpenGL demo, what kind of things would I have to keep in mind while programming, not looking at things like textures etc, but really coding techniques? For example : does a "uses" (a.k.a. include) statement to unused code enlarge my executable, or will the compiler ignore it, as it is not used? BTW : I''m using Borland Delphi to code my programs, if that makes any difference...
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
Advertisement
I tellz you what. Depends on the compiler. Delphi is awesome though. I think you''re fine. MSVC++ 6 is also rather decent.

Good compilers don''t include code that is guaranteed not to be used in the EXE. When you use some of the functions from the standard includes, you may unknowingly drag in a whole chain of functions that the function you used depends on.

Example (in C++): including iostream.h makes your file grow by something like 350k. Crazy stuff. (that''s one of the reasons I don''t normally use streams).

I''m not sure what units the size of a delphi app would depend on, but I think delphi apps are quite large in general, since they include a whole visual library. For a simple programme, you''re looking at something like 400 KB at least.

BTW, why would you care about the EXE size anyway?

------------------------
CRAZY_DUSIK* pCrazyDuSiK = new CRAZY_DUSIK;
pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);
------------------------CRAZY_DUSIK* pCrazyDuSiK = new CRAZY_DUSIK;pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);pCrazyDuSiK->WebSiteURL = "http://www.geocities.com/dusik2000";
If you want to do a 64kb program, the best is that you program in win32 asm, using TASM5 or MASM32, and you need to aply techniques of optimization of size, and to use ONLY the part of opengl libraries what you need.
Sorry of my english
quote:Original post by dusik
Example (in C++): including iostream.h makes your file grow by something like 350k. Crazy stuff. (that''s one of the reasons I don''t normally use streams).

It is not that much. Try a cout "hello world" vs an printf "hello world" and you''ll see the difference is less than 200k, and that''s in debug mode. With optimisations on it''s likely to be even less.



[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]
i honestly know nothing of delphi, but the most obvious answer to reducing executable size would be to dynamically link to as many things as possible, i.e. leave as much code outside of your executable as possible. more demo oriented sites might have more information about this, maybe cfxweb.net or similar?

ewen
I dont know why people care so much about the size of the exe its no big deal really. I mean who gives a rats arse...
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
You have to give a rat ass for demos because there''s a category called 64k intros. P
I''ve been doing contract work in delphi the past few months again so I''ll put in my 2 cents.

Lets say we have a tiny delphi app like this


  program Project2;uses  Forms,  Unit1 in ''Unit1.pas'' {Form1};{$R *.RES}begin  Application.Initialize;  Application.CreateForm(TForm1, Form1);  Application.Run;end.  


Tiny huh? Not, it''s 307KB

But if you drop the uses Forms and the other code, its only 17KB, better huh, so you will have to get a window the manual way, that should keep the size down.

Also have a look at these links

http://www.theproduct.de/index.html
http://upx.sourceforge.net/

Thanks for your input guys!

Yes, I know theproduct and UPX. More of this stuf at http://farb-rausch.de/ . Very nice!
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
man!
introse are the bomb digity yo!!

[ my engine ][ my game ][ my email ]
SPAM
Rate me up.

This topic is closed to new replies.

Advertisement