#1 Members - Reputation: 300
Posted 13 December 2012 - 07:38 AM
Many here know I am a huge proponent of C. As of late I am considering a move to C++ due to some of the C++ 11 features. One such feature is std::unique_ptr.
Keep in mind I am not a huge proponent of OOP way to easy to abuse and mangle the ability to maintain code. What other advantages besides the obvious would I gain?
#3 Moderators - Reputation: 14288
Posted 13 December 2012 - 07:59 AM
For a real-world example of the benefits, C++'s std::sort is a lot faster than C's qsort, due to the fact that the optimiser can massage it a lot more at compile-time.
Most cool parts of std also rely on templates, such as unique_ptr, and the above-mentioned function (which is great for callbacks, events, delegates, etc).
Edited by Hodgman, 13 December 2012 - 08:00 AM.
#4 Crossbones+ - Reputation: 1219
Posted 13 December 2012 - 07:59 AM
#5 Crossbones+ - Reputation: 268
Posted 13 December 2012 - 08:10 AM
I have been using OOP from my Pascal days. But I have found that larger programs runn faster in C++.
Your Brain contains the Best Program Ever Written : Manage Your Data Wisely !!
#6 Members - Reputation: 2820
Posted 13 December 2012 - 08:28 AM
The biggest and best thing about C++ is it supports the RAII paradigm (which requires a certain amount of OOP). That alone makes C++ stand head and shoulders above C or Java and any other language with non-deterministic destruction. You can use RAII using only std::unique_ptr and lambdas if it's important that you avoid the appearance of using classic OOP.
Professional Free Software Developer
#7 Members - Reputation: 6183
Posted 13 December 2012 - 08:31 AM
C used to be my primary language, but I have been using C++ for about 11 years now. The things I couldn't live without if I were to go back to C are:
- std::string
- Containers (primarily std::vector, std::map, std::unordered_map)
- RAII
- Operator overloading for math classes, like vectors and matrices.
#8 Members - Reputation: 632
Posted 13 December 2012 - 08:36 AM
OOP is great, but not everything is an object. That is why I do not like languages thet shoehorn OOP to situations where it does not work. C++ does not force you, however – it lets you choose.
There is clearly no reason nowadays why would not someone want to use C++ (except in circumstances where the STL is nonexistent). I would recommend you to switch.
#9 Members - Reputation: 3358
Posted 13 December 2012 - 09:57 AM
I don't like OOP myself. It's like nail-oriented roofing. Objects are useful constructs, but they aren't the only tool around.
C used to be my primary language, but I have been using C++ for about 11 years now. The things I couldn't live without if I were to go back to C are:
- std::string
- Containers (primarily std::vector, std::map, std::unordered_map)
- RAII
- Operator overloading for math classes, like vectors and matrices.
It's funny that your list from C to C++, reads almost identical to one I would create about what I miss going from C# to C++...
- .NET class libraries, vastly superior string handling
- generic containers and LINQ, especially LINQ, also not having to deal with C++ terrible template syntax and error handling
- sensible automatic memory management
- operator overloading I'm rather meh towards. So instead I will go with the lack of multiple inheritance and existence of interfaces.
With C++ 11, I think there are a number of things you can add to the list. lambda functions, automatics, those would be useful in non-OO programming.
#10 Members - Reputation: 300
Posted 13 December 2012 - 02:05 PM
#11 Crossbones+ - Reputation: 1389
Posted 13 December 2012 - 09:44 PM
if (Object.size() < Object.MaximumSize)
{
Object.IncreaseSize;
}
This code makes sense, rather than having to use weird structs and arrays, or collections of values that require commenting to explain the correlation. I also recently wrote an article on The Auto Variable (A great new C++11 feature).As a list, well, I'm not sure. Here are some (very useful) highlights:
- The Auto Variable
- Constexpr
- Vectors
- Objects, in General
- auto pointers
- weak pointers
- etc.
Edited by superman3275, 13 December 2012 - 09:44 PM.
Here's Breakout:
Breakout!
If you need some photo editing done, contact me:
superman3275@gmail.com
if you want some programming help, or are recruiting for a game development team, either PM me on here or email me up there
#13 Members - Reputation: 300
Posted 14 December 2012 - 04:29 AM
Object-Oriented programming hardly produces error-prone, mangled code. In fact, I would say (And this is someone who came from only procedural programming to C++ around two years ago) that object-oriented programming reduces errors, nevermind making your code far more understandable.
if (Object.size() < Object.MaximumSize) { Object.IncreaseSize; }This code makes sense, rather than having to use weird structs and arrays, or collections of values that require commenting to explain the correlation. I also recently wrote an article on The Auto Variable (A great new C++11 feature).
As a list, well, I'm not sure. Here are some (very useful) highlights:There are just far too many great C++(11) features. C hasn't been updated since 1999, also, which means many C++ features that are commonplace in many programming languages now might never reach C (However I hope they make a new standard, it's definitely rejuvinate the language).
- The Auto Variable
- Constexpr
- Vectors
- Objects, in General
- auto pointers
- weak pointers
- etc.
I am not saying OOP is error prone what I am saying is that OOP can lead to abstractions that go too deep which leads to harder to maintain code. You can find numerous threads here in the GDNet forums where people have a hard time finding certain bugs because their abstractions are far to complex for the problem they are trying to solve. The issue arrises because people tend to abuse inheritence. From a side node understandable is more of a personal preference. For instance I find it easier to understand and learn procedural libraries then heavily abstracted libraries. It is not that I have a problem with OOP I use it when it makes sense in Python all the time when writing scripts and such the issue with it have have is the over abstraction and abuse that comes from it.
Yes the C11 standard came out very close to the C++11 standard the issue with C at the moment is none of the compilers care to implement the newer C standards to this day the only full C99 compiler I know of is Pells and maybe Intel. GCC has some support and MSVC has terrible support.
It comes down to the fact for me that there are certain aspects of C++ in the new 11 standard that I really like and really wish were in C. In all honesty one feature that would make a world of difference in C is namespaces but they still don't exist in any compiler I have used.
#14 Members - Reputation: 632
Posted 14 December 2012 - 07:35 AM
Edited by ifthen, 14 December 2012 - 07:36 AM.
#15 Members - Reputation: 273
Posted 16 December 2012 - 05:11 PM
Yes the C11 standard came out very close to the C++11 standard the issue with C at the moment is none of the compilers care to implement the newer C standards to this day the only full C99 compiler I know of is Pells and maybe Intel. GCC has some support and MSVC has terrible support.
Clang has the best support for both C11 and C++11 at the moment as far as I am aware. GCC is second place with C++11 support. MSVC has no support at all for any C dialect other than ANSI C and has poor C++11 support (comparatively speaking). Intel I have no idea about other than they have good support for C99. No idea about C11 or C++11.
#16 Members - Reputation: 300
Posted 16 December 2012 - 05:30 PM






