DEV Community

Vincenzo
Vincenzo

Posted on

What do I need to go back to C++ in 2021

Back in early 2000s, while I was in High Scool, straight after some Pascal, and some Visual Basic, I got introduced to a weird mix of C and C++ by a confused professor, and being taught that it was C++. I loved it anyway.

Skipping few years forward, I learned it properly at uni (where properly means being thought c++98 as if it was the modern c++), while on the side I was doing some php, ruby, python and Java, moving away from the lower level and up to an higher level of abstraction, who needs to play around with memory management in 2007-8-9 (can't remember the year exactly) right?

Still loved it.

Skipping ahead few more years, it is 2020, and I have been working professionally in webdev for the last 10 years, so I moved away from C++, moved away from Java, did some C#, did some PHP, then mostly Javascript and the likes.

Until 2020 hit, and I decided to learn to some some game development.

After a whole year and few interesting projects, I decided to go back to my roots, and re-learn again C++, after many years of working with higher abstraction/level programming languages, to try out some game engines eventually, and work on a possible C++ native version of some games ideas I have on a notebook since I was a kid.

Been reading how the language has evolved in the years, and yet still how divided the community is about tooling/build system/package management.

All of that make me want to learn rust (which I tried and I find a bag of wank syntactically speaking).

So that is why I want to ask you, beautiful people of Dev.to, if you have any suggestions on path to learn the most modern C++ patterns, to be precise I would do a small list things I would love to know. (Just to let you know I use mostly linux, but I do own a Mac for work and a Windows pc too, so would be nice if you can keep that in mind, I would love to have my tooling multiplatform)

  1. I do not care about basic tutorials, as I said worked with many languages and I did spent few days to refresh what I knew. But would be nice if there was a list of new cool features and how to use them with code examples (lambdas and the likes), or even a podcast/blog/youtube channel with nice tutorials about a bit more advanced topics.

  2. Would be nice to know how to setup a good dev env on Linux/Windows/Mac. clang g++ cpp? which and why? Cmake? plain makefile? bash scripts to build?

  3. Best (Free/Cheap) IDE? been trying VSCode (as I use it for everything else) and it is a bit iffy at times. I do not like Eclipse and I cannot use Visual Studio on Linux :'(

  4. Best way to scaffold a project? Seems like there are millions of different options/opinions, would be interested into your personal experiences on those, and why having all in src/ and subfolders of that is better than having /libs/ and /src/ or whatever. Are there cli tools that generates projects structures for you that are standardish?

  5. Package managers? I been looking into conan and some others I cannot even remember the name of. Are they necessary? I have seen around how cool the boost libs are and I wouldnt mind to have them installed on my pc and then link them while I build, but it sounds like a nightmare if I want to put my code up somewhere to have to add on the readme Install this lib doing x and y before compiling rather than just having to run something like conan install && cmake build or whatever.

  6. Is it good to use straight away C++20 or are there like 99% of the libs that do not support it? How to use different version in different projects? is it just that flag on compilation or do you need to install something like virtualenv in python or nvm for node?

  7. Unit Test Libs? I saw that loads of people use that GTest something, are there other ones, that maybe are easy to get via a package manager and set just for your local project rather than machine-wide?

  8. Code Generations via IDE, I had forgotten the .hpp contains declaration and the .cpp contains the actual implementation of a class paradigma, god it sounds quite annoying, are there IDE tools where you can just generate the code on the .cpp file after declaring the signature on the .hpp file?

  9. How are you doing still working on C++ on 2021? Are you happy or do you wish you had done something else?

  10. Do you think it is stupid to try to catch up on C++ on 2021?

Thanks everyone for reading this.

Discussion (15)

Collapse
sandordargo profile image
Sandor Dargo

It's definitely not a bad idea!

As you're looking for non-beginner sources to follow, here you have a collection of a couple of cool blogs:

github.com/sandordargo/cpp-resourc...

I hope you'll like at least some of them.

Collapse
vikkio88 profile image
Vincenzo Author

oh nice one man, thanks

Collapse
pgradot profile image
Pierre Gradot

You can also read all the articles by Sandor Dargo on dev.to ;)

Thread Thread
sandordargo profile image
Sandor Dargo

Thanks :)

Collapse
elvisoric profile image
Elvis Oric

Hello there, It is not stupid at all.

To refresh your knowledge you can use A Tour of C++ (C++ In-Depth Series) book by Bjarne Stroustrup

Personally I use heavily customized vim as IDE. For the build system, I am using meson.build and conan as package manager. You can check my sample project where I use meson and conan github.com/elvisoric/conan_meson

Collapse
vikkio88 profile image
Vincenzo Author

hi there, thanks for sharing those, I have been really into it for a few weeks now, loving it still.

I wanted to ask you, why meson instead of cmake? everyone seems to be using cmake around, is it because the syntax is slightly nicer?

Collapse
elvisoric profile image
Elvis Oric

