8 ms·
LearnCPP: Website devoted to teaching you how to program in C++
- jcq3 4y agoBetter learn chatGPT
- tester457 4y agoPractice GPT a day, to keep the replacement away
- deleted 4y ago[deleted]
- tyronehed 4y ago[dead]
- okaleniuk 4y ago[flagged]
- hahaxdxd123 4y ago[flagged]
- pjmlp 4y agoOr is it like vaping that also comes with its own set of issues?
- willnonya 4y agoThe important question is which one makes you look cool and which makes you look like a douche?
- hulitu 4y agoBecause rust is used in ? and in ? The majority of programs on my system are written in C. Then C++ . Then Python. I guess i have more programs written in TCL than in Rust.
- FpUser 4y agoI propose the other sign on HN: beware of crusaders
- Steiner23 4y agoDilate.
- password-234 4y ago[flagged]
- wiseowise 4y agoWhy do you think C++ is like smoking?
- okaleniuk 4y agoBecause we live in a free society and smoking is a proper right. It is unhealthy and largely outdated habit but if you want to light a cigarette, you can. Programming in C++ is also an outdated habit. There are better languages, better technologies, and there are generally better ways to create software than writing code, compiling the code, replacing std::abs with abs (real issue, these are different functions) and recompiling the code again. But writing in a horrible language is a proper right as well. People write in Brainfuck for fun and good for them! Jack Rusher sums up what better programming looks like in his Strange Loop talk https://www.youtube.com/watch?v=8Ab3ArE8W3s https://www.youtube.com/watch?v=8Ab3ArE8W3s
- jbaber 4y agoThey're likely referring to the (not too crazy idea) to slowly deprecate C++ in favor of Rust. There's plenty of extant code to work on, of course. https://www.zdnet.com/article/programming-languages-its-time-to-stop-using-c-and-c-for-new-projects-says-microsoft-azure-cto/ https://www.zdnet.com/article/programming-languages-its-time...
- Andoryuuta 4y agoStatements like these only serve to polarize people, not encourage them to write safer code / use safer languages. There are many places where C/C++ (and many other non-Rust languages) are still used, and where it would not be feasible at this time to fully rewrite them in rust. Modern resources like the OP posted should be encouraged, as they actively teach about proper use of the language, and foot-guns to avoid (e.g. don't use c-style strings + strcpy, use smart pointers, etc).
- okaleniuk 4y agoProper use of the language is what https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines is for. Before that, there were HICPP, JSF, MISRA, ISO/IEC TR 24772, NUREG 6463 etc. I have been writing in C++ for most of my professional career, I wrote company-wide guidelines, I still teach and consult. I absolutely agree that C++ is not going anywhere anytime soon. That being said, so is smoking. We can't just tell people not to smoke anymore, we live in a free society. But we really shouldn't drag more people in.
- hcks 4y agoSorry, but Rust is doomed to be forever solely used for meme startups and nth rewriting of basic UNIX utilities.
- okaleniuk 4y agoRust is essentially C++ done right. It isn't as aggravating as C++ but it is the same technology essentially. It doesn't bring anything new to the table. It's yet another LLVM frontend. We need to look into something far more fascinating like http://www.spiral.net/ http://www.spiral.net/ Something that creates value a mere compiler, which is a technology from the 50s, can not.
- Klonoar 4y agoYour comment is just as needlessly inflammatory as theirs. Chill.
- aldanor 4y agoSimilarly, sorry, but C++ is doomed to be forever solely used for (a) maintaining codebases that noone wants to maintain but doesn't have a choice, and (b) organising cpp conferences to maintain self-confidence of a crowd of programmers whose skill set is becoming more and more outdated. /s /s
- gpderetta 4y agoat the very least it will be needed to maintain the backend for the rust compilers.
- optimalsolver 4y agoAfter many headaches trying to get Numba to work with Python, I decided to just go out and learn C++. This was my main resource and can highly recommend.
- einpoklum 4y agoAs a C++-head with little experience in Python - I would ask you to elaborate a little. What were trying to achieve with Numba, that gave you headaches?
- optimalsolver 4y agoSymbolic regression which involves a ton of CPU-intensive mathematical operations, but Numba is very picky on what it will or won't optimize.
- TillE 4y agoThis is essentially why C++ is here to stay. I've wasted a lot of time fiddling with bindings despite knowing C++, and ultimately the best answer is to just do most of your work in C++, and write application-specific bindings for Python/Lua/whatever if you really need to.
- mothsonasloth 4y agoAs 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 incorrectly.
- trinovantes 4y agoI haven't used Java since school so I'm curious about modern Java. Do you need to worry about circular references preventing garbage collection or are there easy tools to detect such cases?
- deleted 4y ago[deleted]
- ponow 4y agoJava will collect sets of objects with circular references: https://stackoverflow.com/questions/1910194/how-does-java-garbage-collection-work-with-circular-references https://stackoverflow.com/questions/1910194/how-does-java-ga...
- School-Cotton 4y agoCircular references have never prevented garbage collection in any version of Java AFAIK.
- einpoklum 4y agoFor Java'eans, here's an interesting StackOverflow question about why there's no Garbage Collector in C++ and what it means: https://stackoverflow.com/q/147130/1593077 https://stackoverflow.com/q/147130/1593077 and my particular answer: https://stackoverflow.com/a/48046118/1593077 https://stackoverflow.com/a/48046118/1593077 in essence, with Modern C++, it is relatively easy to just not produce garbage which needs to be collected :-)
- nashashmi 4y agoI used to use this resource back in 2008. It really cleared up lots of basic information on memory allocation and heap overflow.
- spaniard89277 4y agoAs 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.
- boppo1 4y agoI'm just a little further down the road than you are and the best course seems to be to learn a little C++ first because it will help inform why Rust works as it does. Then when you try Rust, if you hate it, you've still got C++.
- aliqot 4y agoWe'll be waiting for you on the Zig side :>
- galangalalgol 4y agoI like zig, the simplicity, and explicitness especially, the meta programming is really cool, but having now experienced the borrow-checker, I don't think I'd ever want to program without one. Rust isn't simple, and on occasion, it isn't sufficiently explicit for me, but it has a borrow-checker. For those reasons I'm very excited about Austral. The borrows, linear types, and the notion that anything that isn't explicit is wrong, all appeal to me.
- aliqot 4y agoNothing wrong with that, besides I think the people that only stick with one language are rare these days. It was more humor than anything, and I agree with you. I spent the last year or year and a half or so using Rust quite a bit more than I'd originally anticipated, and it's been cool in a sudoku way that tests my chin scratching abilities from time to time..
- Klonoar 4y agoI used to agree with this, but I would actually now suggest doing the inverse. Rust will beat you over the head with a way of thinking that carries nicely back to C++, and the tooling (Cargo, etc) is more comparable to what someone coming from another language ecosystem would know. Smaller things like Rust's decent support for functional programming seems to click with everyone I know who's dabbling from the JS world.
- einpoklum 4y agoThe website sometimes fudges things with somewhat-incorrect statements. Maybe it's a minor issue, but I noticed that it says, for example: > When an initializer is provided after an equals sign, this is called copy > initialization. Copy initialization was inherited from the C language. > > int width = 5; // copy initialization of value 5 into variable width > That's not quite right. Consider the following program: #include <iostream> struct A { A (const A& other) : x{other.x} { std::cout << "Copy ctor\n" ;} A (A&& other) : x{other.x} { std::cout << "Move ctor\n" ;} A() : x{0} { std::cout << "Default ctor\n" ;} A(int x_) : x{x_} { std::cout << "int ctor\n" ;} A& operator=(const A& other) { x = other.x; std::cout << "Copy assignment\n" ; return *this; } A& operator=(A&& other) { x = other.x; std::cout << "Move assignment\n" ; return *this; } int x; }; int main() { A a1 = A(5); } The constructor used here will not be the copy constructor. There will be just a single construction, of a1, and it will be the "int ctor", i.e. `A(int x_)`. See it on GodBolt : https://godbolt.org/z/eT8soWMxE https://godbolt.org/z/eT8soWMxE I don't know if this characterizes other parts of LearnCPP, haven't gone through it myself.
- thom 4y agoIf you really want to embrace the horror: https://www.youtube.com/watch?v=tH0Z2OvHAd8 https://www.youtube.com/watch?v=tH0Z2OvHAd8
- jdrek1 4y agoCopy initialization does not mean that the copy constructor is called. It is the correct term for an expression `T a = ...;`, which can often result in the copy constructor being called but does not have to. In this case it's mandatory copy elision from a prvalue, which leads to only one constructor being called.
- einpoklum 4y agoYou are absolutely correct. It turns out "copy initialization is the formal term used. It's kind of stupid IMHO, since it may not be initialization by copying or using a copy of anything, but: https://en.cppreference.com/w/cpp/language/copy_initialization https://en.cppreference.com/w/cpp/language/copy_initializati... So I half-take-back my comment.
- mh-cx 4y agoIf you already know a programming language and prefer a more concise tutorial you might also like this site: https://cplusplus.com/doc/tutorial/ https://cplusplus.com/doc/tutorial/ It's way less verbose and more to the point.
- toppy 4y agoOr in even more concise way here: https://learnxinyminutes.com/docs/c++/ https://learnxinyminutes.com/docs/c++/
- iLoveOncall 4y agoI haven't done any C++ since 2015ish but your link seems incredibly outdated. Sure you'll learn some C++ syntax, but you'll learn the C++ from 20 years ago, not the modern C++ with smart pointers and all that stuff which is basically turning it into a new language.
- boppo1 4y agoIs it a bad idea to learn from Stroustrup's 'Principles'?
- rramadass 4y agoNo, it is a great book to get started with C++ if you already know programming. Relevant: https://news.ycombinator.com/item?id=34233688 https://news.ycombinator.com/item?id=34233688
- zabzonk 4y agoas someone that has done a lot of commercial C++ teaching in his time, i would say that this is one to avoid for a beginning programmer. stroustrup is not, imho, one of the worlds great teachers, and i would not recommend C++ as a first programming language. more experienced programmers should go with TC++PL.
- boppo1 4y ago
- Karsteski 4y agoThis website gave me a strong start to my developer career!
- oeitho 4y agoThe cookie popup is truly annoying though. There's no way that this website is in any form of compliance with GDPR...
- nonethewiser 4y ago> There's no way that this website is in any form of compliance with GDPR... Doesnt seem like it needs to be
- oeitho 4y agoIn what way? GDPR applies regardless of what country the page is served from as long as it offers any product or service to EU inhabitants.
- deleted 4y ago[deleted]
- wirthjason 4y agoI wish there was a good place to learn “the other parts” of C++, the build systems, using static analyzers, testing, dependency management, etc. I’m thinking something like MIT’s “missing semester” course which teaches the boots on the ground part of software like how to use Git. https://missing.csail.mit.edu/ https://missing.csail.mit.edu/ Maybe these resources exist for C++ and I just never found them. I think a lot of “modern” languages get this right by including these things from the start. The experience is so much better.
- galangalalgol 4y agoFor the build system, I like: http://cliutils.gitlab.io/modern-cmake/ 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 submodules. That is a method still in use and even advocated for, but conan is often touted as the more modern way to do it. I've used it on some teams, and I'm undecided. I also have no good resources for it.
- geokon 4y agoIt'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 subdirectory. Variables such as the project-version-number get overwritten by the parent project and more dangerously the submodule can start to change variables in the overall project. 2: Dependencies will often reuse target names. For instance, libraries often have a target called `uninstall`. Because redeclaring a target in a different subdirectory is a no-no - CMake crashes Proper dependency management can be done directly through CMake without repeating yourself by using Hunter: https://hunter.readthedocs.io/ https://hunter.readthedocs.io/ This solved the diamond problem, gives you proper namespaces in CMake and with Polly you can have sane toolchain files (https://github.com/ruslo/polly https://github.com/ruslo/polly - but you can also just write them manually). Everything is built on CMake and Git (and git hashes). You get nice dependency build caches and forking dependencies is also trivial EDIT: The creator of Hunter has his own CMake Intro. I haven't gone through it while-learning, but it looks comprehensive and informative: https://cgold.readthedocs.io/en/latest/ https://cgold.readthedocs.io/en/latest/
- buro9 4y agoI loved the uni course that I did many many moons ago, and hey it's online and is complete enough that anyone can work against it: https://www.dcs.bbk.ac.uk/~roger/cpp/ https://www.dcs.bbk.ac.uk/~roger/cpp/
- iLoveOncall 4y agoThe problem with it being many many moons ago is that C++ has evolved so much since then that that course is now so outdated it's pretty much irrelevant.
- rr888 4y agoI used to be a C++ dev before moving to Java/Python. I'd like to go back but there seems to be few roles for people that aren't up to date experts. Is this the case? I'm not sure if the C++ shortage is like the COBOL shortage or a genuine active community that is growing.
- svorakang 4y agoThere are jobs if you know where to look. I regularly see ads searching for C++ developers. I'm in an automotive-heavy region in Northern Europe. C++ is widely used in HMIs, AD/ADAS, and general service development (diagnostic services, middleware). I also see the need of C++ developers in medtech and automation companies around here. The ads request some experience, but in practice they are happy to recruit what they can find. Some technologies change, so does C++, but not so long ago I landed a C++ gig for €80+/hr, although being more of a ANSI C90 expert, only used C++ occassionally (for test environments mostly), and being completely out of synch with the "latest" concepts of modern C++ and its tooling (as a reference, std::move was new to me; CMake was an annoying bigger sibling of Make). Customer was happy until that Chinese virus became a fad.
- samsquire 4y agoAt one point in time I thought C++ was too complicated since I was only familiar with Java, Javascript, Python. I feel I didn't understand the reason for the complexity. Then I began to study algorithms and then code generation at the assembly level. I've written very little assembly. But I want to generate assembly. This puts me in a difficult position. Today I think C++ is fascinating as a language because it has wide implementer support (cppfront, MSVC, GCC, clang) and it is well defined as a language. Someone can read the C++ standard documentation and implement a compiler for generating assembly for that AST. That's fascinating. Especially for a language as advanced as C++. I am also fascinated by metaprogramming and C++ templates. I needed to learn how to use C++ templates to use coroutines with threadpools in C++. Can't say I understand them completely but I understand how we need to provide specializations to the compiler so it knows how to generate code for different cases. I feel there's a missing orthogonal specification of computation that is cleanly compilable. As with Rust, with C++ there is many programs that are wrong by arrangement of tokens. It would be better if most arrangement of tokens are valid programs, due to semantics of the language not being subtle. https://stackoverflow.com/questions/74520133/how-can-i-pass-things-to-a-c20-coroutine-co-await-await-suspend-operator-funct https://stackoverflow.com/questions/74520133/how-can-i-pass-... I feel there's an omitted abstractions when it comes to code generation. The languages we use to represent computation in and relationships between things are rather low level. Mutable state is very difficult to reason about.
- gigatexal 4y agoC++ 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?
- zabzonk 4y agoa lot of c++ is there to support library writers worried about efficiency, rather than application programmers concerned with good-enough, maintainable code if. like most people, you are in the latter category, you can write pretty good code without worrying about all the bells & whistles of the later releases.
- aninteger 4y agoYou 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, and run as long as the dependencies haven't also changed too much (I'm looking at you Win32, X11, Motif). That gives you the time to migrate code bases over time without the fear of being left behind and unsupported. Even if, for some reason, you were writing C++98 for the last 30 years, it shouldn't be too difficult to make the jump to newer standards. The biggest change, in my opinion, is lambdas and move semantics, and it's not to difficult to apply those to an old code base (if you want to) and start modernizing it. Some people say C++20/23 is a new language but the fundamentals of C++ haven't changed too much and I'd say it's easier to learn C++23 coming from C++98 than it is to learn Rust coming from C++98.
- rramadass 4y ago>Some people say C++20/23 is a new language but the fundamentals of C++ haven't changed too much and I'd say it's easier to learn C++23 coming from C++98 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.
- avsteele 4y agoI am always grateful that people spent their time to create resources like this. This looks good and I would recommend it to someone who isn't a total newbie. I also find it very interesting to look at the pedagogy of these sites. In the case of this site, it starts with a lot of history and computing. This is common for books, but asking a new user to wade through so much preamble before any 'meat' is asking a lot. In the first part where code is shown/explained: https://www.learncpp.com/cpp-tutorial/statements-and-the-structure-of-a-program/ https://www.learncpp.com/cpp-tutorial/statements-and-the-str... is a lot of upfront jargon for a newbie to process. ('pre-processor directive') It does do a good job of showing how to set up visual studio. However these days, a htttp://repl.it is surely a MUCH easier way to get up and running. I wrote a very small ultra-beginner guide for a young relative to learn C. It gets right into what C code looks like, makes connections to the math they have seen in school, and tries to hold back terms until they are really needed (omitting details where needed) It isn't polished designed for widespread use, but I think for the truest beginners its better than other guides I found on the web. https://avsteele.com/C_Programming/ https://avsteele.com/C_Programming/
- bluedino 4y agoIs 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.
- tejohnso 4y ago> Bjarne's books might be great, but they aren't for anyone new to C++ and especially not anyone new to programming in general. I disagree. Not sure why PPP[1] wouldn't fit the bill. It's specifically geared to people who haven't programmed before. 1: https://stroustrup.com/programming.html https://stroustrup.com/programming.html
- bluedino 4y agoOne example is that he uses a header file called "std_lib_facilities". So right out of the gate it confuses people, it's not actually shown until a little later in the book, there's tons of questions on C++ forums and StackOverflow where people get stuck on it. It's just not a clear, step-by-step introduction.
- yeputons 4y agoAlthough I find the order of topics questionable, at least they talk about undefined behavior instead of saying blatantly wrong outdated stuff like "a read out of array range will just result in some garbage value being read". I've read some random pages and nothing stood out as blatantly wrong, which is already a high bar for a C++ course. 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.
- jack_pp 4y agoI learned C++ from scratch around 13-14 years ago through this website and with help from #freenode's C++ channel and I'm grateful for both.
- synergy20 4y agoThis is an excellent website to learn modern c++. I still wish it had better navigation design, like a side bar for easy access to the ToC, or a drop-down menu for the same thing. I have to use the back|forward to do that. cplusplus.com is out of date, but it has the simplest and easiest web interface to me comparing to either learncpp.com or cppreference.com, super easy and simple to navigate: https://cplusplus.com/doc/tutorial/ https://cplusplus.com/doc/tutorial/
- a-user-you-like 4y agoThis tutorial does not include modules, the best feature in C++ in a while. Is there a modern c++ intro or tutorial that includes CMake, modules, concepts, etc?
- notRobot 4y agoI used this website to learn C++ a many years ago and it made it very easy! Very thankful for this resource, and others like it.