News for hackers. Stuff that matters.
Re:#include <rules> by freedomben on Sunday February 04, 2024 @08:22AM (#39249985)
It surprises and saddens me how dismissed C++ is nowadays. It's rarely my first choice (unless writing a gui, then Qt is my go-to), but it is a far more modern and less dangerous language than most people think. With most technology, people don't assume it hasn't changed since the 90s, but for some reason, that's what people do with C++
Re:#include <rules> by Xeamek on Sunday February 04, 2024 @09:26AM (#39250415)
>more modern and less dangerous language than most people think

Compared to what? Itself from 20 years ago? That's great, but not nearly enough. Cpp just has SO MUCH FRICTION that it's simply not worth it to deal with it. Maybe if you have 20yrs of cpp experience and carved out a specific way for yourself to avoid all of it while still being productive... But that's not really an argument.

And sure, there are still some cases when the alternatives aren't ideal either (ie. Rust also having friction, especially in domain like games, or higher level languages being too slow). But cpp has so much downsides I don't see why should one ever default into choosing cpp, unless you REALLY care about the benefits it brings. But those upsides are usually external (ie. ecosystem), rather then features of the language itself

https://bitbashing.io/std-visit.html

Re:#include <rules> by marcosdumay on Sunday February 04, 2024 @10:13AM (#39250778)
> and carved out a specific way for yourself to avoid all of it while still being productive

I believe such person exists when I see one. All that I see around are people claiming they did that, while ignoring some huge issue with their style that inserts some really nasty bugs on their software.

Instead, the only C++ code that works out there is created by committee and peer-reviewed, so that different styles compensate each other.

Re:#include <rules> by geertj on Sunday February 04, 2024 @03:27PM (#39254065)
> I believe such person exists when I see one. All that I see around are people claiming they did that, while ignoring some huge issue with their style that inserts some really nasty bugs on their software.

The real question is, of 100 bugs in a real-world application, how many were caused or at least influenced by the language, and how many are application level errors. In my practical experience bugs due to C++ behavior have just not been a thing. Maybe your world is different.

Re:#include <rules> by tsimionescu on Sunday February 04, 2024 @10:16AM (#39250804)
> it is a far more modern and less dangerous language than most people think.

I think the opposite tends to be true. C++ is a more dangerous language than most people think, and many who see some nice new constructs end up with a false sense of security. In any major C++ project you will sooner rather than later find pieces that don't strictly respect all of the rules of modern C++, that end up accidentally invoking UB, and that will happily pass code review and de testing before blowing up when something else changes.

People tend to believe they can write safe C++, but outside constrained environments (similar to MISRA C) , this has not been proven true in practice.

Re:#include <rules> by StopTheTechies on Sunday February 04, 2024 @08:45AM (#39250139)
> but it is a far more modern and less dangerous language than most people think.

I suspect a better answer here is that people have wildly different tolerances for safety and don't discuss the subjective aspects of interactions with programming languages.

Re:#include <rules> by dns_snek on Sunday February 04, 2024 @08:58AM (#39250230)
I've never written C++ in professional capacity, what turns me off from learning is what I've heard and read about its vast complexity, e.g. you could meet 20 expert C++ developers and they'd all be using a different subset of the language. I don't want to spend more energy learning a language than I do actually solving the problem. Same reasoning turns me off from Rust, too.
Re:#include <rules> by bun_terminator on Sunday February 04, 2024 @02:08PM (#39253300)
As a pure c++ dev, this is true and a good reason. The committee is borderline sabotaging the language. On top of the anti-cpp crows slinging hitpieces
Re:#include <rules> by ryandrake on Sunday February 04, 2024 @09:10AM (#39250309)
Modern C++ is great and I would choose it today if I were starting a project from scratch. I think people’s problem with C++ is the existing projects/code. If I were to join a random company today working with a C++ code base, it is very likely I’d be dealing with legacy code complete with all the 1990s footguns C++ dismissers dismiss. That code base would also likely have problems like requiring Visual C++ 6.0 to compile, emitting thousands of warnings that have been ignored for decades, and the company shipping the DEBUG executable because nobody can figure out how to get the RELEASE build to not crash. Often existing C++ projects come with 1990s era problems, so detractors can still legitimately use 30 year old arguments.
Re:#include <rules> by JonChesterfield on Sunday February 04, 2024 @10:04AM (#39250697)
Modern C++ is mostly syntactic sugar over older C++. If you manage to walk the happy path entirely within said syntax the code looks quite pretty. Lots of the language design is about having a nicer way to express common ideas.

If you stray from the happy path, the demons come for you. Or if your use case isn't met by the existing sugar. Or if you have a dependency which was written a couple of years ago that you need to reach into.

And naturally the project started from scratch today, only using the very nicest C++ features, will be legacy code written wrong in three or six years from now as the language moves on.

I wouldn't want to start a new project in C++ today but I'm not totally confident there's a better choice available.

Re:#include <rules> by lmm on Sunday February 04, 2024 @07:44PM (#39256104)
> With most technology, people don't assume it hasn't changed since the 90s, but for some reason, that's what people do with C++

Disagree, every technology is like this. Talk to people about Maven and they think the 2005-era reasons not to use it are valid. Mention MongoDB and people think it's 2015. The industry is seemingly only ever willing to progress by adopting new things, not by fixing existing things.