Learning C++ from a Python Perspective

12 Jan 2019

This post is a little less directed than some of my recent ones, but I was taking a break from another round of C++ practice, and I thought I’d reflect on my experiences with the language so far in comparison to Python. In the past I imagine a compiled language like C++ or Fortran were many Physics students’ first interaction with computer programming, making it a little wonder that in the 70s/80s so many IT companies were started by former Physics students…

However by the time I went to university, in their wisdom, most Physics departments had heavily reduced or even stopped teaching computation as a compulsory subject. By the early 2010s I suppose scripting languages had become so widespread, and handy, there was little need for new Physicists to learn how to do complex pointer arithmetic to solve a differential equation when they could use SciPy.

However, this gap in training gives one a false sense of security, and learning C++ I’ve realised just how much of a ball ache programming must have been in the past, when there weren’t any amazing editors (props to VSCode) to point you in the right direction, compilation/linker errors must have been the stuff of much anguish.

I feel much more grateful than I did before for Python and its general utility, and abundance of open source libraries. It made the world of computing seem so accessible, and easy, and allowed you to work on the problem without wasting hours and hours just setting something you barely understood up! However learning C++, again has given me a little bit of an understanding of how big of a jump it must have been itself - classes and OOP being so fundamental in the language, and being so new upon its release.

I also now finally understand why no-one suggests that you begin computing with C++, if you don’t already have a good understanding of OOP concepts, a lot of will just go over your head. Even if you do, it’s weird, often byzantine, syntax is easily enough to throw even the most confident Python newbie. With the STL metalanguage, C++ itself, and the massive standard library - there’s a huge amount of raw information just to ingest, before you can start doing some wizardry. However, I suppose it’s a little bit easier if you were already half way towards being a wizard when you started learning it.