DEV Community

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

Vincenzo on March 18, 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 ...
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

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

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

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

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

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

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

Writing videogames code is not for regular slow action application developers

slow app developers lol. thanks I guess