Live data from Hacker News

LearnCPP: Website devoted to teaching you how to program in C++

learncpp.com

121–130 of 145 posts

Re: LearnCPP: Website devoted to teaching you how to program in C++

#122
post #95

Earlier quoted context omitted.

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++…

I'm already fairly deep into python, kinda knowledgeable in JS to make some minor stuff and currently I'm practicing a lot with git. After than it comes Java (i'm following a self-paced bootcamp path). 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…

The reason I mentioned c# is because it feels like "if Java adopted new features at a decent rate" and these days pretty much all of it is MIT licensed. Coming from Java to c#, I found it much more ergonomic and productive mostly due to less boilerplate and more concise syntax sugar. There are several ways to compile it to native if you need to and it has great c/c++ ffi support, although if you're doing a lot with microcontrollers you'll end up writing c/c++ eventually. Luckily a lot of big langs (c/c++/c#/Java) have similar syntax and concepts since they all sort of started from c.

I'd suggest waiting until you learn some java/c# before starting on c/c++, or instead starting at old school c (k&r c) or arduino c++. Modern c++ is a beast to learn.

Re: LearnCPP: Website devoted to teaching you how to program in C++

#123

Is 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.

I learned from this website. I would recommend it to people who already know how to program another language.

Re: LearnCPP: Website devoted to teaching you how to program in C++

#124

This 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?

Are modules production ready yet on all platforms?

Do they work at all on any platform? They are much less than half-baked on GCC or clang and MSVC has incomplete support.

Re: LearnCPP: Website devoted to teaching you how to program in C++

#125
post #30
post #21

If you already know a programming language and prefer a more concise tutorial you might also like this site: https://cplusplus.com/doc/tutorial/ It's way less verbose and more to the point.

You should absolutely not use or recommend that site. It's stuck on incomplete C++14 at best and also contains some pretty bad code. learncpp.com is a much better tutorial and cppreference.com is a much better reference. The only thing cplusplus.com is good at is polluting search results.

cppreference has a steep learning curve with how information dense it looks, but once you’re up to speed you can move a lot faster with the standard library. I find it’s the site I always have a tab open on.

Re: LearnCPP: Website devoted to teaching you how to program in C++

#126
post #30
post #21

If you already know a programming language and prefer a more concise tutorial you might also like this site: https://cplusplus.com/doc/tutorial/ It's way less verbose and more to the point.

You should absolutely not use or recommend that site. It's stuck on incomplete C++14 at best and also contains some pretty bad code. learncpp.com is a much better tutorial and cppreference.com is a much better reference. The only thing cplusplus.com is good at is polluting search results.

Back when I was a software engineer, I used to constantly hear how bad cplusplus was. Yet, in spite of this, I'd fairly often find myself using it because the results were just so much easier to parse.

Just as an example, cppreference doesn't have a page dedicated to std::string (when you search for it on Google, it tkes you to std::basic_string) whereas cplusplus does.

Even comparing the two pages, cplusplus immediately gets to the point that std::string is just a std::basic_string, whereas cppreference has three paragraphs of technical minutiae before it finally points out what std::string is.

Even though cplusplus is out of date and incomplete, it's still often more useful than cppreference when you're trying to get your head around STL for the first time.

Re: LearnCPP: Website devoted to teaching you how to program in C++

#127
post #23

Earlier quoted context omitted.

I've been getting back into C++ after an extremely long hiatus and I've been impressed by how thoroughly modern it is. The worst crime you're likely to commit these days is accidentally invoking a copy constructor more often than you want to, and even then, not actually creating leaks. In fact, the most striking thing coming from a language like Java or C# isn't memory management at all, is how utterly non-OO C++ act…

Even when C++ was created, object-orientation was not a goal, but rather a means to an end. Yes, that was a significant feature, and the original name was "C with objects", but even then it was only part of the bigger picture, and that part got smaller over time. The next big step away from an OO-orientation of the language (no, that's not a typo) was when the STL was adopted into the standard library - with its iter…

C with Classes, not C with Objects, was the original name of what became C++.

Re: LearnCPP: Website devoted to teaching you how to program in C++

#128
post #23

Earlier quoted context omitted.

For 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 and my particular answer: 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 :-)

I've been getting back into C++ after an extremely long hiatus and I've been impressed by how thoroughly modern it is. The worst crime you're likely to commit these days is accidentally invoking a copy constructor more often than you want to, and even then, not actually creating leaks. In fact, the most striking thing coming from a language like Java or C# isn't memory management at all, is how utterly non-OO C++ act…

> The worst crime you're likely to commit these days is accidentally invoking a copy constructor more often than you want to, and even then, not actually creating leaks.

As much as I like modern C++, use after free is still way too easy to commit. But if you stick to value types and mostly don't store references/non-owning raw pointers, then it's OK.

Re: LearnCPP: Website devoted to teaching you how to program in C++

#129

After 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.

This 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.

Re: LearnCPP: Website devoted to teaching you how to program in C++

#130

As 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.

Please do not start with either C++ or C. They are horrible, horrible languages to learn as a beginner. Not because of bad tooling, incompatible compilers, tons of features, or even manual memory management and pointers, no. 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 ex…

Tooling did help this situation somewhat, but it is not very discoverable.

If a beginner started off with a clang or gcc toolchain, then I would immediately suggest the following command line options for the compiler (the exact standard version does not matter, just stick to one):

  -std=c++20 -pedantic-errors -Wall -Wextra -fsanitize=address,undefined
And there are a few toolchain specific macros worth adding.

This would help with most undefined behaviors encountered as a beginner, although the sanitizers don't catch everything.

Post reply on HN