
I learnt C++ in 2018 and have no regrets - ingve
https://vishnubharathi.codes/blog/learning-cpp-2018/
======
anuragsoni
"To round up, C++ does not dictate about its tooling, which basically gives
lot of choices and flexibility. But at the same time it is making it complex
for beginners to come in to projects and start projects with it."

This was a big problem for me when I first started using C++. I don't remember
it being too bad when I was just working on small projects and things I wanted
to do at school. The problems started when moving past the "1-person"
projects. Want to contribute to other projects? Chances are they all have very
different build setups and configurations when it comes to building, testing,
dependency management. That adds some friction even before you start taking a
look at the actual code-base.

I understand that a lot of these problems can occur for languages as old as
C++, but I wish the tooling was a little more opinionated and worked a little
better at guiding newcomers into doing things in a nicer manner.

~~~
hipokampa
All C/C++ projects I have ever seen used either cmake or autoconf build
system. It's pretty standard.

~~~
jandrewrogers
That's an availability bias. While cmake is common in commercial settings, I
haven't seen autoconf used outside of open source. I've seen scons and meson
both used as well at various companies.

Meson seems to be spreading pretty rapidly. After I was introduced to it a few
years ago for work, I started using it as my default build system for C++
elsewhere and more C++ devs I know have started using it. I've seen it replace
CMake and make at large companies for C++.

~~~
gshack
Why would one use menson over cmake ?

~~~
jandrewrogers
Meson is much easier to use and configure for C++, being quite obviously
designed specifically with C++ builds in mind. It automagically does the right
thing for setting up most C++ build environments by default with virtually no
config or quirks you need to learn. It is built on top of Ninja, and generally
very fast and efficient. The only real knock against it is that the
documentation isn't as good as could be, and it is evolving quickly, but the
fact that it often "just works" doing the obvious thing makes it less of an
issue. In my experience, setting up a cmake environment has a significantly
steeper learning curve and is more work.

The tradeoff is that Meson takes a fairly rigorous "one correct way" approach
to how you organize your builds. It doesn't prevent you from doing anything
functional but what it forces you to do is very sensible, minimizes the
potential for issues in diverse environments, and reduces the degrees of
freedom Meson has to sort out. A prohibition on unfettered creativity,
advisable or not, in how you manage your builds has turned out to be a
blessing in my experience because it codifies what are very arguably best
practices in code and then makes it easy to implement them.

I'm fairly agnostic on build systems -- I've probably used a dozen -- but
Meson, even in its relatively youthful state, is the best C++ build system
I've used so far in terms of getting things done quickly in a maintainable way
that is easy to use for average programmers.

~~~
RealityVoid
How would you evaluate Meson as a build system for C projects? I _think_ C and
C++ build process is very similar, but I only work professionally with C, so
maybe there are some quirks to C++ I am not aware of.

Basically, I wonder if you would recommend Meson as a build system for a
mostly C project with maybe some C++ parts and some extra external tools ran
on top.

~~~
jandrewrogers
I agree with your presumption that it almost certainly _should_ work well but
I haven't actually used it for a C project. Offhand, I can't think of anything
that I would expect to break.

------
hellofunk
> My quest for relearning C++ started in November 2018.

That’s great! I’ve been using it since 2013 and still haven’t learned it!

~~~
blub
What language can one say that they fully master?

I've been using Python since 2008-ish on and off for various scripting tasks
and small tools, I can't say that I've "learned" it. They keep adding new
stuff, some things I forgot, others I never needed.

I've been using C++ professionally since ~2006 and for similar reasons I won't
say that I master it either. Metaprogramming is a clear weak point for me, but
OTOH I find the whole exercise pointless and unpleasant. Unless one wants to
be on the standards body, it's not really worth trying to learn C++ (or any
other language) at 100% IMO.

~~~
imglorp
It's worth pointing out one measure of complexity: the Stroustrup book (4th
ed) is 1376 pages, and that was 2013. Since then there's been how many layers
more on top?

As a contrast, the description of Common Lisp syntax fits on a sticky note,
but the library and semantics spec take about the same number of pages to
describe a similar amount of functionality.

