delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/08/03:28:20

Posted-Date: Sun, 8 Jun 1997 10:26:30 +0300
Message-ID: <01BB5524.FA16C340@pl5.techno-link.com>
From: "Alian Ltd." <alian AT plovdiv DOT techno-link DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: RE: C++ question
Date: Sat, 8 Jun 1996 10:07:11 +0300
MIME-Version: 1.0

From what I saw in the last few months, DJGPP makes the best code ever possible (we made small research studying the code, which the following compilers produce: Microsoft C++, Borland C++ 3.1 (the very old DOS version), Watcom C++, Symantec C++. The best result was made with DJGPP. The code was very compact, optimized and fast, and errors in code generation were not found (in comparison - Borland C++ makes sometimes stupid errors while generating machine code - just forgets registers and etc., which could make you crazy, trying to find why your code doesn't work anymore :-)).

Usually the C++ compilers produce very good code. But the OO program structure makes impossible skipping some things, which will delay the execution (theoretically). For example, every time you use a class method, you have one hidden pointer in the stack. Every time when you make call to virtual function, the compiler finds the address of the correct function using special table, hidden from you. This things could delay the execution.

But there is nothing to compare with the usability and the reliability of one good made OO project (of course, when you had sited down and make the project in you head first, after that 'generating' the source ;-)). If you make good your project design, choosing the correct class structure, inheritance and all the other necessary things, you can finish much faster and better the project. Of course, if you fail here, even the best compiler can't help you.

If you had been C programmer before, you might need weeks (maybe months) to make your mind to 'work' object-orientedly. Specially if you had worked a lot with non-OO language. But finally it happens - you're starting to thing OO-ly.

The protection methods you had heard for are just great for the design. This makes possible whole class encapsulation (your class is a 'black-box' for the class users and they know just what the class does, not how it does it), so they do not have way to disturb (theoretically again!) the class and it's job. The principle is: they know just what they had to, and they can use only this to do their job.

The C++ benefit is not only in the classes. It's also in the function and class templates, the function overloading and also many other things, which are just cooler that the C.

And also you have always the possibility just to write C in you C++ program - anyway the C++ is C superset ;-).

If you need any more info about C++, I suggest you reading book about it. Usually each good C++ book (beginners level) starts with such a comparison C<=>C++. Anyway, if you need any other info, don't hesitate.

Dony

-----Original Message-----
From:	Telepac [SMTP:suporte AT mail DOT telepac DOT pt]
Sent:	Sunday, June 08, 1997 4:00 AM
To:	djgpp AT delorie DOT com
Subject:	C++ question

I´ve been seeing a lot of discusing about C++ versus C for games and that
kind of stuff.
I´ve been reading, trying to decide if C++ is good for games, but it seems
that there isnt an answer....

Could anyone tell if DJGGP makes good C++ code.

I´m now learning C++, and i think its OK for games...
I think that without notice, we are just using a kinda of structs.

I think the idea of class's and objects are just for protecting data and
code from beeing missuse, and a good compiler would compile pretty much
like C code.

Can anyone give me some light about it ?

-- 
Silent Dreamer
silentdreamer AT mail DOT telepac DOT pt

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019