January 19th, 2004
So cmoog made the mistake of mentioning how great C++ is.
Being a special interest of mine, I decided to see the current state of things between C and C++ at the moment.
So, two simple programs.
Both compiled with gcc -O3
$ ls -l chello cpphello
-rwxr-xr-x 1 root root 6691 Jan 18 17:28 chello
-rwxr-xr-x 1 root root 8136 Jan 18 17:27 cpphello
$ time ./chello
$ time ./cpphello
Those are representative times (I ran each about 10 times or so and averaged in actuality)
System times are about the same. That makes sense since that's linux printing it to the screen.
Real times are mostly junk. That's the time from start to stop of execution, regardless of what else is going on
in the system.
User times are where it's at. That's the actual time that the code is paged in and executing.
One might notice that C++ takes longer. Significantly longer. This is because of the runtime allocation of the objects in question and cleanup probably. C doesn't bother with that. It interacts directly. This is why C will always beat out C++.
Object Oriented Programming imposes all sorts of strange limitations upon a programmer that aren't true to the machine's capabilities. It's all under the vague and poorly defended pretense that it creates better code. The nastiest bugs that I've ever tracked down have been the result of obfuscation through OOP. In order to do almost any operation, you invoke all sorts of classes one after the next. Many of which are internal compiled libraries which might have interesting issues with cleanup and memory management.
C code when properly placed between files shows the same benefits as distinct objects. C code when properly placed in functions results in clean, readable, compartmentalized code. More of it's under your command and thanks to call stacks, you can easily track down just which function caused the problem.
You also don't have those silly private, public, and protected distinctions.
|Date:||January 23rd, 2004 02:51 pm (UTC)|| |
Damn, that's scary. Someone who thinks like I do about modern programming.
This is one of the reasons I stopped persuing programming about 7 years ago.