Posted: Sun Dec 31, 2006 12:16 pm
Ready4Dis you should pat yourself on the back...you have made me want to switch to C++..I'm reading C++ for dummies right now..
The Place to Start for Operating System Developers
https://f.osdev.org/
...if you don't know the language well. It's true that careless use of C++ can cause quite inefficient code, but that is true for every language. C++ is just much, much more than C, and people tend to carry over their "styles" from C or Java, which doesn't result in good C++ code.Ready4Dis wrote:However, depending on what parts you use and the compiler, it can cause speed issues as well as bloat.
Not trying to start a flame war, both have their uses, but I have never seen C++ more efficient speed wise than C, time-to-release, yes, it can be MUCH more efficient, as can re-useability and readability. A long while back me and a buddy were writing a ray-tracing engine, we used C++ because it was much simpler to implement, especially with multiple object types (for tracing said rays). Well, we inherited from the base class, overloaded virtual functions for collisions, etc and it worked very nicely, although seemed slower that what we were aiming. One day I decided to see how much worse C was, so I wrote generic structs with pointers to function, and type information, and a ton of casting and if statements everywhere. We saw our speed more than double, and have left everything in C since. I do use C++ in a lot of my game programming, most things can be optimised algorithmically, in which case their is no noticeable speed difference, however, for something very time critical, I still stick with C and in some cases assembly depending on how time critical (and how well the compiler optimizes). I normally won't optimize a section of code unless it is found to be the source of most of the time spent using a profiler however, no need was time optimizing something that runs once in a 100th of a second. Anywho, like I said, I use C++ a lot in my programming, it makes development time much faster, finding bugs are ussually easier (due to being easier to follow program flow without all the hacks!), and a lot of other things much nicer (and I do have a few includes that I re-use in a lot of my apps, a memory tracker to keep track of new/delete calls for memory leaks, a generic linked list and dynamic array class, as well as a few other nifty things).Solar wrote:...if you don't know the language well. It's true that careless use of C++ can cause quite inefficient code, but that is true for every language. C++ is just much, much more than C, and people tend to carry over their "styles" from C or Java, which doesn't result in good C++ code.Ready4Dis wrote:However, depending on what parts you use and the compiler, it can cause speed issues as well as bloat.
Used well, C++ can be made more efficient than C, both in speed and in time-to-release (which is the important point with the other 80% of the code, as we know). It just takes longer to get "fluent" in C++.
An STL sort() beats a C-style qsort() by almost one order of magnitude (because the compare function can be inlined). That's just one example.Ready4Dis wrote:Not trying to start a flame war, both have their uses, but I have never seen C++ more efficient speed wise than C...
Means, you took the traditional beginner's road (object oriented), which sadly enough is still taught by many introductionary books, and didn't use the real power of C++ when it comes to efficiency, which is templates...Well, we inherited from the base class, overloaded virtual functions for collisions, etc...
Poor C++ code.One day I decided to see how much worse C was, so I wrote generic structs with pointers to function, and type information, and a ton of casting and if statements everywhere. We saw our speed more than double...
Dynamic array class? What's wrong with <vector>?...a generic linked list and dynamic array class...
C standard: ISO 9899:1999 (most recent), chapter 7 iirc is the c library.Solar wrote:The STL is part of the C++ standard library. (Which is larger than just the STL; actually the "S"TL became part of the standard pretty late in the standartization process.) It is, unless I am very much mistaken, specified in the same ISO standard as the C++ language itself.
I know for a fact that the C library is part of the C language standard.