home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:19506 comp.lang.c++:18903
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!asuvax!ncar!noao!amethyst!organpipe.uug.arizona.edu!news
- From: dave@cs.arizona.edu (Dave Schaumann)
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Re: C/C++ Speed
- Message-ID: <1993Jan10.215947.13520@organpipe.uug.arizona.edu>
- Date: 10 Jan 93 21:59:47 GMT
- References: <1ipsk5INNf5m@aludra.usc.edu>
- Sender: news@organpipe.uug.arizona.edu
- Reply-To: dave@cs.arizona.edu (Dave Schaumann)
- Followup-To: comp.lang.c
- Distribution: usa
- Organization: University of Arizona
- Lines: 52
- In-Reply-To: dliao@aludra.usc.edu (David Liao)
-
- In article <1ipsk5INNf5m@aludra.usc.edu>, dliao@aludra (David Liao) writes:
- >
- > Two programmers are writing the same program but with different
- >languages which are C and C++. These two programmers are experts in
- >their own programming language. Hmm... which program will run faster
- >than the other?
-
- Probably the C program, but...
-
- Choosing a target language *always* involves trade-offs. C has several
- advantages in its favor that tend to make C programs run faster:
-
- 1. C is a smaller language than C++. This means a company with $X to
- spend on developing a C compiler will have more money left over when
- it comes time to think about optimizing.
-
- 2. C is more widely used, so more money is spent developing C compilers,
- and so the level of technology you're likely to encounter for C
- compilers is likely to be superior.
-
- 3. C++ does have some features which might cause code to run slow.
- Since it's a more powerful language than C, it also has more features
- that can be abused.
-
- >I just want to know if the C program will run faster than the C++ program.
-
- Last semester, I had a graphics class, and the final project was to write
- an interactive program that drew Bezier curves, with up to 50 segments.
- We were allowed to choose the language, so there were people using the
- (Sun 4) vendor cc, some using gcc. I used g++ (I don't know if anyone
- else did, though). I was able to obtain very satisfactory performance
- with my program. I would even say that I was able to more easily implement
- some optimizations (such as utilizing pre-computed screen coordinates)
- because of the class structure available.
-
- I realize this isn't "iron-clad proof", but my experience indicates that
- unless you're really pushing the envelope, you can get competative
- performance out of a C++ program.
-
-
- > I also heard the size of C++ program is generally bigger than C.
-
- I just brought this up myself a few weeks ago. The answer is that it is
- possible to compile C++ programs to be very comparable to the size of an
- equivalent C program.
-
- On the other hand, there are some compilers out there that can generate
- very large executables.
-
- --
- What I've learned from reading net news #2:
- Surely the most ignored phrase to be posted to the net is "'nuff said".
-