Live data from Hacker News

C++ Should Be C++

open-std.org

151–160 of 191 posts

Re: C++ Should Be C++

#151

> It is easy to see that C++ is fit as a general-purpose programming language–adoption by millions is a testament to that. I really wish the std would drop this pretense and focus on C++'s strong point: Continue being the fastest systems language possible. Everywhere in the std lib you can see compromises that require rewriting substantial portions for any real time application. Things like: shared_ptr eagerly using…

>std::string allocating

You mean you want string_view? It still calls strlen when you instantiate it with a literal though.

Re: C++ Should Be C++

#152

Earlier quoted context omitted.

I think it's less about not wanting memory safety and more that compilation speeds are so time-wastingly abysmal that it's a few orders of magnitude more important to address. The whole deal with interpreted languages was to avoid sitting there for a few minutes every time you make a god damn one letter change, with the unfortunate but usually acceptable trade-off of some execution speed.

I know I'm weird, but as long as I can compile individual units and link them to other already-compiled units then compilation speed is something I don't care about much at all.

That's fine and dandy as long as you don't use C++ with templates and other stuff that needs 90% of the code to be in the headers.

Any recompile triggers a lot of recompilation.

And no, I can't change the code the other hundred devs are writing in my company.

In C++ there is no individual units. In C it's somewhat plausible with some discipline.

Re: C++ Should Be C++

#153
C++ isn't C++. It is every incarnation of the language, every language subset defined in a code standard (for a project or an organization), over decades.

Sure you can write virgin code in C++ and choose some "modern" incarnation of the language or some subset thereof. But there exists billions of lines of legacy that most of us have to deal with. Daily or occasionally. Usually without the option of rewriting.

Then there's the tooling. The horrific, antiquated build process which we try to automate with tools that just make things even more complex. The lack of a practical standard library that says "you know, those things you often have to do, we should actually offer those". It is neither helpful nor useful that C++ doesn't have room for HTTP, JSON, basic networking abstractions etc.

I would not recommend a beginner learn C++ today. I'd recommend Rust or Go. Most people are going to be more productive AND produce more robust code in fewer years. One can be annoyed by that statement, but you would have an uphill battle claiming that it is wrong.

I don't think C++ is worth the investment for a new programmer. Dealing with C++ just gets more complex the more changes we make to it and the more we evolve it. C++ isn't just one spec - it is the aggregate of all specs and practices that have existed because that's what you risk ending up working on in real life.

It's a bit much history.

From the perspective of the programmer I think it is a much better idea to put some energy behind a fresh start. And try to remember the mistakes that were made. Right now, for C++ developers, Rust looks like the closest thing to a fresh start. But it may be that Go is going to make a lot of C++ programmers a lot happier too since not all C++ code lives in constrained environments or actually has to deliver bare metal performance.

I don't think the C++ community even wants C++ to turn into something that is comparable to Rust or Go. Doing that to C++ would require throwing things out and creating something very different.

Re: C++ Should Be C++

#154

I hope people don't throw out the effective and well-thought out parts with the problematic parts. It happened with Macromedia Flash and it happened with Microsoft's Visual Basic. The JVM and industry attitudes to Java. PHP. We have lost some good technology over time, please don't let us lose the good parts of C++.

I'm not sure this is best done by holding on to implementations of those ideas that have serious flaws. Yes, learning is slow, and most languages seem to start with a handful of ideas someone wants to realize and then ignoring a lot of the difficult stuff others took a long time to solve.

Re: C++ Should Be C++

#155

The C++ community has some of the best brains around. Absolute geniuses. If C++ is ok with being a small language used by and for geniuses - I have no problem with that. If C++ wants to be popular - we need a breaking change between the world of 2023 and 1990 - they don't know what we know now. I like some parts of C++... it's too bad the "good language" is shackled to a mountain of razor blades.

What do you think about Carbon[1]? I am hopeful. [1] https://github.com/carbon-language/carbon-lang

Not the OP, Carbon currently still doesn't have a working implementation, it is clearly a tool for Google to migrate away from C++ without rewriting the world, they are quite open that it isn't trying to be anything else, it is only an experiement, and it may even fail as an experiment.

Carbon gets talked a lot by people that somehow miss the language goals.

Re: C++ Should Be C++

#156

Honestly, everyone working with C++ sticks to a select subset of the language that they've chosen for their project, or the project they're contributing to. Nobody knows all of C++. Personally, I don't mind C++ forking out in different directions and accepting diverse proposals; while I wouldn't bother to use them myself, I realize that it may be useful to other people. C++ is an engineer's language, and it's ridicul…

Except the detail when LLVM gets shipped with application code, like a JIT, and then gets exposed to possible security attacks.

Yes, most likely LLVM will never be rewritten into something else, yet security is a concern also in compiler code.

Re: C++ Should Be C++

#157

Honestly, everyone working with C++ sticks to a select subset of the language that they've chosen for their project, or the project they're contributing to. Nobody knows all of C++. Personally, I don't mind C++ forking out in different directions and accepting diverse proposals; while I wouldn't bother to use them myself, I realize that it may be useful to other people. C++ is an engineer's language, and it's ridicul…

> Yes, there are memory safety issues, but in practice, these are isolated in very few places. Take a compiler like LLVM for instance: most developers are working on transforms or analyses, and they're exposed to zero manual memory management. It is really easy to get use-after-free in LLVM passes due to using eraseFromParent() instead of removeFromParent(), etc. As I recall, in some places the optimization code goes…

Maybe not, still I like to follow up on GraalVM, as I used to for MaximeVM and JikesRVM, and MSR Phonenix compiler, exactly because of that.

Compiler building frameworks in managed languages.

Re: C++ Should Be C++

#158

Earlier quoted context omitted.

No, C is not the same as it is less expressive. C++ templates allow for declarative nested inlining into a single compilation unit that is extremely difficult to achieve with C macros. See elsewhere in this thread for discussion of boost, it's not applicable.

In this thread: all the people that have never looked at C++ disassembly. Maybe the C++ "language server" of your choice should have a mode where it prints all the constructors destructors copy constructors and what not on top of your code? "Zero cost abstraction" is a big fantasy. C++ is the king of hidden control flow and the costs are everywhere.

[dead]

Re: C++ Should Be C++

#159

Earlier quoted context omitted.

Your specific gripes seem reasonable (I suspect design-by-committee plays a big part), but: > I really wish the std would drop this pretense and focus on C++'s strong point: Continue being the fastest systems language possible. You've essentially described C, not C++. C++ has a different philosophy and makes different trade-offs. C++ is at least still pretty committed to the you only pay for what you use principle. A…

> You've essentially described C I'd disagree pretty strongly with that. C is more focused on being relatively simple to implement and backwards compatibility with the past 50 years. (I read a blog post by a C committee member talking about that recently, wish I could find the link) Just look at the garbage fire which is the standard library. qsort. strtok. rand. C++ should (in theory at least) be able to match or su…

[dead]

Re: C++ Should Be C++

#160

Earlier quoted context omitted.

It was my understanding that one can easily add their own allocator to any STL container, though as you point out you have to write that allocator yourself

Allocators have an inherently broken design, tying them to types. See this CppCon talk by the (engaging and funny) Andrei Alexandrescu: https://www.youtube.com/watch?v=LIb3L4vKZ7U std::allocator is to allocation what std::vector is to vexation (or: designing allocators that don't not-work)

If the allocator is unaware of your type, how do you initialize the underlying object? That is - how do you invoke the default or non-default constructor of type T over the memory region you just allocated?
Post reply on HN