On Tue, 2004-01-20 at 08:20, Richard B. Johnson wrote:
> Nevertheless, I provide three programs, one written in
> C, the other in C++ and the third in assembly. A tar.gz
> file is attached for those interested.
>
> -rwxr-xr-x 1 root root 57800 Jan 20 10:16 hello+
> -rwxr-xr-x 1 root root 460 Jan 20 10:16 helloa
> -rwxr-xr-x 1 root root 2948 Jan 20 10:16 helloc
>
> The code size, generated from assembly is 460 bytes.
> The code size, generated from C is 2,948 bytes.
> The code size, generated from C++ is 57,800 bytes.
>
> Clearly, C++ is not the optimum language for writing
> a "Hello World" program.
I like C++ and hate to see it so unfairly maligned. Here's a much
better example:
Makefile:
helloc: hello.c
gcc -Os -s -o helloc hello.c
hellocpp: hello.cpp
g++ -Os -fno-rtti -fno-exceptions -s -o hellocpp hello.cpp
Both programs contain exactly the same code: one main() function using
puts("Hello world!").
# ls -l
-rwxrwxr-x 1 jbriggs jbriggs 2840 Jan 20 10:02 helloc
-rwxrwxr-x 1 jbriggs jbriggs 2948 Jan 20 10:06 hellocpp
108 extra bytes is hardly the end of the world.
--
Zan Lynx <zlynx _at_ acm.org>
Attachment:
signature.asc
Description: This is a digitally signed message part
Follow-Ups:
- Re: Compiling C++ kernel module + MakefileRichard B. Johnson
- Re: Compiling C++ kernel module + MakefileChris Friesen
- Compiling C++ kernel module + MakefileAshish sddf
- Re: Compiling C++ kernel module + MakefileRichard B. Johnson
- Re: Compiling C++ kernel module + MakefileBart Samwel
- Re: Compiling C++ kernel module + MakefileRichard B. Johnson
- Re: Compiling C++ kernel module + MakefileBart Samwel
- Re: Compiling C++ kernel module + MakefileRichard B. Johnson
- Re: Compiling C++ kernel module + MakefileBart Samwel
- Re: Compiling C++ kernel module + MakefileRichard B. Johnson
- Re: Compiling C++ kernel module + MakefileBart Samwel
- Re: Compiling C++ kernel module + MakefileRichard B. Johnson
- Prev by Date: Re: [PATCH] bitmap parsing/printing routines, version 4
- Next by Date: Re: ALSA vs. OSS
- Previous by thread: Re: Compiling C++ kernel module + Makefile
- Next by thread: Re: Compiling C++ kernel module + Makefile
- Indexes:[Main][Thread]