Is C++ too complex?
#41 Moderators - Reputation: 6645
Posted 01 December 2012 - 07:32 PM
#43 Members - Reputation: 439
Posted 03 December 2012 - 04:04 AM
I recently graduated with a BS in computer science and I have a few friends who are lower classmen and they're now looking to get jobs and I have often looked over their resumes to at least do a bullshit check on it. My school teaches Java as the first language (gross...), but eventually forces people to learn C or C++ through data structures classes and a dash of functional programming in a compilers and languages class. Almost everyone LOVES Java and hates C, C++, and OCaml. Anyways, some people become what I would call "Syntactically proficient" in C++, where I would trust them to implement very small pieces of code or features. Nothing more. It amazes me the audacity people have when they claim their proficiencies in particular languages, even though they have absolutely ZERO credibility in making them. My favorite, of course, is the listing of languages they know and they write something like:
Languages Known:
- C++ (Expert)
- Java (Expert)
- Python (Intermediate)
I know of only a handful of names in the world (We're talking like, 5-10 people) which could be on such a resume that could claim EXPERT in a language as complex as C++... Anyways, this turned out to be more of a rant. The reason why we (game developers) stick with such a complex and nasty language is for many different reasons. For me, one of the biggest reasons is simply it's the best we've got for the job we have. When you need to write high performance code, C++ surely can let you do that. If you need very precise control of hardware, C++ can let you do that. But be wary, if you need both of those, you will likely need to know what you're doing, and C++ does not spare those who don't know what they're doing.
My advice for people who want to know C++ more intimately:
- Write more C++ code and READ other people's C++ code. Figure out what you do and what they do. Why are you the same or different?
- IMPLEMENT YOUR OWN COMPILER!
- LEARN ABOUT LANGUAGE DESIGN!
- Learn other languages.
- Read the C++ language standard.
I put 1 up first since I think it's most easily done by the vast majority of people. 2 and 3 though I think really lets you understand some of the fundamental issues that drive the decisions the C++ language committee has to make. You also begin to understand why entire features are designed the way they are in terms of semantics and syntax. It also helps you put into perspective other programming languages (sure helped me). The last point, isn't really going to be helpful if you aren't already pretty proficient in C++ and programming language design issues. In fact, it may be of very little help to anyone unless you're interested in implementing a C++ compiler.
*Edit*
I should clarify my suggestion #2: Implement your own compiler for a simple, object oriented language. COOL perhaps. Implementing your own C++ compiler would be a herculean task. It takes teams of experts to implement one.
Edited by snowmanZOMG, 03 December 2012 - 04:08 AM.
#44 Members - Reputation: 1239
Posted 03 December 2012 - 04:36 AM
Your car is too complex. Try disassembling and reassembling it.C++ is too complex. Anyone who doesn't (or isn't willing to) admit that probably hasn't worked with the language enough to realize that or is delusional. Try writing your own parser for the language...
#45 Crossbones+ - Reputation: 3520
Posted 03 December 2012 - 04:42 AM
Thank god for that clarification, I was starting to wonder if implementing your own C++ compiler was par for the course*Edit*
I should clarify my suggestion #2: Implement your own compiler for a simple, object oriented language. COOL perhaps. Implementing your own C++ compiler would be a herculean task. It takes teams of experts to implement one.
#46 Members - Reputation: 212
Posted 03 December 2012 - 06:14 PM
I would suggest you not to waste time on D. It's been around for some 6+ years now, and I am doubtful you'll find much work in that area, if ever.
@whtemple1959: Just start easy with some very simple programs. Try to stick to the simple things in the beginning, using as few keywords as possible. Using your analogy, draw stick figures to familiarize yourself with the tools. But keep coding, even if it is the most simple things. Like doodling. In time (depending how much time you spend) you'll pick up the basics soon enough. As far as the tools go, don't worry about them. Install QT.. or MingW. But the only thing you need from them is to make them compile a program. If you get that working, you're good to go. All you need to focus on right now is making small programs. Here are some links for you:
http://www.cplusplus.com/doc/tutorial/
http://www.cppgameprogramming.com
I haven't look at them closely but I am sure you can find others later.
Learning to walk before running is important.
Also, If you want to be inspired, have a look here on what others have done:
http://www.pouet.net
Hope it helps.
#47 Members - Reputation: 1840
Posted 03 December 2012 - 06:27 PM
C++ is complex, probably too much so, as someone said (I think about C++11), it's like a commitee designing an octopus by nailing 4 legs on to a dog. Backwards compatibility is the killer though (but obviously that is one of its main strong points).
#49 Members - Reputation: 1840
Posted 03 December 2012 - 06:36 PM
If only they could get rid of some of the mistakes they made earlier on and make a cleaner lighter language. Not going to happen though.
#50 Members - Reputation: 1564
Posted 03 December 2012 - 06:52 PM
Your car is too complex. Try disassembling and reassembling it.
C++ is too complex. Anyone who doesn't (or isn't willing to) admit that probably hasn't worked with the language enough to realize that or is delusional. Try writing your own parser for the language...
Modern cars are too complex. My mom's car has a big chunk of black-box electronics on top of the goddamn battery.
THE BATTERY.
A 'proper' (read that as 'Khat is a smug, opinionated git') car can be taken apart and re-assembled by a decent mechanic. The new ones try to do way too much and end up not being able to go to from point A to point B because the satellite radio reception isn't good enough to power the flux capacitor or whatever.
C++ is (eeeeeehhhh...) sort of starting to look a little the same. There's a solid core language under it all, but all the stuff that's put on top of that can be a little bizzarre at times.
Even so, if you think about it in relative terms C++ is still good at the jobs that it's good at, so I wouldn't say that it's a huge problem. On the other hand, if a new language comes out right now that does the same job with less BS then I'd say there may be a fight on.
Edited by Khatharr, 03 December 2012 - 06:58 PM.
There are ten kinds of people in this world: those who understand binary and those who don't.
#51 Members - Reputation: 403
Posted 03 December 2012 - 06:57 PM
If only they could get rid of some of the mistakes they made earlier on and make a cleaner lighter language. Not going to happen though.
The language is light....i really don't see the problem alot of you seem to have with it. Its the same with any programming language. Once you know how to programm you can basicly programm in any language.
#52 Members - Reputation: 1840
Posted 03 December 2012 - 07:01 PM
#53 Members - Reputation: 1564
Posted 03 December 2012 - 07:02 PM
If only they could get rid of some of the mistakes they made earlier on and make a cleaner lighter language. Not going to happen though.
Wish I could upvote you twice. I don't know if I'd call them 'mistakes' but some of the changes seem a lot more like 'tack on another class' rather than actually incrementing the language itself to add new features.
Edited by Khatharr, 03 December 2012 - 07:04 PM.
There are ten kinds of people in this world: those who understand binary and those who don't.
#54 Members - Reputation: 403
Posted 03 December 2012 - 07:10 PM
I think i have seen alot of code and c can just be as bad as c++. Same goes for every programming language. You can always write bad code and create structures that no one understands besides yourself. But that really has not so much todo with the language used.You've probably never seen any really bad C++ code. C is a very light language but my, have I seen some terrible code which no-one understands. C++ is about 4 times worse if you write it badly.
#55 Moderators - Reputation: 7561
Posted 03 December 2012 - 07:35 PM
You can write bad code in any language, sure. You can also commit genocide with any weapon, but some weapons make it a hell of a lot easier.
[Work - ArenaNet] [Epoch Language] [Scribblings] [Journal - peek into my shattered mind]
#56 Moderator* - Reputation: 5387
Posted 03 December 2012 - 07:54 PM
Which constructors and/or operators will be called in this code:
struct MyStruct { MyStruct() {} MyStruct(int i) {} MyStruct(const MyStruct&) {} MyStruct& operator = (int) { return *this; } }; MyStruct s = 5;
C++ is way too complex. I don't mean too complex for beginners. I mean it's way more complex than it needs to be.
Beginners can start with whatever they want. They just need to realize that it'll probably take them longer to get something shiny on the screen with C++. Like SiCrane said, no matter what language someone chooses, they'll make plenty of mistakes. It's not the end of the world if someone chooses C++. But it's not exactly a walk in the park, either. It's never a walk in the park.
Edited by Cornstalks, 03 December 2012 - 07:56 PM.
#57 Members - Reputation: 403
Posted 03 December 2012 - 08:12 PM
#58 Members - Reputation: 531
Posted 03 December 2012 - 08:23 PM
And I'm not talking about relatively obscure tricks/"abuses" of the languages. I'm talking about stuff you'll learn in your first years of Comp Sci, or an intro-to-C++ book.
I mean, I've seen my fair share of heinous code. In all manner of languages: C, C++, Java, C#, Python, LUA .. you name it. But what makes it complex has never been the language as much as the complexity of the code. In other words, I rarely ask myself: "Damn, what does this language feature do?" but rather ask "why in the world has the developer done this?"
I do believe, though, that pointers and the usage thereof continually trip folks up with regard to C *and* C++, and with good reason. Pointer management takes a while to get a good grasp of, but even Pascal had pointers and I can count on my left foot the number of times someone has said "Pascal is too complex"
So, again, what *exactly* makes C++ so complex over, say, Java? Pointers aside, and considering only what you may learn in your first year as a CS student? (I make that distinction because as you spend more time in any language you'll eventually learn all sorts of 'interesting' things that'll make most folks' heads spin)
#59 Moderators - Reputation: 7561
Posted 03 December 2012 - 08:57 PM
The problem is that no first-year CS course will cover all the things you have to know to use C++ proficiently. It's like asking "what's so hard about being a chef? Limit your answers to the subject of boiling water."
Well, yeah, boiling water isn't hard. There's a lot more to being a chef than boiling water.
[Work - ArenaNet] [Epoch Language] [Scribblings] [Journal - peek into my shattered mind]
#60 Crossbones+ - Reputation: 1038
Posted 03 December 2012 - 09:05 PM
This is a good demonstration of how confusing C++ is. Cornstalks told you exactly what happens, you went and tested it, and you are still wrong.Ok when i saw that code i thought hmm pretty clear it should be the int constructor since the object doesn'exist yet....then i saw your explanation and i shrug...really? then i tried it just to be sure....first instinct was right your "spoiler" is wrong
He said that the int constructor gets called, then the copy constructor gets called, but the compiler is allowed to optimize the copy constructor away. In the case of your particular compiler, your particular compiler version, your particular computer architecture, your particular compiler settings it so happens that the compiler does that optimization and only calls the int constructor. But with some other configuration of those things, the same code would result in both constructors being called, and in both cases the compiler could be a completely valid C++ compiler. This repeats over and over again in the language: valid C++ compilers are allowed to do a wide range of things, and if you want your code to be valid C++, it has to withstand all of those things. Therefore you have to know what the language says. If you don't know the copy constructor may get called there and you assume it won't, that can blow up in your face at some point in the future.






