Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As someone who has been painfully self-teaching C++ for the last ~1.5 years on and on, these are my hangups:

- The features that make C++ decent are often found in C++ 20/23, for which there are woefully few resources

- Code taking advantage of coroutines and generators isn't commonplace yet, rare to find examples

- C++ 20 concepts are a near mirror copy of Rust Traits and enable composition that's an alternative to inheritance, again difficult to find examples of

- C++'s way of "implementing" interfaces (IE iterator<T>) by having a magic defined set of type aliases and methods is not intuitive for me

- Writing code to control things like parallelization and thread scheduling that's portable across libraries is difficult. I think std:: executor is supposed to fix this but if I'm manually scheduling threads and I want to use IE oneTBB it's not obvious how to do this.

- Dependency and package management is a nightmare. Need to condense CMake + vcpkg into a Cargo like tool and make it a standard

- error messages are indecipherable. GCC 13-dev colors make this a bit better but human-written "ELI-5" errors succinctly explaining the problem and suggesting a solution (like Rust)

- flags like "-fsanitize=address,leak,undefined -fanalyzer -Wthread-safety -D_FORTIFY_SOURCE=" should be baked in to a default "dev"/"debug" mode newbies shouldn't need to know/think about

- Profiling and instrumenting/monitoring should be a few CLI flags with nice UI visualizers (IE LLVM X-ray)

- I have to Google what headers cstd/std stuff comes from half the time



C11 resources are just fine to start with. That will bring you to "modern C++".

C++ is not about bleeding edge. Nor is it about being a good, modern language.

It's key feature is to be able to tweak performance based on profiler data.

So, you want to write code you understand well enough, so you can adapt it based on the feedback profiler gives you.

If you don't need to write code that needs to get every last bit of performance, or you don't have to use some specific libraries, or maintain some legacy code, there is no reason to use C++.

Also, a humorous rant:

1.5 years? I've been programming C++ professionally for 15 years and it's still a daily struggle. It's a minefield of footguns, within which are buried unexploded munitions from previous generations, all administered by a posse of savants gleefully adding more and more convolutions to the language to "modernize" it.

I have to also Google what headers cstd/std stuff comes from all the time


Never memorize the things you can find in documentation, or through tooling.


FWIW the concept feature of c++20 has very little in common with rust traits. C++ concepts are closer to type assertions and aren't really a type system for templates.

The old c++0x concepts proposal was much closer (and of course precedes them), bit turned out it was harder to make it work.


Interesting that I also am learning c++ since some months and I have a very similar feedback as you.

Just to add something:

> - C++ 20 concepts are a near mirror copy of Rust Traits and enable composition that's an alternative to inheritance, again difficult to find examples of

I don't know Rust, but they remind me of Scala traits. I guess it's conceptually the same, and Scala comes first :)

> - The features that make C++ decent are often found in C++ 20/23, for which there are woefully few resources

Somehow yes, but I think lots of cool things happened in 11 and 17. At least when I read the docs, it seems so. C++20 seems to have simplified and ported a lot of more modern features to the language, though. But 11 was a game changer from my understanding.

> - Dependency and package management is a nightmare. Need to condense CMake + vcpkg into a Cargo like tool and make it a standard

Tooling is indeed something that requires a sort of unofficial community decision to say "just start with this and this". That's so true! But that also goes against the main philosophy of C++ which makes it so super cool!

> - flags like "-fsanitize=address,leak,undefined -fanalyzer -Wthread-safety -D_FORTIFY_SOURCE=" should be baked in to a default "dev"/"debug" mode newbies shouldn't need to know/think about

Did you try project_options[0]? I recommend it to all newbies like me. Just set the "enable_developer_mode=true" and you get all that stuff for free.

> - I have to Google what headers cstd/std stuff comes from half the time

In Clion you can cmd+click on the symbol and it leads to the header.

As a final note, another recommended resource is https://github.com/cpp-best-practices/

[0]: https://github.com/aminya/project_options


> I don't know Rust, but they remind me of Scala traits. I guess it's conceptually the same

Rust's traits are typeclasses. Scala's traits are like Java interfaces but more.


Rust's dynamic traits are like Java or C# Interfaces.

Rust's Static traits are used like C++ templates but with more compiler checks and guidance.

In both cases, you can separate the code that implements the trait from the class itself (like a partial class). In Rust you can also retroactively declare a trait and then implement that trait for a class you like (even someone else's class, or a standard class).


you're right, Scala has also type classes, though. Generics, traits, variance, etc., are all quite sophisticated in Scala. I wouldn't say it's taken from Rust. The idea had been there for a while.


That project options tool is pretty neat, thanks for sharing!


Let's add the fact that no IDE right now fully supports C++ 20. Visual Studio comes closest, but for example modules still don't really work well.


They work good enough that I only use modules on my hobby coding since VS 2022 got released.


I tried it around 6-9 months ago and the modules basically broke Intellisense - in even a smallest project with modules, the update of the Intellisense's internal state took 15-30 seconds. Hopefully it's better now, but I think I'll by trying out zig instead.


I would be interested in hearing what modern resources you have been using that have been helpful and which ones you would recommend.


"IE" ?


Yeah -- I thought it meant something along the lines of "for example" or "one instance being"?


Usually people use the lower case with dots, i.e. `i.e.`. Also one usually uses `e.g.` in those situations with `i.e` reserved for "that is". To illustrate:

"We had to come up with some way to cut our burn rate, e.g. lay off (i.e. fire) some of our workforce; cut facilities (i.e. get out of our leases),..."

As an aside, I wish there were "minor aside" conversations that wouldn't pollute the main thread so I could respond without occupying massive comment-space.


In AE it's also usual to have a comma following them, so

"We had to come up with some way to cut our burn rate, e.g., lay off (i.e., fire) some of our workforce; cut facilities (i.e., get out of our leases),..."

The reasoning being that these expressions are "parenthetic and should be punctuated accordingly" The Elements of Style


+1 for the comma (Strunk and White and Chicago Manual of Style for references)


id est (i.e.) = that is (literally "it is")

exempli gratia (e.g.) = for the sake of example, for example

See: https://en.m.wikipedia.org/wiki/List_of_Latin_phrases


Thanks.

Coincidentally, I had years of Latin so I knew those, but thought this had some other contextual meaning, a name of something (like IE for Internet Explorer). Apparently not!


e.g. -> example

i.e. -> in other words


e.g. -> Egg-zample

i.e. -> the other one


i.e. -> In other wErds


Surely not Internet Exploder?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: