Live data from Hacker News

21st Century C++

cacm.acm.org

51–60 of 281 posts

Re: 21st Century C++

#51

The C++ Core Guidelines have existed for nearly 10 years now. Despite this, not a single implementation in any of the three major compilers exists that can enforce them. Profiles, which Bjarne et al have had years to work on, will not provide memory safety[0]. The C++ committee, including Bjarne Stroustrup, needs to accept that the language cannot be improved without breaking changes. However, it's already too late.…

Clion, clang tidy and Visual C++ analysers do have partial support for the Core Guidelines, and they can be enforced.

Granted, it is only those that can be machine verified.

Office is using C++20 modules in production, Vulkan also has a modules version.

Re: 21st Century C++

#52
post #41

[flagged]

> It is so objectively horrible in every capacity,

Total hyperbole and simply not true.

> but it still somehow managed to limp on for all these years

Before Rust became somewhat popular, there was simply no serious alternative to C++ in many domains.

Re: 21st Century C++

#53
post #42

For someone who wants to get into systems programming professionally, is C++ going to be a hard requirement or can one mostly get away with C/Rust?

The only places where C++ failed to take C's crown has been on UNIX clones (naturally, due to the symbiotic relationship), and embedded where even modern C couldn't replace C89 + compiler extensions from the chip vendor, many shops are stuck in the past, even though most toolchains are already up to C++20 and C17 nowadays.

Rust is still too new for many folks to adopt, it depends on how much you would be willing to help grow the ecosystem, versus doing the actual application.

It will eventually get there, but also have the same issues as C++, regarding taking over C in UNIX/POSIX and embedded, and C++ has the advantage of having been a kind of Typescript for C, in terms of adoption effort, being a UNIX language from AT&T, designed to fit into C ecosystem.

Re: 21st Century C++

#55
Here's how Bjarne describes that first C++ program:

"a simple program that writes every unique line from input to output"

Bjarne does thank more than half a dozen people, including other WG21 members, for reviewing this paper, maybe none of them read this program?

More likely, like Bjarne they didn't notice that this program has Undefined Behaviour for some inputs and that in the real world it doesn't quite do what's advertised.

Re: 21st Century C++

#56
post #54
post #41

[flagged]

Start by removing Rust's dependency in GCC and LLVM, both written in C++.

Rust doesn't "depend" on LLVM in the sense you seem to imagine, you can instead lower Rust's MIR into Cranelift (which is written in Rust) if you want for example.

LLVM's optimiser is more powerful, and it handles unwinding, so today most people want LLVM but actually I think LLVM's future might involve more Rust.

Re: 21st Century C++

#57

Earlier quoted context omitted.

No, the formatting was definitely botched. It should look much better than it does even in a proportional font.

Agreed. I wouldn't mind if, say, end of line comments weren't perfectly aligned. There's zero indentation so things like for (string line; getline(is,line); ) s.insert(line); are hard to visually parse.

This must depend on some settings of the browser and perhaps also on the locally installed typefaces.

On my Firefox on Linux, this HTML page is not rendered with any custom typefaces, but it uses those specified by me as defaults for serif/sans serif/monospace.

The C++ code is rendered in my browser with my default, i.e. with JetBrains Mono and there is nothing weird.

The code quoted by you is indented as expected, not as in your posting.

On my computer, I have mostly typefaces that I have bought myself and which are seldom encountered in most computers. I do not have any of the typefaces that are typically specified in CSS rules, i.e. none of the typefaces that can be found in default installations of Windows, Linux or MacOS.

So perhaps there is a bug in their CSS at the definition of "wp-block-code", which on other computers selects a bad typeface that is proportional, so that the narrow spaces make the indentation disappear. (Their wp-block-code says "font-family:inherit" and I have not searched further to see from where the wrong font-family may be inherited.)

Here, perhaps because that bad typeface cannot be found, the browser uses my default monospace font and the code is displayed fine.

Or else, perhaps you have not set in your browser a proper default for monospace fonts and it just takes Arial or other such inappropriate system font even for monospace.

Re: 21st Century C++

#58

Here's how Bjarne describes that first C++ program: "a simple program that writes every unique line from input to output" Bjarne does thank more than half a dozen people, including other WG21 members, for reviewing this paper, maybe none of them read this program? More likely, like Bjarne they didn't notice that this program has Undefined Behaviour for some inputs and that in the real world it doesn't quite do what's…

The collect_lines example won't even compile, it's not valid C++, but there's undefined behavior in one of the examples? I'm very surprised and would like to know what it is, that would be truly shocking.

Re: 21st Century C++

#59

Something about the formatting of the code blocks used is all messed up for me. Seems to be independent on browser, happens in both Firefox and Chrome.

Have you verified that your browsers have correct settings for their default fonts, i.e. a real monospace font as the default for "monospace"?

Here the code is displayed with my default monospace font, as configured in browsers, so the formatting is fine.

There are only 2 possible reasons for the bad formatting: a bug in the CSS of the ACM site, which selects a bad font on certain computers or a bad configuration of your own browsers, where you have not selected appropriate default fonts.

Re: 21st Century C++

#60
post #7

Something about the formatting of the code blocks used is all messed up for me. Seems to be independent on browser, happens in both Firefox and Chrome.

This is a Bjarne issue. For personal reasons he uses proportional fonts in his code blocks (in his texts) instead of monospaced and the code snippets always look bad. I guess he is stuck in his ways, just have to work around this ugly look.

This is not a Bjarne issue.

The font is selected by the HTML/CSS of the ACM site, not by Bjarne.

There may be a bug in the CSS of the ACM site, but I think that it is more likely that anyone who does not see correctly formatted code on that page has forgotten to open the settings of their browsers and select appropriate default fonts for "serif", "sans serif" and "monospace".

As installed, most browsers very seldom have appropriate default fonts, you normally must choose them yourself.

In this case, whoever does not see a monospace font, which is mandatory for rendering the code on that page, because the indentation is done with spaces, which become too narrow if rendered with a proportional font, must have that proportional font set in their browser as a default monospace font, so they should correct this.

Post reply on HN