

Why people think C++ is complicated? - nksonfire
http://www.easycppcodes.com/article/why-people-think-c-is-complicated/

======
flohofwoe
I fully agree with the authors concept that C++ is both a high-level and low-
level language, and it is important to choose the right 'sub-language' for a
given context.

I'd love to have the ability in C++ (and basically all other languages) to
turn on/off language and standard library features right in the source code,
it would do wonders for the maintainability of projects with many contributors
and large code bases in general.

Instead of writing a style guide in the sense of "don't use new/delete, don't
use raw pointers or arrays, don't use exceptions, don't use CRT functions,
don't use stl containers, etc...", and hope that everyone follows the guide or
catch violations in code reviews, the style guide would be part of the source
code, and violating it would result in compilation errors.

~~~
nanny
Honest question: why wouldn't someone want to use STL containers?

~~~
icefox
A bit of the no one ever got fired for buying IBM. By using the STL containers
you can quickly learn a not great, but not horrible API and have a good chance
of it being around down the road, your stuff will still compile, api wont
change and it might be available on other platforms.

~~~
TeMPOraL
Honestly, the API doesn't seem that bad when you understand what it's trying
to achieve. There are some hairy areas though (dealing with std::bind many
years ago comes to my mind, but I didn't understand back then that they were
basically trying to shoehorn half of Common Lisp into C++).

------
s_dev
Google Cache:
[http://webcache.googleusercontent.com/search?q=cache:http://...](http://webcache.googleusercontent.com/search?q=cache:http://www.easycppcodes.com/article/why-
people-think-c-is-complicated/)

It was down for me.

~~~
eleumik
great

------
LoSboccacc
wait, it isn't? I mean, I worked on that, carefully avoiding all the
shot_me_in_the_foot features, like non pure virtual stuff, dynamic and static
casts etc, but every time I engage in anything as simple as reading boost
sources with templates and stuff knitting magic I just get a brain freeze and
get back to java

~~~
ndepoel
Any language you choose is as complicated as you make it yourself. Some of the
cleanest, simplest and most readable code I've seen in my life was written in
C, while the most horribly complex, obtuse and over-engineered projects I've
seen were written in Java.

------
TeMPOraL
I never found C++ complicated but I suppose it's because this was the first
programming language I really learned. When you're learning your first
language, you don't have any frame of reference yet to compare it to. You
either grok it or don't. And then it becomes your baseline for programming,
you compare next things you learn to that first language.

~~~
crapnewdevs
C++ is not complicated, it a language that offers a range of features and
paradigms, and doesn't make you pay for what you don't use, unlike some
languages. However, modern "developers" are often impatient, have a frame of
reference that everything is ruby or js, not to worry about any resources
(they are infinite, right?) and think all their problems can be solved via gem
or npm install. The modern software stack has therefore become a bigger pile
of more diseased turtles, all the way down.

~~~
jahnu
It sure is complicated, and I say that as a full time c++ dev who sees it in a
generally favourable light.

There is a huge amount of knowledge that you need to pick up over the years
before you can consider yourself even an advanced c++ programmer let alone an
expert.

In my experience it's way more complex than c, JavaScript, Python and any
Lisp. However, you can use it in a c-like fashion and avoid some of the
complexity but if you want to work with anyone else's code then you have
little choice but to learn that complexity.

~~~
TeMPOraL
It is complicated compared to many other languages - that's why I wrote that I
didn't find it this way - I didn't know any other language then, so C++ level
of complication became my baseline (which made me find most other languages
seem very simple).

------
Ma8ee
The most favourable thing I ever heard anyone say about C++ is that it is a
decent language if you only use some parts of it.

~~~
jahnu
I think it's a true statement though.

Same for JavaScript :)

------
danbruc
»General relativity has a reputation for being very difficult. I think the
reason is that it is very difficult.«

Leonard Susskind

------
amelius
C++ is the perfect example that shows that you can't build a language
incrementally, while maintaining backward compatibility. You have to oversee
all the issues, and define the language accordingly.

I'm afraid after a while, Rust will see the same problems, unless they let go
of backward compatibility.

~~~
ricogallo
That's the reason Scala doesn't guarantee backwards compatibility for major
releases. Of course, there is always someone who complaints about it not being
enterprise ready.

