CPlusPlus

ThoughtStorms Wiki

I like the original CLanguage

I'm not much of a fan of C++

A C++ package manager : https://conan.io/

Quora Answer : Why is C++ considered a bad language?

May 10, 2017

This is one of those rare occasions I disagree with Simon Kinahan; although his answer sets the scene for this one.

C++ is a bad language because it's built on a flawed philosophy : which is that you should add power to a language by kludging it in "horizontally" in the form of libraries rather than "vertically" by building new Domain Specific Languages to express it.

Stroustrup is very explicit about this, rhetorically asking "why go to other languages for new features when you can add them as libraries in C++?"

Well, the answer is, adding new higher level conceptual thinking in the form of a library doesn't really hide the old thinking from you. Or allow you to abandon it.

C++'s abstractions leak, more or less on purpose. Because you can never escape the underlying low-level thinking when you're just using this stuff via libraries. You are stuck with the syntax and mindset of the low-level, even as you add more and more frameworks on top.

Yes, you can explicitly add garbage collection to a C++ program. But you can't relax and stop thinking about memory management. It can't disappear completely beneath the horizon of things you need to be aware of the way it does in Java.

Yes, you can have higher-level strings, that can abstract Unicode-ness etc. via a library. But you can never be sure that you won't confront strings that are simple byte-arrays coming from another part of your large system.

Etc.

C++'s ability to build high-level abstractions uncomfortably falls between two stools.

It encourage you to think you can and should be building large applications full of application logic. But doesn't give you the real abstracting power to focus only at that application level.

This explains the otherwise mysterious paradox that C is a good language, so how could something that is "C plus more stuff" possibly be a bad one? Well, it's exactly the "more plussing" that's the problem.

With C, you KNOW you should only use it to build relatively small things. It doesn't pretend to offer you mechanisms to build big things. And so you turn to the obvious tools for scaling up : lex and yacc to build small scripting languages, the Unix pipe to orchestrate multiple small tools . C++ gives you just enough rope to hang yourself. Just enough powerful abstraction building capacity in the language itself that you (or that guy who used to work in your company 15 years ago ) thought it might be possible to reinvent half of Common Lisp's data-manipulation capability and half an operating systems' worth of concurrent process management inside your sprawling monolithic application.

I don't see why it shouldn't be possible to combine low-level memory management and efficiency with high level abstraction building. But proper abstraction building requires something more like macros or similar capabilities to make a level of expression which really transcends the low level. That's exactly what C++ lacks.

Quora Answer : I've read a lot of negative comments on C++ and I've seen a lot of people hate this language. I know Java very well but all these negative things have made me hate C++ without even trying it. Can you change my mind? Is C++ really that bad?

Apr 3, 2019

You shouldn't hate anything without trying it. That's just silly.

What's "wrong" with C++ is that it's an awkwardly underpowered tool for the job. It's a low level systems programming language like C.

And C is a good low level systems programming language. But the expectation is that you aren't going to try to write huge things with it.

The problem with C++ is that it adds a bit extra to help you build higher level abstractions and larger programs. But doesn't really add enough to make that comfortable.

So .. if you're used to Java, Java is very like C++ but the VM and garbage collection takes some of the work away from you, allowing you to focus more on the architecture and larger scale application logic.

Now I personally think that even Java is too low level for most application level programming in 2019. And you want something higher level still. But at least it takes care of memory for you and the types are relatively robust, if basic.

But C++ is like using Java except it ALSO forces you to manage a bunch of low level system resources like memory management etc. These are things you need to worry about when you want to do very low-level, perhaps very efficient programming on small embedded systems, or in the kernel of an OS, but you don't want to be bothered with if you are writing a word processor or most user facing applications which are I/O bound.

So it's underpowered. If you want to write a small efficient or system level thing, then C++ is OK. Really you can just treat it like C but with classes.

But if you want to write an application. Then it's too much trouble. Like trying to dig a ditch with a spoon. Just get something which is better suited to let you focus on application logic.