The web is huge and all encompassing. Coding boot camps, by and large, only teach web development languages and techniques because every business needs a website. This means there are an incredible amount of jobs for web developers open (I didn’t even filter the results on Stack Overflow to prove this point). Everybody has a smartphone in their pocket which runs apps backed by web services. Much of #techtwitter talks about web development or phone app development. Given all of this focus on app and web development why would you want to learn C++ these days?
To answer this, we need to know a few things:
- What is C++ currently used for?
- Why wouldn’t you want to learn C++?
- How hard is it to learn?
- Are there enough job openings to warrant learning it?
In my somewhat biased opinion the answer is yes it is worth learning. There are interesting problems to be solved in a way that C++ can handle well. While there are gotchas to the C++ that other languages protect a developer from many of these have been solved with recent additions to C++ and its core libraries.
What Is C++ Used For In 2021?
C++ has long been associated with solving problems where performance and/or fine grained control over resources is a priority. This includes this like:
- Programming embedded devices
- Game/graphics engines
- Mathematical libraries (used in scientific computing)
- Financial calculations
At the time of writing this I am working on code that runs on an unmanned aerial vehicle. We use C++ because we need to ensure that the code that handles things like temperature sensing, relay control, and control over the flight surfaces of the plane operate quickly enough to keep the plane flying. While there are other languages that could likely perform meet this performance requirement there are a few other reasons.
Much of the simulation that tests how the plane is going to work and run our software happens in Matlab and Simulink. It is easy to integrate C and C++ software with Matlab. Additionally, as part of this testing, we use various PXI/PXIe cards (computer expansion cards with a specialized interface) such as programmable resistor cards to emulated resistance based thermometers and communications cards that handle aviation specific messaging. The APIs for these cards are presented in C or C++.
What I’m working on is just one of many interesting problems that can be solved in the arena of software engineering. C++, in this case, happens to be a great tool for the job despite the upcoming reasons that you might not want to use it.
Why Wouldn’t You Want To Learn C++?
While there are several things about C++ that are challenging the most prominent of the issues is memory safety. C and C++ give a developer control over the memory that is being used. This can be one of the keys to wringing extra performance out of an algorithm. It is also historically and currently one of the biggest security risks in any software. In other words: It’s a gigantic footgun that comes with it’s own hostler:
While memory safety is the biggest issue, in my opinion, with using C++ many of the actual issues with memory safety have been resolved with recent additions to the C++ language. One of the largest issues surrounds when new memory is allocated, when it is released (freed), and if the memory is used before allocation or after release. This issue has historically been solved by wrapping the memory in a class and by doing the allocation and release in the constructor and destructor respectively. This is known as RAII; Resource Allocation Is Initialization. If the memory is only used by the object and is released when the object is then it “should” eliminate the problems of use after releasing. The advent of smart pointers in C++11 do this internally to make life easier for developers and are part of the language and all implementations of the standard library.
How Hard Is C++ To Learn?
This is a question that many developers or aspiring developers will ask and, of course, it really depends on your current level of experience and why you want to learn C++. If you’re just starting out your journey as a developer and you’d like to learn C++ to be able to develop games there will be a steep learning curve for both C++ AND the non-programming knowledge you’ll need for the game industry. If you’re a seasoned developer with experience with a statically typed language already and you already possess the business knowledge to create your product you’ll have a pretty easy time learning syntax and library calls. Most folks will find themselves somewhere in the middle.
The internet is, as always, there to help with myriad tutorials and getting started guides to help you along the path. The resource that will help you best depends on your experience so far. I will link to both a book that will help a beginner with the language and fundamentals and some getting started resources that will help those with some experience.
The C++ Programming Language by Bjarne Stroustrop is the definitive guide to the language written by the person that designed the language. Given that it is a little older and only covers up to C++11, I’d also recommend getting A Tour of C++ (also by Bjarne) which is shorter and updated through parts of C++20. This guide from CareerKarma is tailored toward beginners to the language; while it seems overly simple to me I’m likely jaded from having figured out most of what it says on my own.
Are There Any Job Openings Using C++?
To be short, yes. As with most jobs in the software engineering field many of these will want loads of experience with the language and tools they’re using and extensive knowledge of their particular domain of work. Also as with most jobs you should apply anyway once you have a modicum of experience. If you’ve got a friend working somewhere with a job opening who can tell you what they actually need and what they are willing to teach that’s even better. As of the time of writing/publishing the initial version of this article the company I work for is looking for someone in the Sacramento, California to help me with what I’m working on.
C++ is a powerful tool that can be used to accomplish a great many programming tasks. It also comes with dangers that can pose security risks; these risks, however, can be a great opportunity to learn about the details of how memory allocation and usage works. I, personally, love using C++ because it is used to implement the deep, dark details of many operating systems. I find these details fun an interesting to work on and, as such, would highly recommend the language to anyone willing to listen.
For more information that I’ve shared re FF adding C++, please check out the following posts:
Thanks for the good and (rather!) neutral piece. I sometimes feel like C++ is the latin of computer languages: if you know it, most other languages are much easier to learn because C++ pre-dates most and has influenced most of them. Also, it takes a little more effort to learn C++, and commands a little more respect if you “speak” it :-).
You’re welcome. I’m not sure I’d say that it commands more respect to everybody in the software industry if you speak it. More like the people who need it. It’s a tool and is good at some things and terrible at others.