Welcome to C++ Jungle
Tags: cpp
Published: 2020-06-17 16:32:34

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](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list), which I'll definitely read later on, but for now, I decided to follow along [C++ Reference tutorials](http://www.cplusplus.com/doc/tutorial/program_structure/), which should be enough for now.

This post was written at the sound of:
{% spotify spotify:album:5YFcEg0KaTy1Q20EYfsCR2 %}

---

# The basics

Alright, let's start with our favorite program of all: Hello World:
{% gist https://gist.github.com/MarcoBomfim/661f20ad9cb8e4aa4cb0aadd522bcf19 %}

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:
![Cpp_Data_Types](https://dev-to-uploads.s3.amazonaws.com/i/kk5kxch49owjn36dzosf.png)

Now, here's the gist with what I've learned so about variables:
{% gist https://gist.github.com/MarcoBomfim/6f0a25624ef72e2c66b90466f06278cb %}

---

# 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:
{% gist https://gist.github.com/MarcoBomfim/f24e3bfe0633f5fc69f5882277078430 %}

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:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nw0dgr1mvjs6x3c4twjs.png)

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`:
{% gist https://gist.github.com/MarcoBomfim/cd0f7ed211ed2f1ffb9c2e8157959991 %}

---

# 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!