Click here to Skip to main content
14,271,429 members

C / C++ / MFC

 
GeneralRe: course distribution system project in algorithm source code? Pin
David Crow21-Jan-19 10:27
memberDavid Crow21-Jan-19 10:27 
GeneralRe: course distribution system project in algorithm source code? Pin
CPallini21-Jan-19 10:35
mveCPallini21-Jan-19 10:35 
GeneralRe: course distribution system project in algorithm source code? Pin
Joe Woodbury21-Jan-19 10:37
professionalJoe Woodbury21-Jan-19 10:37 
AnswerRe: course distribution system project in algorithm source code? Pin
Stefan_Lang21-Jan-19 21:16
memberStefan_Lang21-Jan-19 21:16 
QuestionChoosing my next Programming Language Pin
HS_C_Student21-Jan-19 2:49
memberHS_C_Student21-Jan-19 2:49 
AnswerRe: Choosing my next Programming Language Pin
Richard MacCutchan21-Jan-19 4:57
protectorRichard MacCutchan21-Jan-19 4:57 
AnswerRe: Choosing my next Programming Language Pin
Joe Woodbury21-Jan-19 6:57
professionalJoe Woodbury21-Jan-19 6:57 
AnswerRe: Choosing my next Programming Language PinPopular
Stefan_Lang21-Jan-19 22:03
memberStefan_Lang21-Jan-19 22:03 
HS_C_Student wrote:
That C++'s OOP leads to less resource efficient programming and that classes were a crutch to help structure code in lieu of skillfully choosing one's own good designs.

There are so many ... misconceptions in that sentence alone, I wonder why you're actually thinking of C++ as your next language. I do agree that C++ is a good language to learn, but maybe I should clarify a few things:

1. C++ is not an OOP language! While it's often declared as such because its support for OOP is the most prominent feature that distinguishes it from C, C++ (as well as C) is a general purpose language! You can use it effectively for pretty much any programming paradigm you can think of: procedural, modular, object oriented, functional, you name it. Most other programming languages are not nearly as flexible. And that is the main reason why I love this language more than any other.

2. C++ is not less efficient than C. Neither with respect to use of resources nor with respect to speed. It used to be somewhat slower in some areas, but not the assembly that modern compilers can generate from modern C++ code. Of course, if you turn, say, some procedural code into OO code, use a lot of virtual functions and class hierarchies, that will likely cause some losses - but (if you do it right) you get clearer, more comprehensible code in return. It's not really a loss, it's a tradeoff, and it's for the programmer to decide whether he's willing to make that tradeoff or not.

3. I'm not sure what gave you the impression that classes are a crutch!? When I look at some code from less skilled programmers, yes that code may appear that way. But if you do understand the OO principles, and use it correctly, a well designed class hierarchy can give you extremely clear and comprehensible code, without sacrifcing anything, really.

That said, I'll have to give you a fair warning: programmers coming from a C background tend to stick with the programming techniques they know, because, in C++, they can! That is not necessarily a bad thing, but when these techniques creep into the class design, then, yes, what you get is a crutch! When you move to C++ from C, you need to take a step back every time you're about to design a class, and make sure that you drop any notion of using known principles and techniques, until you at least managed to specify what, exactly, the class needs to be able to do - and what not! The latter is really the key to good class design: making sure that a class does no more than what it's intended for. Otherwise you won't be able to benefit from the good aspects of OO, and you'll end up with the worst aaspects of both the procedural and the OO paradigm.

4. One extra tip: as I said, OOP is just one of many paradigms that C++ supports. Don't get too crazy with classes! The perception of many programmers that C++ is an OO-language, and only an OO-language, led to massive overuse of the OO principles. Programmers (including myself) were suffering from "when all you have is a hammer, everything looks like a nail" syndrome. It is not a good idea to turn everything into classes just because you can. Sometimes a struct and a set of polymorphic (or otherwise generic) functions is better design.

Therefore, when learning C++, you should also learn about the other paradigms: templates, generic programming and meta programming are diffcult to understand and learn, but there are many good articles and sites, and you can always come here for help. Functional programming got a lot of support with the more recent C++ standards and are well worth investigating. And, of course, sometimes there's really nothing wrong with plain old C structs and functions.

C is a great toolbox. But it's just the starter set with little more than a hammer, a screwdriver, and pincers. With C++ you get the advanced toolset! That doesn't mean you no longer need your hammer. Just that you now have a lot more specialized tools that can make specific tasks so much easier to complete.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

GeneralRe: Choosing my next Programming Language Pin
Richard MacCutchan21-Jan-19 22:41
protectorRichard MacCutchan21-Jan-19 22:41 
AnswerRe: Choosing my next Programming Language Pin
Member 1412742230-Jan-19 4:36
memberMember 1412742230-Jan-19 4:36 
QuestionOPC DA3 Pin
D.Manivelan20-Jan-19 22:21
memberD.Manivelan20-Jan-19 22:21 
AnswerRe: OPC DA3 Pin
Richard MacCutchan20-Jan-19 22:56
protectorRichard MacCutchan20-Jan-19 22:56 
QuestionAdd checkbox in second column in dynamically created ListCtrl Pin
Anu_Bala20-Jan-19 18:19
memberAnu_Bala20-Jan-19 18:19 
AnswerRe: Add checkbox in second column in dynamically created ListCtrl Pin
Victor Nijegorodov20-Jan-19 20:45
memberVictor Nijegorodov20-Jan-19 20:45 
AnswerRe: Add checkbox in second column in dynamically created ListCtrl Pin
Richard MacCutchan20-Jan-19 21:24
protectorRichard MacCutchan20-Jan-19 21:24 
QuestionHow to use Pin
Member 1412420320-Jan-19 15:46
memberMember 1412420320-Jan-19 15:46 
QuestionUsing hex in an array and "scanning" for it fails. Pin
Vaclav_20-Jan-19 14:51
memberVaclav_20-Jan-19 14:51 
AnswerRe: Using hex in an array and "scanning" for it fails. Pin
Peter_in_278020-Jan-19 15:27
professionalPeter_in_278020-Jan-19 15:27 
GeneralRe: Using hex in an array and "scanning" for it fails. SOLVED Pin
Vaclav_20-Jan-19 16:57
memberVaclav_20-Jan-19 16:57 
GeneralRe: Using hex in an array and "scanning" for it fails. SOLVED Pin
CPallini20-Jan-19 20:32
mveCPallini20-Jan-19 20:32 
GeneralRe: Using hex in an array and "scanning" for it fails. SOLVED Pin
Vaclav_21-Jan-19 6:42
memberVaclav_21-Jan-19 6:42 
QuestionComplex multidimensional array in C++ Pin
Vaclav_19-Jan-19 18:27
memberVaclav_19-Jan-19 18:27 
AnswerRe: Complex multidimensional array in C++ Pin
Richard MacCutchan19-Jan-19 21:34
protectorRichard MacCutchan19-Jan-19 21:34 
GeneralRe: Complex multidimensional array in C++ Pin
Daniel Pfeffer19-Jan-19 21:48
professionalDaniel Pfeffer19-Jan-19 21:48 
GeneralRe: Complex multidimensional array in C++ Pin
Richard MacCutchan19-Jan-19 22:14
protectorRichard MacCutchan19-Jan-19 22:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.