C++ is huge and growing every 3? years (C++17, 20, 23...) is it really possible to master or can you only ever get to the point of being good enough to be dangerous?
LearnCPP: Website devoted to teaching you how to program in C++
91–100 of 145 posts
Re: LearnCPP: Website devoted to teaching you how to program in C++
#92As a newbie into programming, I get pulled all the time by people to learn my first compiled language either in C++ or Rust. Every time I ask even the most innocent question in any forum it becomes a shitshow, and I can see, I'm late to the party here in HN.
Two words: undefined behavior. In other languages, if you do a mistake, something fails around the place where you did it, or at least afterwards, or at least you can reason why the failure is exactly where it is. In C++, you cannot. Accidental array bounds overflow? Too bad, now your program crashes in a completely unrelated closing bracket (not even a statement) five minutes later.
In other languages, if your program does not crash and produces a correct answer until point X, you can be more or less sure that everything afterwards at least gets corrects inputs. Not in C or C++: if there was an UB before point X, the program may look like it does random things: some stuff is printing, some stuff is shown in the debugger, random lines are executed, arithmetic operations make no sense, perfectly valid functions crash: https://stackoverflow.com/questions/54120862/does-the-c-stan...
Re: LearnCPP: Website devoted to teaching you how to program in C++
#93Is this website any good? It's heavily pushed by some C++ subreddits. I don't even know what I would recommend to a newbie. I learned C 25 years ago, and dabbled in C++ 2 or 3 times since then. Bjarne's books might be great, but they aren't for anyone new to C++ and especially not anyone new to programming in general. C++ For Dummies/21 Days style books are just bad. And there are more bad websites than I can count.
C++ is awful for beginners exactly because of undefined behavior, no good book can fix that, IMHO.
As for topics covered, talking in details about linkage, functions, constexpr, bit manipulation before if/for statements is, uhm, questionable, if this is aimed at beginners. Then the site talks about type conversions, function overloading, structs, and arrays only appear somewhere in the middle. Moreover, much simpler std::vector is introduced _after_ C-style arrays. Wild ride for a reader, but one can argue such order is more "academic", whatever that means.
Re: LearnCPP: Website devoted to teaching you how to program in C++
#94C++ is huge and growing every 3? years (C++17, 20, 23...) is it really possible to master or can you only ever get to the point of being good enough to be dangerous?
You end up mastering a subset of the language. Typically whatever you use at work or in your free time. Whether that subset is 10% or 90% is kind of up to you. There was an old joke about everyone using a different subset of C++ but like most jokes it's mostly an over exaggeration. C++ (and C) have amazing backwards compatibility and there is a strong chance that code written 30 years ago will still compile, link, an…
I generally advise people wishing to learn C++ to read Bjarne Stroustup's 2nd Edition of The C++ Programming Language (TC++PL) first. All the Basic language features are there and it is manageable (i.e. C++98). Once they have an idea of this subset they can then move on to later standards eg. TC++PL 4th edition for C++11 and A Tour of C++ 3rd edition for upto C++20. This demonstrates the evolution of the language and brings home the point that there are orders of magnitude more C++98 code then C++11 and later.
Re: LearnCPP: Website devoted to teaching you how to program in C++
#95As a newbie into programming, I get pulled all the time by people to learn my first compiled language either in C++ or Rust. Every time I ask even the most innocent question in any forum it becomes a shitshow, and I can see, I'm late to the party here in HN.
Plus rusts strict memory management rules don't really translate to other languages, and c++ has a habit of changing wildly. The c++ of 10 years ago barely looks the same whereas python and c# feel less like the goalposts are moving.
Re: LearnCPP: Website devoted to teaching you how to program in C++
#96As a newbie into programming, I get pulled all the time by people to learn my first compiled language either in C++ or Rust. Every time I ask even the most innocent question in any forum it becomes a shitshow, and I can see, I'm late to the party here in HN.
If you're really new, I'd say either python or c# (unless you have a goal in mind). C++ and rust are both a lot more difficult to learn if you don't have any background imo. The scoping and memory management rules will distract you from learning the basics. Something like python with jupyter notebooks is pretty much perfect for learning or putting together quick projects, and c# to me feels like a more forgiving c++…
Java seems interesting from an employment perspective, but the small stuff I've touched seems extremely verbose. I feel like I have to write and think way more to do simple stuff. But I just had a brief introduction, I guess I can get used to it.
I wanted a compiled language that allows me to tackle some interests I have, and I feel It will be c/c++ wether I like or not, because one of my interests is fiddling with hardware. Nim can compile down do C apparently but it isn't widely adopted.
Re: LearnCPP: Website devoted to teaching you how to program in C++
#97Earlier quoted context omitted.
For the build system, I like: http://cliutils.gitlab.io/modern-cmake/ In addition to building, it will show how to add cppcheck and clang-tidy to your cmake files. That part is pretty easy. Just don't turn on every check in clang-tidy. Many of them are for specific code bases. Modernization checks are my favorite ones. Keeps you doing stuff the modern way. My link has you doing dependency management with git submodul…
Honestly, I find the usage of the adjective "modern" deceptive and insincere in the marketing term "Modern CMake". The "modern" scripting language doesn't even support return values and the variables lack basic type-safety. It breaks for anything beyond a simple Hello World. I would recommend any other C++ build tools that use a proper programming language for scripting, be it Meson or Bazel.
Re: LearnCPP: Website devoted to teaching you how to program in C++
#98As a Java dev who learned C++ at university the hate towards C++ is misplaced. C++ is a no thrills language which lets you have freedom but freedom to also shoot yourself in the foot 100+n ways, but this gives you a good foundation as a developer IMHO. Every time I think about garbage collection in Java, I can appreciate that I am not having to write code to destruct an object or worry about passing references incorr…
I switched from C++ to Java too. Still, every time I type `new MyObject()` without a corresponding `delete` I feel like I got away with some sort of crime ;)
Re: LearnCPP: Website devoted to teaching you how to program in C++
#99Earlier quoted context omitted.
For the build system, I like: http://cliutils.gitlab.io/modern-cmake/ In addition to building, it will show how to add cppcheck and clang-tidy to your cmake files. That part is pretty easy. Just don't turn on every check in clang-tidy. Many of them are for specific code bases. Modernization checks are my favorite ones. Keeps you doing stuff the modern way. My link has you doing dependency management with git submodul…
It's been quite a few years since I've really written any C++ and I'm surprised the landscape hasn't evolved at all. People are making the same mistakes... Modern CMake should be using toolchain files to specify the toolchain/flags. That should be included in ever CMake intro. (Hacking those into your CMakeLists.txt is not okay) gitsubmodules are also a hack 1: Many dependencies are not setup to be used as a CMake su…
Re: LearnCPP: Website devoted to teaching you how to program in C++
#100Earlier quoted context omitted.
Honestly, I find the usage of the adjective "modern" deceptive and insincere in the marketing term "Modern CMake". The "modern" scripting language doesn't even support return values and the variables lack basic type-safety. It breaks for anything beyond a simple Hello World. I would recommend any other C++ build tools that use a proper programming language for scripting, be it Meson or Bazel.
I dislike cmake, so when a sibling post mentioned meson I went looking. It doesn't seem to have good support for cuda, and neither does bazel, to the point I don't immediately find anyone getting it to work. These days the only reason I start a project at work in c++ instead of rust is to use cuda, so that would be a strong consideration. Is this easier than my brief glance would indicate?
I would think that rules like https://github.com/liuliu/rules_cuda should work for you in Bazel. (Tensorflow also uses Bazel, so I don't think that this should be a problem.)