C++ is a pleasure to work with.

2    14 Mar 2019 23:17 by u/skruf

The team I work with produces nice readable code, it is usually a breeze to perform maintenance... However that really doesn't prove my point, so feel free to provide some examples why it is not a pleasure.

21 comments

0

Another point in its favour is that it's not Java.

0

* and & are cancer

0

The main issue with C++ is the amount of undefined behavior and the very high amount of knowledge you need to write "legitimate" code.

There's just so many pitfals.

That being said - I really love it. It's my favorite language by far.

0
int (int arg)
{
    int x;
    if (arg > 0)
        x = arg;
    return x * x;
}
0

I don't agree. C/C++ Takes more effort than Rust, D, or especially Nim. C/C++ is uglier code, lots of boilerplate, slower development, and much higher likelihood lethal bugs (which can cost a company millions).

With the aforementioned languages you can still write lower-level code with manual memory management that's as efficient as C/C++, and easily interface with all of C/C++ libraries. But 90% of the time using higher-level features and GC is a good trade-off (and they're still faster than Java, C#, Go, Haskell, etc).

0

Most languages are at this point. But C++ has so many features, if you don't know what to do with them, it's very easy to make a mess of things.

0

Overflow.

0
void recurse()
{
    recurse();
}
0

cout << what << the << fuck << is << this << shit

0
0

meh

0

Slow compilations,

0

Just don't go full retard on meta programming, I guess

0

That's one of the best parts of C++ though.

0

This one may be subtle, but is fairly obvious to the intermediate C++ developer.

I basically demonstrate wrong use of shared ptr:

#include <memory>
#include <iostream>
class Whatever
{
public:
    Whatever(int a) : m_a(a) {}
    std::shared_ptr<Whatever> getptr()
    {
        return std::shared_ptr<Whatever>(this);
    }
private:
    int m_a;
};
int main(int argc, char* argv[])
{
    std::shared_ptr<Whatever> instance = std::make_shared<Whatever>(123);
    std::shared_ptr<Whatever> same_but_diffrent = instance->getptr();
    std::cout << "instance: " << instance.use_count() << std::endl;
    std::cout << "diffrent: " << same_but_diffrent.use_count() << std::endl;
    return 0;
}

Outputs:

~$ ./a.out 
instance: 1
diffrent: 1
double free or corruption (out)
zsh: abort      ./a.out
0

It's an object oriented programming language, and not a even consistent one.

0

I would say it really is not; if it were, we could not have free standing functions or global variables and other fun things... But yeah you can, and should, use OOP designs in C++. C is cool, too. Especially the older versions without type checking.

0

I love modern c++

0

On reason is that the IDE's are still not up to speed. Refactoring in C++ is never as nice as it is in intellij. Additionally, code completion, type hints, and other elements are pretty much fucked in all IDE's when they are behind templates.

0

I have found Qt Creator fairly good with this issue

0

if you are not disciplined at programming, it is way too easy to shoot yourself in the foot (and everyone else, for that matter) . I much prefer strongly typed languages and BOUNDS CHECKING. also, doing all the memory management yourself is usually a big PITA and except for a few cases is usually better done by the compiler. that being said, if you want to program embedded systems, there really is nothing else but C/C++.