The two extremes represent different locations on the syntax-vs-library
complexity tradeoff continuum.

~~~
TeMPOraL
> _The two extremes represent different locations on the syntax-vs-library
> complexity tradeoff continuum._

I'd say it's a syntax x language semantics x libraries triangle. Common Lisp
may have trivial syntax, but there are some hidden gems of complexity in the
language semantics level. To this day I don't _really_ understand eval-when,
and I've been using Common Lisp for the past 9 years.

~~~
imglorp
Yeah that sounds about right. It's a 3 space.

------
TeMPOraL
I've learned 15+ years ago, and I stopped paying attention around ~2010, which
is just before significant changes were made. Even though I read up on some
features and concepts from C++11 and C++14, I feel so disconnected from what's
going on as if what I learned was a completely different language.

Can anyone recommend any source for someone with lots of pre-C++11 experience
to get up to speed with current capabilities, and the current community?

EDIT: Thanks everyone for the suggestions!

EDIT2: I skimmed Anthony Calandra's list, and most of the new features seem
indeed just cute, but not fundamental changes. Still, I want to reiterate the
worry I expressed downthread: how much did the underlying semantics, the
idioms, and the general way of thinking change?

~~~
linuxlizard
I've been in the same boat--relearning C++ after using C++98(!) for a long
time. My first go-to book was _A Tour of C++_ , 2e by Stroustrup. Also
_Effective Modern C++_ by Scott Meyers (of _Effective C++_ fame).

Other books I've been reading: _C++ 17 The Complete Guide_ by Josuttis _C++ 17
in Detail_ by Filipek