------
nadams
[http://tehsausage.com/ptypes/doc/inet.examples.html](http://tehsausage.com/ptypes/doc/inet.examples.html)

vs

[http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/tut...](http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/tutorial/tutdaytime3/src.html)

I know a lot of people would criticize the practices/styles used in ptypes -
but I've yet to see another C++ library that is as easy to use, easy to read,
AND most importantly cross platform. Hell even raw sockets in C is easier to
use and understand than boost [1].

This is one of my favorite comments on reddit [2].

[1] [http://www.thegeekstuff.com/2011/12/c-socket-
programming/](http://www.thegeekstuff.com/2011/12/c-socket-programming/)

[2]
[http://www.reddit.com/r/programming/comments/197dn1/introduc...](http://www.reddit.com/r/programming/comments/197dn1/introduction_to_c_a_series_of_46_videos_created/c8lks22)

------
madiathomas
I support the idea of dividing C++ into two. That way people can start by
learning top C++, use it for some years and start to use features which are on
bottom C++ after gaining some confidence.

~~~
frozenport
The 'pro' features are heavily used by library designers. In practice, written
C++ is indeed, along the lines you mention.

------
wtf_is_up
Because it is?

------
airza
I think having to to divide the language into two semantically exclusive
sublanguages answers the question of the author. (Though the title here is not
his title...) The other answer (which there was an article about a few months
ago which was posted here) is "Because having exceptions is really complicated
when certain object actions can't throw exceptions."

------
cttet
I am a C艹 beginner from Python and C. I feel that the handling of trade-offs
between performance and safety/explicitly is passed to programmers and not the
language itself, which made it difficult for beginners to capture what is the
best practice. Choices may be good for experienced programmers, but they are
not very friendly for beginners.

------
dschiptsov
Because it looks like a standardized set of kluges suffering from the kitchen
sink sindrome? (compared to well-designed languages)

------
cmpitg
Perhaps a bit off-topic but serious question. I don't understand whenever
someone says language A is next to bare metal? What does a language have
anything to do with bare metal or performance? Isn't it the
compiler/interpreter that performance is about?

~~~
ziegmeister
Languages like C and C++ compile down directly to machine code, and the
resulting machine code is run from then on the bare metal without any further
translation.

Interpreted languages such as Python or Ruby (or languages that run on a VM,
like Java) go through an interpretation step _every time_ they are run that
translates them down to machine language.

This gives compiled languages an inherent advantage in terms of runtime
performance; programs written in these languages don't have the overhead of
translating to machine code at runtime. This is typically why people advocate
"next to bare metal" as having better performance.

~~~
TheOtherHobbes
That's technically true, but I think it has more to do with the programming
model.

In C and (sort of) C++ you can deal with actual bytes in actual memory
locations. You can find the exact memory address of a data structure, and you
can read or write directly to that location.

You can even prod the compiler to suggest that it uses real hardware registers
for variables.

You can also control how memory is allocated and released.

In most languages an array is just an array. You usually don't care where it
is in memory.

In functional languages you concentrate more on designing symbolic operations,
and the fact that there's real memory under there somewhere is almost
irrelevant.

But C/C++ are bare-metal-ish. In assembler you work directly with memory, but
you can control program flow. You can jump/branch to any address in memory.
Sometimes you can even overwrite your own code.

C/C++ won't let you do that.

As a former assembler guy, I find that C++ is the worst of both worlds. You
get the cognitive overhead of dealing with memory management and pointer
arithmetic and iterators, but the options for _not_ working with them when you
don't want to are limited - so it's hard to concentrate on the functional
level, and you do a lot of the work the compiler/interpreter would usually do,
but without the "do whatever you want" freedom of assembler.

------
minthd
Isn't that what happens in the arduino, where users use top-c++ ? and it works
pretty well for them, in a very harsh, constrained environment.

------
viciousplant
"Error establishing a database connection"

But I would say it's because others are easy.

Yes others are hell lot easier.

------
DevPad
Operating low-level resources makes it more complicated and because of that, -
big amount of programming mistakes made there are critical.

------
pjc50
-1 for use of "codes"!

(arguably C# is the "top C++" with its managed/unmanaged distinction)

~~~
pjc50
OK, so clearly the idea that "code" is a mass noun rather than a plural is
very unpopular. Or I've failed the "don't be negative" rule.

