top | item 33440412

(no title)

ayberk | 3 years ago

As someone who has been writing C++ at Google, this exactly. Despite all the tooling, guidelines and "internal magic", C++ is still an abomination. And no it has nothing to do with memory management, I actually do like C.

I love how Eric Raymond describes it as "anti-compact", because, well, it really is. C++ as a whole should be deprecated -- and no new projects should use C++ (unless for some very odd and specific reason).

discuss

order

DeathArrow|3 years ago

>C++ as a whole should be deprecated -- and no new projects should use C++ (unless for some very odd and specific reason).

And what can be used instead of C++? C? If C was better, then C++ wouldn't have been invented. Rust? It's much more painful to use than C++. Zig? It's immature and has very low usage. Nim? Has very low user base. Julia? It isn't solving the same problems.

smackeyacky|3 years ago

I don't think that's true. I started C++ using the 'cfront' system, the major push wasn't because C was somehow lacking, it was because it was fashionable to do object orient programming which is hard in C. Various horrible patterns were invented using function pointers so C programmers could feel like they were doing object oriented programming and all of them sucked.

When cfront turned up, the first versions basically automated that suckage. C++ did get better, but it was still horrible compared to CLOS or Smalltalk. This was largely due to weirdness in how the constructor/destructor ordering worked, the giant bogosity that is multiple inheritance and a few massive other undefined behaviours that every compiler did differently, but I think at this point it's fair to point out the language is bad and things like C# are so much better it's not even funny any more.

xedrac|3 years ago

> Rust? It's much more painful to use than C++.

As someone who has used C++ professionally for two decades, I disagree. Rust's pain is superficial and all up front. C++ pain is death by a thousand paper cuts, especially if you have people on your team that aren't intimately familiar with its pitfalls and its more modern constructs. I don't plan to write a new C++ project ever again, unless there's some very compelling reason to do so. Rust is an absolute breath of fresh air.

jjav|3 years ago

> And what can be used instead of C++?

For most use cases Java is a better option. Very fast, without any of the pain.

If you truly must not have a VM (rare), there's still C. Perhaps rust.

littlestymaar|3 years ago

> Rust? It's much more painful to use than C++.

Unless you're doing something really highly specific to C++ (like Cuda for instance or deep integration with big C++ codebase), saying that rust is painful compared to C++ is laughable.

adgjlsfhk1|3 years ago

Julia is solving many of the same problems as C++. GPU compute, HPC, high performance algebra kernels are all well within Julia's purview. It's not (at least yet) good for things like writing OS kernels but there is a large amount of overlap with C++.

dtx1|3 years ago

> Rust? It's much more painful to use than C++

Write a sufficiently complex memory safe program in C++. I dare you. It's been proven again and again that humans can't do it. And calling Rust more painful than C++ is just absurd.

jeffreyrogers|3 years ago

> C++ as a whole should be deprecated -- and no new projects should use C++ (unless for some very odd and specific reason).

It's quite a bit easier than Rust and no other popular language has its most important features (cross platform, interfaces with syscalls and other libraries easily, manual memory management possible, likely to be supported for a long time).

dthul|3 years ago

Having used both C++ and Rust extensively, I would say that it is easier to get something to compile in C++ than in Rust, but I find Rust overall much easier. C++ is really very complex, and even after more than a decade of using it there are so many things I don't know. With Rust I feel like I have a pretty solid grasp of most of the language.

ayberk|3 years ago

It _looks_ easier because it lets you do anything you want. C++ makes you feel like you're going faster, but then you spend two weeks debugging a weird memory issue.

I come from functional programming background, so I'm all for taking a little bit longer to make my code compile if that means it'll work. I'd rather deal with compilation errors than waking up at 2am to debug a stupid segfault.

germandiago|3 years ago

> C++ as a whole should be deprecated -- and no new projects should use C++ (unless for some very odd and specific reason)

Too bold statement. There are still lots of reasons to keep using C++. LOTS.

timbit42|3 years ago

There are lots of reasons to keep using C++ on existing projects in C++ but there are not many reasons to choose C++ for a new project.

gort19|3 years ago

I can see why for legacy projects, but for new projects, what are they?

MichaelZuo|3 years ago

Over C, Assembly, Rust, etc.?

pencilguin|3 years ago

This is exactly equivalent to saying all existing C++ programmers should be demoted to doing only maintenance work, or fired.

As such, it is in violation of site terms and conditions, and damned rude.

ajvs|3 years ago

If you take criticism of any activity you partake in as being "damned rude" and a violation of site T&C, then there'd never be any discussion at all.

You are not your job, and prepare yourself for listening to honest criticism of the things you base your identity around or you will find it very difficult to learn and grow.