Lots of good blogs out there. Also the CPP Podcast.
[http://cppcast.com/](http://cppcast.com/)

There are also a lot of great blogs covering new features. Also

~~~
freedomben
More of a meta-comment, but the underscores you used to presumably get
markdown italics should actually be asterisks on HN. Normally it doesn't make
a readability difference but trying to parse the book names from your post was
a tad mentally painful. Took me a little while to realize the asterisk v.
underscore thing so I thought I'd pass it on.

Note: I do wish HN would adopt standard markdown

~~~
linuxlizard
Oops. Sorry. I had completely forgotten HN markdown. I usually use the
underscores around book titles with cleartext in mind. I'll remember asterisk
in the future.

~~~
TeMPOraL
> _I 'll remember asterisk in the future._

Aaand you've just learned all the formatting HN has :). That, and URLs
automatically turn into clickable everywhere except the body of a self-
submission (i.e. submitting a text instead of a link). Any other formatting
here is just convention.

~~~
ltc5505
_Thank you!_

------
rhodysurf
I use it every day at work and there are days where I leave thinking its the
best language on the planet and others where it makes me throw my laptop
through a wall.

Wouldn't have it any other way haha

------
chubot
_like let me read the source code of a open source software today_

To me, this is the most powerful reason to learn C and C++. If you know these
languages, you can read the codebases of all the things you use and contribute
to them (every browser in existence, every Unix in existence, most user space
tools, many GUI tools, many low-level libraries that mobile apps use).

Even if everybody stops writing C/C++ today, you'll still be using software
written in C/C++ for decades.

And of course, that's a joke -- there's still at least 10x more C/C++ being
written every day in the world than any other language that compiles to native
code (Rust, Go, etc.)

------
ryandrake
He has no regrets, but does have a basic_regret<char, regret_traits<charT>,
allocator<charT>>

Welcome! As someone who’s been using C++ pretty much continuously for two
decades, I think there has never been a better time to learn it. We finally
have compiler competition that has resulted in robust support for the
language’s great features.

------
craigsmansion
Well, after learning C++ there wouldn't be any regrets left to have.

------
seanhandley
> Within C++ is a smaller, simpler, safer language struggling to get out.” -
> Bjarne Stroustrup

Ah, yes. I think they called it "C".

~~~
wues
C compatibility was the very reason for which C++ is bigger, more complicated
and less safe than a similar language not compatible with C could be.

~~~
wbl
Really? C++ accidentally has a Turing complete templating layer. I suppose one
could point to Common Lisp but if you think that is simple....

~~~
TeMPOraL
Well, Common Lisp _is_ simple. Except maybe the Metaobject Protocol (which
ultimately didn't make it into standard, but it sort of still is). And except
eval-when. Eval-when is magic.

------
usgroup
Similar experience here ... it took no time to learn c++ because it’s not the
pre C11 language.

You can make whole applications without touching memory management with RAII
patterns; and C++ APIs are usually not the Java OOP monstrosities everyone
hates.

Operator overloading is just so damn useful . You can make very elegant APIs
in C++ as a result.

------
thosakwe
I also used 2018 to learn and get proficient in C++.

Honestly, I don’t really like it. The only real reason for that is that using
smart pointers is verbose, but I don’t want to do manual memory management
where it’s possible to instead rely on RAII.

Ironically enough, though, C++ is probably the second of two languages I’d
consider my “go to.”

~~~
pavanky
You dont go from beginner to proficient in any language in 1 year, much less
C++.

~~~
thosakwe
Well, I guess "proficient" in relation to someone who had started with the
language 1 year ago. There is definitely still a lot left to learn. I don't
intend to claim mastery, though.

------
sidcool
I am learning Rust currently and it's fascinating. The concepts are very
different and forces me to thing differently. I hope that Rust soon supports
things like kernel programming, asynchronous networking, GUI programming etc.
that C++ is so good at.

~~~
zanny
Rust already supports kernel programming, that is what Redox is. You can do
async networking today on stable with tokio and futures or on nightly with
futures-await and prototype async/await syntax. You can do GUI programming
with gtk-rs.

Its pretty unlikely anyone is going to take on the monumental project of
"write a software GUI kitchen sink suite like Qt, but in Rust" any time soon.
Not because you can't, but because such projects are by their nature at
minimum millions of LOCs.

------
blt
> started learning C++ in November 2018

> blog post in January 2019

> "learnt" in past tense

------
vnorilo
Many here talk about the complexity of C++. I concede it's a huge language,
and not a beautiful one. However, I wouldn't call it that difficult. Being a
systems language, once you understand (roughly, sans optimization finesse) how
the machine code is generated it starts making a lot of sense. Maybe C++ is
even educational because so many nuts and bolts are showing. Personally I'd
recommend some systems programming to everyone, but if thats not on your radar
at all, maybe don't bother. C is also a fine choice.

~~~
mempko
Many programming languages try to have perfect symmetry and because of that,
fail to be useful in the real world. C++ has constructs such as template
specialization that allow symmetry breaking. Symmetry breaking is what makes
nature beautiful and therefore I would argue C++ IS a beautiful language. C++
is complex because the world is complex. Just as a mountain is shaped by time
and the elements, C++ is also shaped by decades of experience and change.

This is what also makes Bjarne one of the greatest language designers. Where
most designers would have gone off making new languages, Bjarne has been
polishing the C++ stone the whole time.

~~~
crimsonalucard
The complexity of the world arises from simplicity. All complex things in the
universe in the end are just atoms.

Is it better to build a complex programming language that handles real world
complexity?

Or is it better to build a simple programming language where complexity is an
emergent property than in turn use that to handle real world complexity.

One issue of building a complex programming language is that if you build the
language to handle one type of complexity, it becomes hard mutate or shift
that programming language to handle a different type of complexity. This is
essentially the issue with whats happening with the newer versions of C++.

------
johnvega
"C++ is hanging around for a long time ( 34 years till date according to
Wikipedia). It is powering some of the world’s oldest and stable piece of
software written over all these years."

Autodesk AutoCAD (36+ years old) CAD software is one of those piece of
software that is still widely used today and very likely used to design
physical products many people use today from your toothbrush, office chairs,
towering skyscraper buildings to parts of a jet plane you've flown in from
your last vacation.

------
Kaveren
> "I have to pay: First and main concern being that the standard study
> materials for reading about C++ are not free."

I don't think this is more than a minor issue. If you can't afford it, the
book is very easy to obtain online for free, either through piracy or a paid /
free trial Safari Books Online subscription. If you felt so inclined, you
could pay for the book after making money with the C++ it taught you.

~~~
gpderetta
The last draft is always available for free from. The standard committee
website.

The document is definitely not a good way to learn the language.

------
barbecue_sauce
I'll take this opportunity to plug Bo Qian's C++ videos on youtube if anybody
is interested in learning modern C++. They are to the point, code-focused,
don't waste time on basic syntax, and cover a lot of ground (lvalues and
rvalues, move semantics, inheritance types, etc.). Only issue is they are only
current to C++11.

