Beginners Guide to C++

C++ is one of the most popular programming languages available today. Originally called C with Classes, the language was renamed C++ in 1983. It’s an extension of the original C language and is a general purpose object-oriented (OOP) environment.

Due to how complex the language can be, and its power and performance, C++ is often used to develop games, programs, device drivers and even entire operating systems.

Dating back to 1979, the start of the golden era of home computing, C++, or rather C with Classes, was the brainchild of Danish computer scientist Bjarne Stroustrup while working on his PhD thesis. Stroustrup’s plan was to further the original C language, which was widely used since the early seventies.

C++ proved to be popular among the developers of the ‘80s, since it was a much easier environment to get to grips with and more importantly, it was 99% compatible with the original C language. This meant that it could be used beyond the mainstream computing labs and by regular people who didn’t have access to the mainframes and large computing data centres.

C++’s impact in the digital world is immense. Many of the programs, applications, games and even operating systems are coded using C++. For example, all of Adobe’s major applications, such as Photoshop, InDesign and so on, are developed in C++. You will find that the browser you surf the Internet with is written in C++, as well as Windows 10, Microsoft Office and the backbone to Google’s search engine. Apple’s macOS is written largely in C++ (with some other languages mixed in depending on the function) and the likes of NASA, SpaceX and even CERN use C++ for various applications, programs, controls and umpteen other computing tasks.

C++ is also extremely efficient and performs well across the board as well as being an easier addition to the core C language. This higher level of performance over other languages, such as Python, BASIC and such, makes it an ideal development environment for modern computing, hence the aforementioned companies using it so widely.

While Python is a great programming language to learn, C++ puts the developer in a much wider world of coding. By mastering C++, you can find yourself developing code for the likes of Microsoft, Apple and so on. Generally, C++ developers enjoy a higher salary than programmers of some other languages and due to its versatility, the C++ programmer can move between jobs and companies without the need to relearn anything specific. However, Python is an easier language to begin with.

If you’re completely new to programming then we would recommend you begin with Python and spend some time getting to grips with programming structure and the many ways and means in which you find a solution to a problem through programming. Once you can happily power up your computer and whip out a Python program with one hand tied behind your back, then move on to C++. Of course, there’s nothing stopping you from jumping straight into C++; if you feel up to the task, go for it.

Getting to use C++ is as easy as Python, all you need is the right set of tools in which to communicate with the computer in C++ and you can start your journey. A C++ IDE is free of charge, even the immensely powerful Visual Studio from Microsoft is freely available to download and use. You can get into C++ from any operating system, be it macOS, Linux, Windows or even mobile platforms.

Just like Python, to answer the question of Why C++ is the answer is because it’s fast, efficient and developed by most of the applications you regularly use. It’s cutting edge and a fantastic language to master.

Equipment You Need to Start with C++

You don’t need to invest a huge amount of money in order to learn C++ and you don’t need an entire computing lab at your disposal either. Providing you have a fairly modern computer, everything else is freely available. Most, if not all, operating systems have C++ in their code, so it stands to reason that you can learn to program in C++ no matter what OS you’re currently using.

Computer – Unless you fancy writing out your C++ code by hand on a sheet of paper (which is something many older coders used to do), a computer is an absolute must have component. PC users can have any recent Linux distro or Windows OS, Mac users the latest macOS.

An IDE – Just as with Python, an IDE is used to enter and execute your C++ code. Many IDEs come with extensions and plugins that help make it work better, or add an extra level of functionality. Often, an IDE provides enhancements depending on the core OS being used, such as being enhanced for Windows 10.

Compiler – A compiler is a program that converts the C++ language into binary, so that the computer can understand. While some IDEs come with a compiler built in, others don’t. Code::Blocks is our favourite IDE that comes with a C++ compiler as part of the package. More on this later.

Text Editor – Some programmers much prefer to use a text editor to assemble their C++ code before running it through a compiler. Essentially you can use any text editor to write code, just save it with a .cpp extension. However, Notepad++ is one of the best code text editors available.

Internet Access – While it’s entirely possible to learn how to code on a computer that’s not attached to the Internet, it’s extraordinarily difficult. You need to install relevant software, keep it up to date, install any extras or extensions and look for help when coding. All of these require access to the Internet.

Time and Patience – Yes, as with Python, you’re going to need to set aside significant time to spend on learning how to code in C++. Sadly, unless you’re a genius, it’s not going to happen overnight, or even a week. A good C++ coder has spent many years honing their craft, so be patient, start small and keep learning.

OS Specific Requirements

C++ will work in any operating system but getting all the necessary pieces together can be confusing to a newcomer. Here are some OS specifics for C++.

Linux – Linux users are lucky in that they already have a compiler and text editor built into their operating system. Any text editor allows you to type out your C++ code, when it’s saved with a .cpp extension, use g++ to compile it.

Windows – We have mentioned previously that a good IDE is Microsoft’s Visual Studio. However, a better IDE and compiler is Code::Blocks, which is regularly kept up to date with a new release twice a year. Otherwise Windows users can enter their code in Notepad++, then compile it with MinGW as used by Code::Blocks.

Raspberry Pi – The Raspberry Pi’s operating system is Raspbian, which is Linux based. Therefore, you’re able to write your code out using a text editor, then compile it with g++ as you would in any other Linux distro.

Mac – Mac owners will need to download and install Xcode to be able to compile their C++ code natively. Other options for the macOS include Netbeans, Eclipse or Code::Blocks. Note: the latest Code::Blocks isn’t available for Mac due to a lack of Mac developers.

Find more guides like this in…

David Hayward

David has spent most of his life tinkering with technology, from the ZX Spectrum, getting his hands on a Fujitsu VPP5000/100 supercomputer, and coding on an overheating Raspberry Pi. He's written for the likes of Micro Mart, Den of Geek, and countless retro sites and publications, covering reviews, creating code and bench testing the latest tech. He also has a huge collection of cables.

Related Articles

Back to top button