Live data from Hacker News

Why do C++ folks make things so complicated?

johndcook.com

31–34 of 34 posts

Re: Why do C++ folks make things so complicated?

#31

If you want to make such a distinction, Qt is probably what would come close to top-C++. It offers dynamic binding via signals/slots, Java-like iterators, simple multi-threading/parallelization, signal/slot-driven networking, database access, and some automatic memory management (deletion via parent widgets, and auto-pointers). It only misses the proposed compiler warnings to indicate that 'bottom-C++' is used. Still…

I have written applications both in Qt and PyQt and found out that in the real world, Pythons performance is more than apt for creating a UI.

Even more so, the PyQt application had a NumPy backend and again, it performed flawlessly. The Qt application had a C++ backend that did similar computations as the Numpy backend, but with a much more painful programming process.

So in that line of thinking, I am a big proponent of having a dynamic language as frontend for low level libraries. Both Qt and the Numpy core are plenty fast for what they need to do and having a dynamic language like Python as a frontend makes programming very convenient. The best of both worlds, really.

I have never experienced Python being the bottleneck of my algorithms using these libraries.

Re: Why do C++ folks make things so complicated?

#32
post #29

C++ already contains "top" and "bottom" C++. You can write boost-style code, with heavy use of smart_ptr and STL algorithms & functors, or you can stay pretty close to the "C with classes" layer.

That's the thing I like most about C++. I can do any type of programming in it (OOP, functional, procedural, templates, etc.). I can roll my own data structures or use the built-in STL containers while working with low-level C-like code. I'm not sure why so many people complain about it. Once I began using it, it quickly became my primary programing tool on Unix, Windows and Macs.

"Beware the Turing Tarpit, where everything is possible but nothing of interest is easy." -- Alan Perlis

C++ is, for many people, a Turing Tarpit: Ask yourself why you wouldn't write something in assembly, and that's why they wouldn't write it in C++.

In specific, C++ doesn't have built-in support for real garbage collection. This means a lot of the idioms I take for granted in languages like Common Lisp and Haskell, to pick two very different languages that have true gc in common, are effectively impossible in C++.

For example, I can't reliably pass complex data structures around using function composition (think f(g(h(x)))) because I can't rely on them existing from one function call to the next; an allocation may have failed somewhere up the line and now what? Adding in all the code needed to handle that isn't just a pain, it obscures the algorithm to the point I'm not programming the same way anymore. I'm not even thinking the same way anymore.

Now for a purely personal anecdote: I quite like C. I can do certain things in C about as fast as I can think of them (mostly, things involving the POSIX API and no really complex data structures). I occasionally get the notion to add some C++ to my bag of tricks; not C-With-Classes, but C++ with Boost and the STL and whatever else g++ can handle these days. I might as well learn to swim by jumping in 500 feet upstream of Niagara Falls; there's "hitting the ground running", there's "hitting the ground doing back-flips and double-somersaults", and then there's "hitting the ground juggling sharpened sabres and gently convincing hungry wolves to not eviscerate you." Honestly, it wasn't this hard to learn how to write macros in Common Lisp. I don't know if the problem is just me or if it really is that bizarre in C++-land.

Re: Why do C++ folks make things so complicated?

#33
post #32
post #29

Earlier quoted context omitted.

That's the thing I like most about C++. I can do any type of programming in it (OOP, functional, procedural, templates, etc.). I can roll my own data structures or use the built-in STL containers while working with low-level C-like code. I'm not sure why so many people complain about it. Once I began using it, it quickly became my primary programing tool on Unix, Windows and Macs.

"Beware the Turing Tarpit, where everything is possible but nothing of interest is easy." -- Alan Perlis C++ is, for many people, a Turing Tarpit: Ask yourself why you wouldn't write something in assembly, and that's why they wouldn't write it in C++. In specific, C++ doesn't have built-in support for real garbage collection. This means a lot of the idioms I take for granted in languages like Common Lisp and Haskell,…

C++ is the wrong choice for many applications, and I'll reach for a higher-level language if I can, but if you need the low-level control of C and need some tools for better abstraction C++ is your only real option.

Re: Why do C++ folks make things so complicated?

#34
post #17

Earlier quoted context omitted.

But you can tolerate ref counting pauses? (When you release the last reference to the last object keeping a large tree of objects alive and have a lengthy cascade of objects being freed.)

Generally, that will still be far smaller than copying every object pointed to on the stack.

Maybe, but what does that have to do with the discussion? Only because there are copying garbage collectors, doesn't mean you have to use one.
Post reply on HN