------
mempko
I like that the author mentions the STL explicitly. The STL is one of the most
beautiful libraries ever written. There are few language libraries that are as
clear and well designed as the STL. Alex Stepanov is completely underrated
outside the C++ community.

~~~
pkolaczk
Some wouldn't agree:
[http://wiki.c2.com/?StlSucks](http://wiki.c2.com/?StlSucks)

Personally, I find Scala standard library much easier to work with and at the
same time much more flexible and powerful.

~~~
lorenzhs
That is pre-C++11 and woefully out of date. To pick out the first two
"defects" listed: std::auto_ptr was deprecated in C++11 and removed in C++17,
and std::unordered_map was introduced in C++11.

~~~
TillE
It's kind of frustrating how much vocal (often outraged!) C++ criticism comes
from people who haven't seriously used the language in years, if ever. It's
just noise.

Like a few days ago I saw a bunch of complaints about how C++14 and beyond
were adding so much stuff and it's just bloat or overcomplication. No! Using
that stuff makes my life so much easier, whereas C++98 was indeed a miserable
nightmare.

------
raydev
Perhaps this is an appopriate place to ask:

What is the best C++ IDE on the Mac?

In particular, fully project-aware autocomplete is a baseline feature. Does
emacs or Vim offer an autocomplete plugin that matches the power of IntelliJ,
or even Xcode?

Is CLion worth the money? Other paid alternatives?

~~~
improv32
If you're comfortable with emacs, irony + rtags does pretty much all the IDE-
type things I need it to. You can autoconfigure rtags based on your build
system (supports basically all of them). you get variable type hints, function
arg hints, contextual autocomplete (including template stuff), jump to
definition, find references, you can fuzzy find and jump to
methods/identifiers/symbols across your project, compiler warnings highlighted
inline, it's a pretty good setup. I use the doom-emacs distribution which has
it all configured and ready to go, im sure spacemacs also has a good setup

------
viach
One can't just learn C++ in one year, imho.

~~~
retro64
I've been coding heavily in C++ for now over 2 decades, and when I interview
someone I typically can get a pretty decent picture of within a general 3 - 5
year range of how long they've been coding based on the various details they
gave when answering the questions about the language. And yes, of course
someone could have 10 years experience, or the same experience for 10 years
and never grow, but in general I found I am pretty spot on.

So I agree, 1 year doesn’t even begin to cut it. You need more than book
knowledge, you need the experience of watching your masterpiece crumble under
its own weight (sometimes several times) or have the joy of hunting some
obscure bug because you failed to recognize the trap you had set for yourself.

I certainly wouldn't want to scare anyone off from C++, because personally I
find the empowerment is worth the pain. It just takes time to learn what to
avoid.

~~~
smileypete
>you need the experience of watching your masterpiece crumble under its own
weight (sometimes several times) or have the joy of hunting some obscure bug
because you failed to recognize the trap you had set for yourself.

Very good point, but that's by no means unique to C++. Maybe that level of
experience ;) in a related language, plus a good working knowledge of C++
would be acceptable?

------
nayuki
It's too bad he made no mention of the concept of undefined behavior in C++.
When coming from any language with consistent semantics, UB is a nasty
surprise that makes you seriously question how correct your code is.

------
CraftThatBlock
I'm in the exact same boat as you. I've been mostly writing JavaScript for the
past 2-3 (with some Go, and more recently Flutter).

I've started to learn some C++ a few days ago, mostly go get into lower level
code and into game development (Unreal), and I've found it to be pretty great!

I've been going through A Tour Of C++ and it's a great primer on the whole
language. I also read the Learn X In Y Minutes on C++ to get a feel of it
before diving in.

