Quote:Original post by lakmir0
To say "better programs" implies that C++ is an inherently better language than C which is ridiculous. It's ultimately about the coder's level of knowledge, not the language. I've seen very ugly "pure C++" code.
No, I was talking purely in the context of writing C++ code.
And yes, it is ultimately about the user's level of knowledge, however with C++ often that level of knowledge reaches a point where they can use it and they don't bother looking any further, at which point many people hit the 'C with classes level'.
Take for example the for loop; there is nothing wrong with the for loop as it is clearly part of the language. However, there is a very good chance that using something like std::foreach when going over a container (or memory block) will be faster because the compiler can (and most certainly does) fold more code together thus producing better performing code.
Now, you might say 'this is ugly' but I would argue that the reason it seems ugly is simply because you aren't used to it because so many people DONT write C++ "properly".
If anything I find C++ written like this to be better to read because I can make assumptions quickly about the code and things like the loop body is isolated away from the loop meaning that, with a well named class/functor, on initial look at the code I don't have to worry about what the code is doing.
Maybe in the cold realities of the commerical world good C++ practise goes by the way side, but that is no reason NOT to learn it in the first place. If you know it then you can, at the very start of the project at least, enforce it and use it which then gives you a solid start for the rest of the project. If you don't know it then you'll never use it and you'll never know what you are missing out on.
It also saves you coming across situations I did where I was working with someone who had been in the games industry for 5 years and had NEVER written a virtual function. His method of doing thing was to copy and paste code about when he needed the same functionality in related classes. This lead to code bloat, harder to maintain code and bugs which got fixed in one place and not in another. When we were working on a menu screen system for a game at work I could see a natural solution involving a small inheritance chain and a couple of virtuals; it was my area of code but I was going on holiday for a couple of days, so I outlined it to two guys (one being new to the company, the other the no-virtual guy) using standard C++ phrasing, asked if they were ok with it, which they apprently were, and went off for a long weekend.
I returned to find my design hadn't been implimented, instead a clugged involving C-style callbacks, copy and pasted code and far far more lines than required had been done and worked into the game which lead to me spending the next couple of days detangling the mess and fixing it up so that it was better and leaner code which did more.
So, yes, knowing how to use your language of choice is important and should be done properly.