
How to learn more as a C++ software engineer? - ingve
http://nullptr.nl/2019/01/better-cpp-software-engineer/
======
lordnacho
C++ is a vast language. If you look at the sheer variety of topics in
something like Stroustrups books, there a fair chance any one project doesn't
require most of them. Variadic templates, metaprogramming, memory barriers,
the specifics of memory layout, public vs private inheritance... How often do
you use all of these? Yet if you look at a few projects you'll often come
across new things.

It's a good idea to look through one of these books (Stroustrup, Meyers,
Alexandrescu, Antony Williams) just to index the topics in your mind.

Then there's the standard library, worth playing with a few data structures to
get used to it. Possibly Boost as well though IMO a lot of the good stuff went
into the STL.

~~~
basilgohar
While I agree that most of your listed examples are likely esoteric enough to
escape need in most projects, I am curious to know why public vs private
inheritance was amongst them, being that it is a core feature of nearly all
object-oriented programming languages.

~~~
dpark
> _I am curious to know why public vs private inheritance was amongst them,
> being that it is a core feature of nearly all object-oriented programming
> languages._

Private inheritance is not "a core feature of nearly all object-oriented
programming languages". C# doesn't support this, nor does Java. I don't
believe Python or Javascript support this in a first-class way either.

~~~
lordnacho
I think in Python everything is "public". C# it's been a while, I think you're
right though.

If you came from either of these languages and read a c++ file, you'd
eventually wonder why there's this extra keyword in the inheritance specifier.

------
pavlov
The author mentions a 10-day C++ conference as a turning point for his career.
I kind of wish I had that experience because personally I don't seem to get
anything out of conferences. I can't think of a single one I would have
enjoyed.

Regardless of conference topic, this is how it usually goes: the first talk in
the morning is fine, the second one is a mindnumbing one-hour walkthrough of a
really complicated way to do something obvious, and by lunchtime I'll rather
escape for good than eat lukewarm sandwiches while listening to small talk of
how someone's [IoT blockchain startup / enterprise logistics dev team /
college course] is amazing because of [conference topic].

~~~
StevePerkins
I've never even HEARD of a 10-day conference before. Most conferences I've
seen are two-days with an optional third, broken up as:

1\. Optional "workshop" add-on day, preceding the main conference. Basically a
guided tour through writing a Hello World app in Spring Boot, or React, or
whatever framework is hot that year.

2\. The main conference. Two days of hour-long sessions, with speakers
consisting of:

(a) consultants trying to promote their firms,

(b) "evangelists" trying to promote their company's products, or

(c) local devs who don't require travel expenses, and are just presenting a
topic to pad their resumes.

Around 90% of the value I've received from technical conferences came from
group 2(c), and I'm not sure that was enough to justify the whole.

What the author describes sounds more like "a training class", which is a
different animal. Even then, I've never seen a training course longer than 5
days.

~~~
zerkten
I didn't read "I was there for 10 days" to mean a "10-day" conference. CppCon
has multi-days classes or workshops that extend the conference. Maybe his
employer was good enough to pad the time to cover jetlag. This is something
I've seen EU companies do that US companies would never do.

PyCon is the longest conference event that I've encountered, but that involves
pre-conference workshops and sprints after the conference. It is great to be
able to immerse yourself in the community, but it can be tiring by the end.

------
ilovecaching
Learn Rust. I'm serious.

The Rust compiler will teach you concepts you need to understand to be an
effective C++ developer, like moves versus copies, working with type
variables, working with smart pointers, etc.

You could learn these things in C++, but it will be much harder. The Rust
compiler error messages are much nicer, and certain features like type
variables are at a higher level of integration than equivalent features in C++
like templates. The borrow checker will also teach you how to write _hygienic_
C++ which is something that will take you years to master on your own.

Lastly, Rust's tooling will keep you focused on learning the language rather
than fiddling with C++ build systems.

~~~
entelechy
I strongly agree. Think of Rust as a very opinionated and functionally
flavoured version of c++.

Also I recommend looking into F#, Haskell and Clojure.

------
unbendable
As a embedded systems (C / C++) and a ReactJS developer (both senior, I know
weird), I have to admit that the web dev ecosystem is much better to get into.
And yes I know the fragmentation is really bad in the JS world. But it is
nothing to the cluster fuck that I have seen in the C/C++ world.

And honestly it is not because C / C++ is hard to learn. They just didn't age
well. C++ is full of anti patterns, the build system (makefile) is absolutely
horrendous (yeah i know about cmake, dont tell me - tell the
manufacturer/vendor), the compiler is your worst enemy (gcc errors are
useless), testing isn't as widespread as I see it in webdev.

Code Quality is not a concern. I found myself often times looking for the
documentation in the source code. And truth be told i rarely find someone
advocating against it. IDE support before CLion is laughable compared to IDEA.
There was just VS that was nearly as good, but not a option for me as a Linux
User.

I had a discussion with someone on a Embedded Meetup and this guy trashed JS
because it isn't type safe. I tell you something C/C++ is NOT type safe. You
can't trust the type you would expect. NEVER. That is actually a big problem
in some use cases.

I am now in a state where I would say that I have a lot of experience in
embedded. It took a lot of time and frustration. But I really envy the people
that put so much effort into teaching and putting so much content to improve
and learn more about webdev. I am aware of the fact that some people are
programming trash in JS too. The thing is they didn't need to. It is so easy
to find good resources advocating good patterns for programming.

I have read on Rust for embedded and the work that some people put into it
gives me hope. I really really wish for C/C++ to vanish in its current state.
It is not friendly to newcomers and surely that is not because they re too
stupid.

