top | item 32879895

(no title)

net_ | 3 years ago

Man, the negative sentiment on this site towards C++ is pretty alien to me.

C++ is (I'm guessing) currently holding up an order of magnitude more applications than whatever you think is better than it. Clearly it has upsides, so it's baffling to me when people greet attempts to reduce the downsides with either "This doesn't make sense, just scrap it for something else" or endless nitpicks about the approach chosen.

A smart guy has decided to put his time towards improving a hugely influential language. That seems like an uncontroversial positive to me, and I welcome any useful results.

discuss

order

0x457|3 years ago

I think not many people ever got properly introduced to C++.

Some probably only saw it during their format education, and it's most likely been taught like C with classes and/or they had to use for stupid things.

There are also many forms of C++, there is your "old and regular" C++, game dev C++, there is modern C++, then there is "I only know C, but sure I can write C++" C++.

Pulling dependencies is not as simple as `npm i boost`.

Communities are small, segmented and not welcoming to newbies.

Absolute madness with build tools. I've never worked with CMake myself until last year, and I haven't so frustrated.

As for how many applications using C++ that's not really an argument — C++ was literally the only choice for many of them at that time.

spookie|3 years ago

Not really an argument? The C/C++ ecosystem is so well established that even today you don't have a choice in a lot of contexts.

If that doesn't show the power of a language, I don't know what can. I don't really think the community is toxic or unwelcoming, more like people are too used to ctrl+c ctrl+v their way out of problems. Nothing against that, I'm the same way, but it really is a matter of taking your time with the language. I've honestly learned to applaud most rust fanatics because of this, at least they are passionate about learning athe language inside/out.

dottedmag|3 years ago

To be properly introduced to C++ is to be properly introduced to the madness called UB.

Of course not many people ever got properly introduced to C++.

FerociousTimes|3 years ago

I echo the same sentiment here but mainly for C language as If my memory serves me right, I didn't have any encounter with C++.

My experience was negative overall and traumatic to some extent and I wouldn't rule out that some who were first exposed to the language in college or even HS share the same aversion and feel scarred and haunted forever by that Blue Ghost.

mattgreenrocks|3 years ago

My theory is that the Internet generally hates multi-paradigm languages (Scala!). Key phrase there is “the Internet,” which is a euphemism for “people who write in the comment section.” They aren’t a representative sample, just a vocal one.

There are plenty of good reasons to hate on C++, but that’s conflated with a lot of “real hacker” signaling.

Most takes on C++ lament that it isn’t C, or is too complex. Rust is a quality replacement for C++, but it doesn’t succeed on either of those counts either.

All new code I write is in Rust or Haskell. If I need to do something weird, like with DynamoRIO, C++ it is.

riffraff|3 years ago

Python and Ruby were considered multiparadigm languages once, and the internet didn't hate them at all.

I think "the internet" tends to complain about languages which have accrued complexity over time, and contain parts that are now considered bad but still lurk in the shadows tripping you up.

Scala, C++, perl and others seem to fall into this category.

nine_k|3 years ago

My problem with C++ is that, with all its complexity, it's still unsafe. Efforts to add safety to it as a,library (unique_ptr, etc) are commendable and useful, but they cannot be comprehensive, because the language's design, especially the early decisions, resists them.

Lack of modularity and the fact that everything is treated like a single source file (via #include) adds interesting ways of unexpected interactions.

throwaway894345|3 years ago

“Holding up an order of magnitude more applications … clearly it has upsides”.

It’s holding up lots of applications because better languages didn’t exist at the time those projects were started, and it’s rarely feasible to switch languages. Specifically, a lot of people look to Rust to unseat C++ for new applications, but it will take a while for Rust to mature with respect to libraries (e.g., game engines) and mindshare in those industries. But even then, old languages have tons of staying power by virtue of age.

YZF|3 years ago

I'm not super familiar with Rust, do you have SSE/AVX intrinsics (others?)? Can you write assembly embedded in Rust code? How does rust stack in terms of performance?

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

looks quite decent, but overall Rust is still behind? So if I am in an area where performance (or cost/energy) is king then I'd still pick C++.

guitarbill|3 years ago

It doesn't feel much different to any other language that people have been burned by (e.g. Javascript). I have some bad C++ experienced, and I know enough programmers I respect who stick to C over C++.

Of course it's difficult to equate that kind of advice/feedback to negative comments on HN. But often, there's some kernel of truth there. So while there's some merit to C++, the criticism can equally be valid. And keeping the underlying complexity of C++ (similar to how Carbon will) might not meaningfully simplify development).

einpoklum|3 years ago

> I have some bad C++ experienced, and I know enough programmers I respect who stick to C over C++.

Do you know such people who work on large software systems, as opposed to, say, micro-controller firmware, or kernel drivers and such?

(Asking as a person who maintains an important(ish) C library for embedded coders: https://github.com/eyalroz/printf)

asveikau|3 years ago

I came up with the following guess many years ago:

There are people who are totally unproductive at C++ and find it scary, mainly because they are not very exposed to it. They assume everybody is as uncomfortable and unproductive with it as they are. Nay, it is impossible for anyone to be productive with it, simply because they aren't. They will attack evidence that somebody has done well with it, because it is some defense of ego for them.

There are other complaints about C++ beyond this of course, with validity, and many of them from old timers and people who bitterly complained about it for decades from a place of knowledge and experience. People have been complaining about ugliness of C++ for longer than my own career. However, as more and more people come up in the post-C++-as-fashionable era, I think this above theory is more and more the bulk of the complaints.

pjmlp|3 years ago

C++ is a great language, the sub culture that keeps unsafe C patterns alive in the language, not so much.

Example, back in the heyday of C++ frameworks bundled with compilers, bounds checking strings and collection arrays were the default.

Nowadays you either call at(), have your own bounded checked types, or enable the debug library, but naturally without influence on 3rd party depedencies.

zhxshen|3 years ago

The text-include compilation model is broken, larger projects pay dearly for this, and thanks to C++'s very long history & very long feature list, there is a veritable Babel of feature subsets & compiler opts to choose from. Adding new dialects and features is not an improvement here.

klodolph|3 years ago

This is what the "modules" feature in C++20 addresses. People are complaining about modules a lot, I think because the spec is a little complicated... but the spec is a little complicated because the problem is a little complicated, and you can't pretend that complexity doesn't exist when you're writing the spec. (There are some other complaints about the modules system. It wasn't going to please everyone.)

New dialects and features were getting added to JS all the time, but what happens is people writing JS libraries or tooling would watch how far these features spread in their users' browser compile base, and many of these various features would never even make it into popular JS runtimes, while others are everywhere now.

I think it's a reasonable model for development--lots of people trying to improve things, the community slowly sifts it out, and the standards are the most conservative of all.

zozbot234|3 years ago

> C++ is (I'm guessing) currently holding up an order of magnitude more applications than whatever you think is better than it.

So what. No one's going to rewrite all of those million lines of code in New C++, or whatever they call this incompatible syntax. It's just a distraction from more relevant efforts.

pavlov|3 years ago

New code can be written in the new syntax, with full access to existing libraries.

I could easily see a company like Meta adopting this. They have both a huge amount of C++ code as well as actively developed guidelines and internal libraries that make use of cutting-edge features.

pelario|3 years ago

From the link:

"I'm sharing this work because I hope to start a conversation about what could be possible within C++’s own evolution to rejuvenate C++, now that we have C++20 and soon C++23 to build upon."

Clearly this is relevant for c++ itself (coming from Sutter), so I'd say it's quite unfair/misguided to call it "just a distraction from more relevant efforts."

the-smug-one|3 years ago

If you've got 10^6 LoC of a product that will be developed and maintained for 10+ more years then you can slowly replace it with this.

zbird|3 years ago

Of course they will. What they are less likely to do is to rewrite it in a completely different language (e.g. Rust.) C++ became popular in the first place because it could easily go along with C. No need to rewrite in bulk.

lallysingh|3 years ago

This isn't a language declaration, it's a tool declaration. A tool useful for prototyping new language features and compiling them into large existing source bases.

benj111|3 years ago

Familiarity breeds contempt?

I'm sure many would dislike rust if they were forced to use it. Same with python, etc, etc, etc.

I'm not saying the criticisms are wrong per se, but the reason we have so many languages is probably because there's no 'right' language.

otabdeveloper4|3 years ago

> programming is hard, let's go (language) shopping instead

Volker_W|3 years ago

> C++ is (I'm guessing) currently holding up an order of magnitude more applications than whatever you think is better than it.

You could say the same thing about COBOL.

(Not that I think that C++ is as bad as COBOL.)

MaulingMonkey|3 years ago

> Clearly it has upsides, so it's baffling to me when people greet attempts to reduce the downsides with either "This doesn't make sense, just scrap it for something else" or endless nitpicks about the approach chosen.

People have been working to reduce the downsides of C++ for decades at this point, and the results are incredibly lackluster, and frequently only work in trivial toy examples - if even then. Every now and then I try out the latest and greatest I can find in terms of dangling pointer prevention, and find myself confused as to if I've even enabled the proper checks, when even my trivial toy examples fail to trigger said checks, only to be horrified when I in fact have enabled said checks and gained nothing.

I, too, welcome any useful results. The problem is: I don't actually find the results useful. I get told garbage like "C++ is safe now!" by people who apparently don't know any better, for things underperforming existing static analysis tools from over a decade ago. It's a distraction, a false promise, and a waste of my time - which could be better spent reviewing C++ code, improving existing static analysis coverage, or going full ham and unironically pushing for incremental rewrites in Rust. Not because it is perfect: I've written and debugged my share of dangling pointer bugs in unsafe Rust code too - but because it is at least better, and provides me with tools to fight the good fight.

And if, from time to time, you find my voice amongst the nitpickers of attempts at C++ "improvements", it's perhaps because the attempt has failed, and I would rather not have others waste their time like I have on false promises. Granted, such warnings are unlikely to work: the alure of something that might ward off yet more late nights chasing yet more heisenbugs in yet another C++ codebase caused by coworkers, third parties, those long gone, or perhaps worse - by me - is just too promising. But it might.

Show me real bugs, in real codebases, caught in bulk where existing tools have failed, and you will have my undivided attention.

bowsamic|3 years ago

I agree, and I don't think it's as hard or complex as people make it out to be

alar44|3 years ago

I will probably get some flack for this but it's an effect of the Python generation. When you can pull in some libraries and build some bloated slow as hell code in minutes, no one cares what's under the hood. The tradeoff from performance (easily 1000s of times, I've seen it swapping out simple python libs for c++, specifically changing dicts to linked lists) to ease of slapping things together makes me sad daily.

lolinder|3 years ago

Why would a trade-off make you sad? For most code that gets written, being able to quickly make something work is far more important than a 1000x increase in performance. Some projects do need performance, and for those no one should choose Python. For all the others, I'm glad Python exists.

CamperBob2|3 years ago

That's true, but at the same time, modern C++ bears about the same resemblance to the C++ that many (if not most) of us learned years ago, as modern English bears to Middle English.

People have been trying to make the language safer and more palatable for multiple decades now, so it seems reasonable to allow Sutter to have a go at it.

ryukoposting|3 years ago

C++'s main upside is that it's the least common denominator. Also its runtime is friendly to embedded systems (kind of).

I welcome good replacements for C++'s syntax, because it's genuinely terrible.

staticassertion|3 years ago

> Clearly it has upsides,

All that you've indicated is that it's used a lot, which is obviously because it has decades on every other option.

Anyway, I love Herb Sutter and I love this work he's doing. Awesome stuff.

hvs|3 years ago

C++ is like the English language. Extraordinarily popular, hard to learn, and full of weird cruft. You can write amazing things in it as well as terribly unsafe garbage.

account42|3 years ago

English is not particularly hard to learn.

cplusplusfellow|3 years ago

I’m truly thankful in my life for Sutter doing the work he does to make this language better. He is a giant.

uoaei|3 years ago

[deleted]