What are some high quality, small C++ projects I could play around with and
read the source code? I'd like to explore it in more practical use next.

------
pknerd
I studied C++ during university days and after that I never got a chance to
learn it seriously due to my job commitments as a web developer. I did work on
C# but not C++ professionally. I always admired my friends who could write
good C or C++ code.

So many times I wish to learn it seriously but these new editors for web
development and Python made me lazy enough that I wish to have some
environment and way to write and compile C programs easily.

I heard modern C++ is way better than what it was in early 2000. I want to
give it a try, hopefully, I will be able to learn and implement Pointers
properly.

~~~
Skunkleton
I have spent my whole career writing C or C++. While it is true that I write
code at a different layer of the stack than is common for languages like C#, I
wouldn't say it is particularly admirable. There are intermittent cool things
that I get to write in C (data structures, protocol stacks, etc.), but for the
most part it is just plumbing. There are lots of cool things that people get
to implement higher up the stack too.

~~~
pknerd
Will you recommend some source? I mostly have a Web Developer and Python
background

------
ixtli
> I feel that [a programming language is] just a tool to instruct a machine to
> do something.

I can't stress enough how true this is.

~~~
kgwxd
Machine code is just a tool to instruct a machine how to do something.
Programming languages are for human-to-compiler _and_ human-to-human
communications.

~~~
oscargrouch
While you are right, i see a lot of enginners making bad decisions for the
right tools to use for a giving problem, based on psychology and emotional
reasoning.

Things might even work in the end, but you can end with a weak project that
wont scale or will crumble when faced with the destructive nature of time.

I know its a controversial topic, but i think a little bit of zen-budhism
training of the mind can make wonders in making those sort of decisions, where
the unbalanced parts of our psychology will eventually show up and cripple
what could be a great thing.

I am an IT enginner, but i practice a lot of self-mind vigilance to understand
my decision making process, to avoid making the most confortable decisions and
going for the write answer, no matter how painful and expensive it may sound.

To give an example of this, i remember for instance CouchDB vs. MongoDB, where
the concepts were layout in CouchDB, but it was done in Erlang, so as soon
someone did almost the same thing in a language that suits a database
development well like C++, the tool sky rocket and reach all of its potential.

The language i see this happening the most for instance is Python. Where you
have great concepts and great enginners but where a lot of them shouldn't be
using Python for that particular goaç. Again here i can use Mercurial as an
example of a great tool in a bad fitting language (for the given tool, as
Python might be a great fit for other use cases).

------
master_yoda_1
Why you think anybody regret learning c++?

------
hannofcart
One does not just "learn" C++.

------
newdaynewthrow
Hi, I guess I'm a little out of the loop... Why would someone generally have
regrets? What language "should" be learned in 2018 instead of something like
C++ (which it sounds like is becoming obsolete)

------
itissid
> Because you just can’t start reading the source code of a code base from top
> to bottom.

This is obviously not what one should do. Read the test cases first is what I
do. It makes for much quicker iteration.

------
dana321
I learned it this year, with cmake. Then i moved onto go.

I tried rust, but they keep changing it and breaking modules i need to use!

~~~
pornel
Rust in stable releases hasn't made any serious breaking changes since 1.0 in
2015. There were tiny breakages in edge cases caused by more or less bug
fixes, in line from breakages you might get when upgrading GCC to a newer
version.

If you find your dependencies are breaking:

• Keep a lockfile (Cargo.lock) committed in your project, so that your deps
won't suddenly get updated to some newer, potentially buggy/incompatible
version.

• If you're updating dependencies, also update the compiler. It's possible
that new versions of dependencies require latest version of compiler.

------
timvisee
I wonder what you'd think about Rust.

------
setquk
There's plenty of years left to get to hate it (I learned C++ in 1998 and have
kept relatively up to date)

------
dliebeskind
C++ is also the language to know if you’re going to be writing EOS smart
contracts.

------
pietromenna
great article, I learned a lot from it:

1\. Current setup and where to go learning (the books) 2\. It also had
nightmares in colleague with C++, but yes, C++11 fixed a lot of it. 3\. Nice
links to the other tooling.