For me, meson is much more natural to use. I used cmake for a few years and i didn't like it at all. From syntax, versions, documentation, etc. I still use cmake but only to build some projects (Everyone uses it and everyone hates it ).

Thread Thread
vikkio88 profile image
Vincenzo Author

loool I thought so, I agree the syntax is horrific, but once you get used to it seems fine.

might not have been bitten by it yet I guess

Collapse
darshan_tweet profile image
Vincezno • Edited on

Keep in mind that damn C++ still evolves fast and keeps adding new stuff, I wrote some tutorial in 2010 and they are already useless.
Said that:

  1. tutorials and books
    C++ Succinctly from Syncfusion, 100 pages, you read it cover to cover.
    OReilly - Effective Modern C++ - Scott Meyers, the only book I follow.
    github.com/isocpp/CppCoreGuidelines the Cpp Core Guideliness.

  2. Compilers
    Clang and GCC have the same features ( as input language, not talking about output format) but I think Clang have better error messages and better code analysis tools.
    Linkers error in GCC are usually gibberish.

  3. IDE
    I didn't do much C++ on Linux recently... Visual Studio is the best I know, CLion is good too.
    Back in the time I enjoyed KDevelop but you will need KDE.

  4. Best way to scaffold a project?
    No clear standard, some people like headers only, some people still do the .h/.cpp separation, modules are not yet used much.

  5. Package managers?
    Pure mess. On visual studio you have NuGet, it works but it's clumsy.
    I like vcpkg (github.com/microsoft/vcpkg) but it's not that common.
    Never tried conan. CMake is usually a good option.

  6. Is it good to use straight away C++20
    Go for it, almost everything is still supported... just most of the older ideas are now bad ideas.

  7. Unit tests.
    I only used GTest so far.

  8. Code Generations via IDE
    No idea, but headers-only is still an option.

  9. How are you doing still working on C++ on 2021?
    It's like driving a tank with lots of button in the cockpit.
    Some of them you need, some you may need, some are useless, some will make the tank explode.
    It's a hell of a language, but I don't know anything better for game programming or low level stuff with class based OOP.

  10. Do you think it is stupid to try to catch up on C++ on 2021?
    If you plan to use it, no.
    If you just want to know it, well I'm studying Scheme, who am I to judge? xD

Collapse
pgradot profile image
Pierre Gradot

I recommand CMake as you build system, to generate either makefiles or nija files.

GCC or clang are both great.

CLion by Jetbrains is my favorite but it's not free nor does it have a community version. Visual Studio Code is quite good too (and it's free) and has plugins for everything.

I highly recommand this website for tutorials about modern C++ modernescpp.com/index.php/what-is-.... I see its on @sandor Dargo's list ;)

The main features for me in modern C++ (as opposed to C++98): auto, constexpr, lambda functions, std::function, std::variant, variadic templates, smart pointers, std::optional.

Do you think it is stupid to try to catch up on C++ on 2021?

You can't start with C++14 IMO.

Unit Test Libs?

I have used Google Test and Catch2. Both are good. I want to try out doctest, which seems to a fork of Catch2 that compiles much faster.

are there IDE tools where you can just generate the code on the .cpp file after declaring the signature on the .hpp file?

CLion can more or less to this: "create class" will generate 2 files. Declare the class in hpp, go to cpp and do "generate defintions" for all functions.

Are there cli tools that generates projects structures for you that are standardish?

As far I as know, there is no de factor standard project structure.

Collapse
vikkio88 profile image
Vincenzo Author

GCC or clang are both great.

any particular reason why some people seems to prefer clang over gcc around the web tutorials I have found?

CLion by Jetbrains is my favorite

man Jetbrains people are the best, pity that they dont have a community version, dont feel like throwing money at it just yet.

thanks for all the info btw

Collapse
sandordargo profile image
Sandor Dargo

I'm not sure if this changed... But when I used CLion without a license it quitted after every 30 minutes. Apart from that it was fully usable and taking a break every half an hour is not that bad :)

Thread Thread
pgradot profile image
Pierre Gradot • Edited on

I have never used in clang in a real project for 2 reasons: I work on Windows and mainly for embedded projects.

From the few experiments I did, clang seems to have even better error messages.

You're welcome btw ;)

Collapse
ravikrishnappa profile image
Ravi Krishnappa

Interesting adventure. I guess you 're doing it for fun. Writing videogames code is not for regular slow action application developers (forum, social media, ecommerce, ERP).

I guess games are developed using domain specific languages. C or Cpp may be too generic.

I spent a lifetime developing ERP kind of business applications. Oracle PL/SQL and Unix knowledge was enough to get things done. Oracle provided everything. Forms and reports builder. And CLI

Recently I learned Rust, Go, Julia, Python, Node.js, Typescript and entered a world of open source code, libraries and communities. I hope your Cpp experience will be similar. Things have changed a lot and communities are learning from each other.

Collapse
vikkio88 profile image
Vincenzo Author

Writing videogames code is not for regular slow action application developers

slow app developers lol. thanks I guess