Being a JavaScript developer all this time, it struck me that I have a view of development and how the code works, that is not precisely the same as other languages out there.
All it takes is opening an Open Source code in Ruby on Rails, for instance, for me to start wondering how things work the way they do, since in JS everything kinda makes sense to me. This is absolutely true for me when looking at C++ code, so in my new journey of studying a new language, and doing some fun projects, I can't stop thinking about my way of viewing things, and how I can explaing to myself, how things work using JS analogies.
This led me to a different way of studying C++, so this reading may be particularly useful if you're a JS developer studying C++ for some reason (who would do that?!). I've tried looking for some books, or guidance on where to begin, and even managed to find a very concise list of books, which I'll definitely read later on, but for now, I decided to follow along C++ Reference tutorials, which should be enough for now.
This post was written at the sound of:
The basics
Alright, let's start with our favorite program of all: Hello World:
If you want to give it a whirl, open up a terminal (I'm running Ubuntu 20.04), access the folder where the file is located, and run:
# Compiles the .cpp file on the folder as 'hello_world'
make hello_world
# To run, just go with:
./hello_world
Variables
Ok, we all know how variables work, no big deal here. I just want to store the actual table of available data types we have on C++, coming straight from the documentation:
Now, here's the gist with what I've learned so about variables:
Operators
Operators is something I won't go too much in depth, as they are pretty much the same among languages, BUT, there are some topics that I think is important that I cover and talk about:
If for whatever reason you're following this posts, and run the gist above, I've left some variables unused on purpose, and it is very likely that whatever IDE you're using will scream at you a warning like so:
If this happens, feel free to ignore it, or simply print the values of those variables, and the warning should go away.
IO Operations
Here we have a couple of examples of how to deal with input from the user, as well as a very nice function called stringstream
:
Wrapping up
This should cover enough ground for me to start building some simple stuff. It was a fun ride so far, but there is still a LOT of ground to cover, but thanks if you've read so far. Hope to see you soon!
Top comments (0)