And if I can recommend you some books (for embedded C/C++):

9781788830287 Embedded Systems Architecture (Good Introduction)

9788131521267 Data Structures and Algorithms in C++ (That actually helped me a
lot with persisting state in memory, some cool tricks)

EDIT: added some newlines

~~~
woud420
While I agree that _some_ Makefiles are terrible, I disagree that make is
absolutely horrendous. It's sort of what you do with it; it's a copy paste
garbled mess, of course it'll be terrible but you can make the same argument
about maven, sbt and quite a few other build systems.

On another note, besides C legacy (memcpy, printf, malloc, etc.), could you
point me towards something that is not type safe in C++ (preferably post
C++11)? I find the argument a little bit disingenuous after claiming rust is
type safe (you can do the same kind of non type safe magic with the unsafe
keyword).

~~~
maccard
> While I agree that some Makefiles are terrible, I disagree that make is
> absolutely horrendous.

I agree with the parent on this point (although make is not _the_ C/C++ build
system) - makefiles are horrible. Make is arcane, full of quirks that bite you
as a beginner, and suffers hugely from being not-portable (gnu make is not the
same as other flavours, and make on windows is practically non-existent)

> could you point me towards something that is not type safe in C++

Not the parent but [0] is a reasonable example.

[0] [https://gcc.godbolt.org/z/csjnM4](https://gcc.godbolt.org/z/csjnM4)

~~~
hermitdev
I think your example here is pretty disingenuous because you haven't created
any types, merely aliases of 'meter' and 'centimeter' that are of type int.

A better example of breaking type safety would be to involve a
reinterpret_cast or a C-style cast, or maybe pass something through a void*.

~~~
maccard
I don't disagree that I haven't created any types, but to someone who doesn't
see the declaration of meter or centimeter, it can be difficult to know that.
Especially if you combine it with almost always auto.

You can created tagged structs, but you inevitably end up needing to extract
the value underneath.

Regarding casts and void pointers, I think they're a slightly less dangerous
case. My Spidey senses tingles whenever I need casts - static (or to a certain
extent dynamic) casts are normally ok, but a reinterpret cast or a void*
parameter is going to warrant a discussion and explanation in a code review.

~~~
hermitdev
> I don't disagree that I haven't created any types, but to someone who
> doesn't see the declaration of meter or centimeter, it can be difficult to
> know that.

We definitely agree here. Better would be to use a library such as Boost
Units, rather than naked aliases.

void* is definitely problematic, and I kill it every chance I get, but it
persists in a lot of code due to C libs and unfortunate legacy dependencies.

~~~
maccard
Sorry I missed this.

> Better would be to use a library such as Boost Units, rather than naked
> aliases.

Completely agreed.

> void* is definitely problematic, and I kill it every chance I get, but it
> persists in a lot of code due to C libs and unfortunate legacy dependencies.

I've not seen it (thankfully) in anything other than actual C code or graphics
code, but whenever I do see it, I make a mental note of "here be dragons" and
make sure to take extra care around there... It's not ideal but it's life..

------
alexeiz
This is all great. But the real improvement in C++ skills can only come from
real work, solving real problems. No amount of time spent on discord/slack,
blogs or conference talks can substitute the real work experience. When you
learn something from a blog, book or conference talk, you should go home and
apply your new knowledge to the problem at hand, realize the pros and cons,
understand the trade-offs. Without this work your knowledge is only skin deep.

~~~
janwilmans
Very true, I will add that and more !

------
nuclx
My advice would be not to specialize in one language too much. Just don't care
about all the clutter that's in C++, you won't need more than a tiny fraction
of it ever anyways. A lot of them are shoe-horned concepts brought from other
languages. Prefer to learn the concepts in those other languages to get a
clear grasp of what their use-cases and benefits are.

~~~
martincmartin
Your advice is great, with one caveat: early in your career, people hire you
for your potential, so being able to pick things up quickly is the most
important skill you need, maybe the only one. Later on, they hire you for your
ability to do things. Picking things up quickly is important, but also knowing
areas in depth becomes equally important.

So, by all means, people should learn the concepts from other languages. But
then, they should also go deep into various areas. Knowing C++ well enough to
write portable, efficient, maintainable code, and developing the habits so
that's natural, is a good skill to have.

------
mapcars
He-he, stop being a `C++` software engineer and become an `anything` software
engineer :D

~~~
robertAngst
Right?

The moment my programming abilities changed was when I had to write a complex
database.

One day I was doing some python job automation and decided I wanted to store
the data in a database. I found sqlite existed, now I'm an addict.

------
zozbot123
You can _always_ learn more C++. The C++ standard alone is thousands of
densely-written pages - and they add to it with every new edition! So, don't
worry about ever running out of stuff to learn about.

~~~
radiator
Agreed. Is the author sure he is asking the right questions? Is learning more
C++ The Goal?

------
crb002
Exercises for Programmers by PragProg and try to use Qt with them. Then
Effective STL. Then Meyers books. C++ is fragmented between STL/Boost/Qt so
you are actually learning three standard libraries.

------
beardedwizard
Isn't this more about the community the author found around a technology they
already loved as opposed to any specific knowledge gained about cpp?

------
mbrodersen
Learn Haskell. Seriously. It dramatically improved how I write C++. And I have
been writing C++ for 25+ years.

------
robertAngst
My suggestion-

Go home and do a C++ project.

Try turning on stuff with an arduino, then try making it useful.

Or try building a program for yourself.