So, author, thank you for your post!

------
ausjke
what about the old and tested makefile with autotools? I still think they got
the job done pretty well and I'm using them.

------
porpoisely
What's there to regret? For purely edification purposes, there isn't a better
OOP language ( though it encompasses other paradigms as well and isn't purely
OOP ) since it doesn't have training wheels. You could hurt yourself with it
but it certainly allows you to explore and learn.

Also, you could "learn" it in a year, but it takes you a lifetime to master
it.

~~~
seanmcdirmid
C++ is not very canonical OOP. And by that I don’t just mean it’s multi
paradigm nature, but it’s realization of OOP features. Using C++ teaches you
mostly about using C++ and doesn’t really transfer across the paradigm.

~~~
vasilipupkin
I think that statement would have to be classified as inaccurate. using C++
teaches you mostly about general purpose programming and it's pretty easy to
go from C++ to python to Java to bash, etc.

~~~
lmm
Nonsense. C++'s template system behaves unlike any other language (things like
SFINAE and the techniques that use it do not transfer), C++-style RAII is
relatively unusual, I don't think any other language requires the programmer
to think about virtual versus non-virtual inheritance, the C-derived sequence
point rules are obscure and much looser than most languages' evaluation rules,
the exception-safety rules are unique to C++, most languages don't make you
track the minutiae of a dozen different integer types with inconsistent
promotion rules, textual macros are abominable, C++ has more obscure control
flow constructs than most languages... meanwhile the language has no standard
support for true sum types, garbage collection, unit testing, poor library
tooling, a limited type system... which means you don't learn the general-
purpose techniques that rely on these things.

If all you know is C++ you will be able to produce a limited amount of working
code in a handful of C++-like languages, sure - but even in Python or Java or
Bash you'll produce very unidiomatic code if you write in C++ style. If you
tried to work in e.g. Smalltalk or Erlang or even OCaml you'd really struggle.
It is not a good way to learn general-purpose programming, because the
language is hugely complicated and most of the complications are C++-specific.

~~~
vasilipupkin
well, that's just like, your opinion, man ( big lebowski reference for those
too young to know ). The reason I disagree with you is because I have never
met a C++ programmer who only knew C++ and couldn't easily do work in some
other language, but of course plenty of people know other languages and can't
do C++. Yes, SFINAE and RAII - you can go for many years of working in C++
without writing much code using either one of those.

~~~
jungler
That is more like an example of Blub paradox in action: You can write in
everything as if it were C, you can't write C as if it were everything else.

Except that it makes a point that is subtly different from the one pg
originally raised in discussing Blub paradox: If you only care about shipping
something, you aren't inclined to think about abstraction as a goal state, and
that's what these other languages are doing: handling things with a goal of
adding abstraction that for a C++ user is out of reach or requires
considerable knowledge of the C++ standard. Users of Python or JS don't know
what a pointer is, and that's intended by design, because for most
applications it is an implementation detail and automating it away is
desirable.

When most software was written in assembler, data structures more complex than
an array were often avoided, because it was difficult to code and debug them.
And if you were an assembly coder of that era, you might well say that you
didn't see the point of structured programming, or that you could easily get
the same effect in fewer bytes. And to some degree, you'd be right, because
you would just design a smaller scope of application that makes those
techniques viable.

Trying to write something resembling modern C++ style in x86 assembly, in
contrast, would be as fruitless as a JS coder trying to use C++ like JS, since
your abstractions wouldn't be there. You'd have to learn the thought process
of a lower level coder and apply those strategies instead of the ones you are
comfortable with.

------
aaaaaaaaaab
>Cmd+F

>"Rust"

>3 results

T-h-r-e-e? How is this even possible?

------
CodeSheikh
Unless your job demanded it I can't think of a compelling reason for a Node
guy to learn C++ as their go to choice of OO language. Why not Java? Even
Python is a good gateway to OO for folks coming straight form Node background.

~~~
CyberDildonics
Someone has to actually do all the native programming that powers scripting
languages and VMs.

~~~
chooseaname
I think some people forget that it's not Javascript all the way down. Wish I
could click the up arrow twice.

