Article View: borland.public.cppbuilder.nativeapi
Article #8905Re: The Most Compressed
From: Chris Croughton
Date: Tue, 31 Aug 2004 09:09
Date: Tue, 31 Aug 2004 09:09
55 lines
2984 bytes
2984 bytes
On Mon, 30 Aug 2004 21:11:47 +0430, Pedram
<nover@hever.sever> wrote:
> anyway ...
> My Hello World sample that is like below :
> #include <windows.h>
> #include "dialogs.hpp"
> #pragma hdrstop
> #pragma argsused
> WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
> lpCmdLine, int nCmdShow)
> {
> ShowMessage("This is a Hello World!");
> return 0;
> }
> has 12288 bytes lenght when I dont attach any RTL
> if I attach RTLs , (RunTimePachage and Dynamic RTL) it wont compile becasue
> there is VCL components/RTLs I think.
> Then when I only arrach Dynamic RTLs it becomes : 51712
>
> I personally think , It is possible to make a 1 Kilobytes exe file to do a
> very simple job like Hello World !!
Of course it is. You don't need a Boeing 767 if you just want to fly a
kite. I think my smallest program to output "Hello World" was about 10
bytes bigger than the string itself -- written all in hex. But if you
are going to write a larger program, you will probably need all of the
other libraries, components, etc.
If you are looking for a small "Hello World" program, there are several
ways to get it small. For a start, do it as a console mode program
rather than a GUI one:
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello world!\n");
return 0;
}
which will be far smaller. Or if you really want to use the GUI, use
MessageBox (and omit including "dialogs.hpp").
What do you /really/ want to do? Trying to save a few bytes is pretty
pointless these days (that's not condoning bloat or sloppy programming,
but time to design and write an application in a clear and maintainable
fashion is more important than saving a few KB of disk or RAM space). I
write mostly in C++, for instance, because although it is more
'expensive' in terms of space and (to a certain extent) speed the
clarity is much improved, so the time spent won't have to be wasted
later trying to work out what it did to maintain it. I've seen projects
where they coded everything in assembler to save a few KB, and it was
hell trying to do something as simple as change the size of a structure.
Chris C
Technical Details
Message-ID:
<slrncj8g2b.5g2.chris@ccserver.keris.net>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mailReferences:
<4130d6c2@newsgroups.borland.com> <4505j0d7fmr3dbl9fpabplhbpvv0gg50i5@4ax.com> <4133585a@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8f88fecd49aea605 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Croughton <chris@keristor.net> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: The Most Compressed Date: Tue, 31 Aug 2004 10:09:31 +0100 Lines: 55 Message-ID: <slrncj8g2b.5g2.chris@ccserver.keris.net> References: <4130d6c2@newsgroups.borland.com> <4505j0d7fmr3dbl9fpabplhbpvv0gg50i5@4ax.com> <4133585a@newsgroups.borland.com> Reply-To: chris@keristor.net X-Trace: news.uni-berlin.de WBR1oLIK7k77WdY6OphBCAoOZNOEBGDmq54PTGLGo5djTCQJA= X-Orig-Path: ccserver.keris.net!news User-Agent: slrn/0.9.7.4 (Linux)