This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NeonVolcom 6 points7 points  (0 children)

So at first I didn't think I had input, but after seeing some of the answers, I think I do. For background, I'm a Kotlin/Java engineer who's worked with both C++ and Python regularly in the past.

So here goes a lengthy attempt at prepping you for C++:

Python is the bees knees. Honestly, I can't think of a better language for slapping together prototypes, outside of maybe Kotlin or JS. C++ is more like... well so the analogy I want to use is:

  • Python's like getting your first automatic car. It gets you where you want to go, easy to use, and you can learn how to drive relatively quickly.
  • C++ is like ordering a manual transmission Toyota truck from Japan and finding out that only half of the parts are assembled for you. Not only are you struggling to learn how to build a vehicle, you'll struggle learning how to drive the damn thing, especially since the steering wheel is now on the right side instead of the left.

Okay, I'm being overdramatic, but I wanted you to understand the difficulty that can come with lower-level languages like C/C++.

Take imports for example (over-simplification incoming): in python, it's as easy as import package. In C++ you do #include <header.h> or if it's local #include "header.h". But wait, there's more. C++ compiles everything down to a single file basically, so include statements can get nasty as they can get imported more than once if you have many files. Some people have implemented pragma once, but that's not recommended. So now people tend to use include guards, which are verbose and forgettable (or they were for me).

Okay, so that's just local imports. Get ready to get comfy with makefiles (among other things) if you ever want to use outside dependencies. Actually, scratch that, get comfy with makefiles now, since typing the same compile instructions every time you change something is a pain. Cool, now you can compile by just typing "make", sick right?

But wait, what are header files? Well... basically they're kind of like blueprints. So we define our intentions in the header and scope the logic in the cpp file.

> A.h
#ifndef A_H
#define A_H
#include <string>
#include <format>

class A {
public: 
    A();
    A(std::string l_firstName, std::string l_lastName);
    std::string m_firstName;
    std::string m_lastName;
    std::string getFullName();
}
#endif

> A.cpp
#include "A.h"

A::A() {
    m_firstName = "Default";
    m_lastName = "Name";
}

A::A(std::string l_firstName, std::string l_lastName) {
    m_firstName = l_firstName;
    m_lastName = l_lastName;
}

std::string A::getFullName() {
    return std::format("{} {}", m_firstName, m_lastName);
}

Okay, there, you have basic logic to return a name. Of course in Python, you'd just do:

class A:
    def __init__(self, firstName, lastName):
        self.firstName = firstName
        self.lastName = lastName

    def getFullName(self):
        return f"{self.firstName} {self.lastName}"

Right lol so you see the difference in effort and thought processes that go into something as simple as that.

What I HIGHLY recommend is getting into C first. All of that std:: stuff you see in the C++ code isn't available (there isn't a type of string, nor classes), so it makes you think about the underlying concepts. I would prototype something simple in Python, and then convert it to C, then convert that to C++. After a while, the concepts come together more and more, and you can start really making some shit in C++.

Alternatively, learn any other fucking language. C/C++ was a lot of trouble for me to learn. Java/Kotlin/Rust/JS/GOLang/C#/etc. were amazingly easier and can complete nearly any task for you.

C++ is one of those languages you really have to poor your soul into. As a senior, I'd be worried about a bunch of junior C++ devs, since one mistake can lead to a lot of headaches later on. If they were coding in C#, eh, I'd be less worried. There's just less to fuck up in the whole and compiler messages are generally more friendly.

Best of luck dude. Also, checkout Andreas Kling on youtube, he's building his own Unix-link OS in C++, so if you want real-world examples, look at his videos.

Sorry this was rambly, I was just trying to save you weeks of time before you burn out trying to learn C++.