SAM MORRELL


ASTROPHYSICIST

My Challenge – Learn C++

April 12, 2012   |   Reading time: ~4 mins

Most people who know me will tell you that I’m not one to shy away from a challenge. This is one of those occasions where said stubborn jack-assedness comes in quite useful. Many times before I have wanted to learn the programming language, C++, however as I’ve come to discover, this is no easy feat. So, my challenge to myself is to become proficient in C/C++.

It’s at this juncture I should probably mention my motivation. The first language I learned to any great proficiency was Visual Basic.net. Though this was all I was capable of at the time, it was a very bad idea. My advice to anyone starting out with programming is to not start wit VB. Having knowledge of it is esoteric at best, and while programming with it will give you a rough idea how programming works, the syntax of the language will seriously screw you up when you try to write using a ‘proper’ language. The next language I learned was PHP. My advice to anyone wanting to get into programming would be to try and start with PHP. It’ll give you a very sound grounding in the syntax of most commonly used languages, it has a relatively good object orientated component when you’re ready to move up to it and it’s weakly typed so you don’t have to worry about type casting and the such, as PHP does it for you. The reason I’m belittling VB is quite simply because when I attempted PHP for the first time, the bad habits that VB sets you into are very difficult to break out of, so for example I’d end up getting a significant amount of syntax errors due to lacking a semicolon at the end of a statement, which PHP and almost every other language require but VB does not.

Now, I’m going to be doing it again. In learning C++ I’m going to have to get out of the bad habits I’ve picked up with PHP. I’m wanting to learn C++ quite simply because it is the programmers language. Most high performance applications on the market today are written wholly or in part using C++. The language itself is strongly typed, meaning that you have to do all the type conversions yourself else the compiler throws an error, you have to worry about memory allocation and pointers and it also has a minimal library to fall back on, which forces you to either write complex algorithms yourself, which I’m gong to have a crack at, or track down supporting libraries yourself. This is where I have to break bad habits again. PHP has a myriad of functions and pre built objects and interfaces to fall back on when you’re writing code, so instead of writing things yourself you tend to search out the function that does it for you. Also, you don’t particularly have to worry about the types of variables in PHP, because the interpreter will automatically type and convert types when you combine them together. In C++, merely trying to concatenate a character array with a floating point number will throw an exception. So, this is merely the next step up in becoming a mildly useful programmer.

You might now be asking “why not learn Visual C#?”. Well, the simple answer is that I have. I’ve written a couple things in C# over the years, but the thing that I dislike about C# is that it falls under the the .NET framework’s Common Language Runtime, meaning that when you compile it, you compile to merely a byte code rather than binary and at runtime the virtual machine then interprets this byte code. This is useful as then you don’t have to compile for different architectures, but it has some serious downsides. You have to constantly rely on Microsoft’s .NET framework which means that code you write is effectively tied to Windows. Also, the fact that it’s interpreted byte code means that, compared to compiled languages, you’re taking a performance hit. Also, when I was writing code in C# I was constantly referencing Microsoft’s pre written functions which always felt like cheating to me. C++ is a chance for me to try and become a better programmer and computer scientist be removing all the abstraction and get back to basics. Let’s see how it goes. I’m betting I loose this resolve within the week.

If you have been, thanks for reading.

Tags:

You Might Also Like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments

Sorry, there are currently no comments for this artcle. Why not start a conversation?