Program The rantings of a lunatic Scientist

Why C++ is only mortal

C/C++ L2Program Rant

Another opinion piece if you’ll grant me the time. Not that there’s anyone to read it but this site, much like blogging was in the olden days of the internet is really more of a hobby and for peace of mind than anything else.

This post was once again inspired by a comment on reddit asking why there were so few good resources for people who wanted to start their education into programming and software engineering by learning in C++.

In my honest opinion as a developer, a computer scientist, and as a teacher the reason there are no “good” resources for people looking to start with C++ is because C++ is just not something you should start with.

Programming is a relatively unimpressive skill to have on its own. The knowledge and ability to design software on the other hand is an incredibly powerful thing to be able to do. Having that ability gives unmeasurably high value to your ability to program, and it scales with how many paradigms, languages, and platforms you can take that to.

Programming is simply syntax wrapped around design. A house is a design built in brick, and likewise a piece of software is a design programmed in syntax.

Now tell me, is it of vital importance that you learn all the engineering principles, all the design aspects, all the architecture concepts, and all the safety mechanisms to build a house at the same time as you learn to lay diamond encrusted bricks in the most elaborate and complicated way possible? Of course it isn’t! It’s much more sensible (and safe) to learn to build a house with normal, simple, sensible bricks and then work on your skills and work your way up to laying diamond encrusted bricks in fancy patterns.

In exactly the same way, this is why someone who has never programmed before should not just dive into C++. Why make life harder for yourself when you just aren’t going to benefit from it? It’s much more sensible (In my opinion at least) to learn about language structures like loops and conditionals, and then learn about Imperative design patterns, and Object Oriented design patterns, and learn about inheritance, and interfaces, and type checking, object references, and data structures, and algorithms, ect, in an easy to pick up and safe to f#$k up language like python or java or C# who all have simplified and friendlier syntaxes (I’m not looking to start a war of which language is best/worse). Then if and when you have a use or a desire to use C++ you already know how to design the house. All you need is the bricks and mortar.

People become complacent and become afraid to branch out from their comfort zones

Another thing that really comes into play here, and this can be a really touchy subject for a lot of developers. You need to pick the language that’s right for the job. And as often is the case, there will be no perfect language. There will certainly be ones which are worse than the others, but there may be several who all excel towards one aspect of your goal but each fall short in some way making none of them quite right. In this case you need to pick the one you feel most comfortable with and roll with it.

A lot of the time I see people trashing languages, Java gets a terrible reputation and a similarly PHP developers have to hide their heads in shame as they pour their coffee at lunch. This (to me) is ridiculous. Each has it’s benefits, and each has it’s laundry list of shortcomings; just like every other language. Every language has it’s purpose, even BrainFuck and MOO had a place in the scientific community. Developers get really attached to their languages and tool chains and far too often they would rather reinvent the wheel bulkier, buggier, slower, and harder to use just to stay within their comfort zone so they don’t have to swap environments (or sometimes even as little as changing their IDE for five minutes…).

So here’s my point.

If a person is coming into a development situation fresh, and they have no prior knowledge of programming, and they have to (unavoidably have to) be developing in C++ for whatever reason, then that person is catastrophically unprepared for what they have walked into. Plain and simple. However, if that person just inherently thinks of C++ as the ultimate in coding and they want to do it in C++ just because then chances are 99.999999% of the time they can do it in a different language, a language that will be friendlier, be easier to learn in, will have libraries which are far easier to incorporate and run with, and will have a development environment which is often far easier to setup and target for their system. More importantly, is a person who is fresh to to all of this and knows very little on the subject really in a position to make an informed decision on what environment is “the best one, I must use that one!” ? By very definition they are not.