News for hackers. Stuff that matters.
Re:Ask HN: Learn C++11 or Rust in 2022? by junon on Monday May 02, 2022 @06:47AM (#31233472)
C++20 is going to be much friendlier. If you're new to C-like languages though, perhaps start with C and work up to C++. The foundations are important to understand, and you'll appreciate why RAII is important.

EDIT: Ah yes, the "crawww C is unsafe, use rust crawww!" downvote crowd is out in full force today.

Re:Ask HN: Learn C++11 or Rust in 2022? by ncmncm on Monday May 02, 2022 @04:10PM (#31240247)
Starting with C is the worst way to learn C++. You start out with bad habits you then have to unlearn.

Unlearning bad C habits is hard because the language accommodates them for as long as you continue to cling to them. You need to consciously decide you will use the new, better way. Once you have done each once, there will be no temptation to backslide.

Re:Ask HN: Learn C++11 or Rust in 2022? by junon on Monday May 02, 2022 @08:22PM (#31242823)
Fully disagree. Understanding pointer semantics is a pre-requisite for understanding RAII.
Re:Ask HN: Learn C++11 or Rust in 2022? by pjmlp on Tuesday May 03, 2022 @02:09AM (#31245228)
I know C++ since 1993, I am quite curious how pointer semantics have anything to do with RAII.
Re:Ask HN: Learn C++11 or Rust in 2022? by junon on Tuesday May 03, 2022 @06:04AM (#31246509)
Because smart pointers are still pointers under the hood. You're forgetting the time before you know what pointers were - people coming from higher level languages don't immediately grok the concept. By teaching them automatic memory management patterns like we use in C++ without teaching them why you need such things, they'll never fully understand the code they're writing.

It's like the "I know React but not JavaScript" crowd all over again.

Re:Ask HN: Learn C++11 or Rust in 2022? by pjmlp on Tuesday May 03, 2022 @06:22AM (#31246626)
If you think RAII is about smart pointers, you really don't understand it.

RAII is about resource management, regardless of where those resources live on.

Heap allocated, OS handles, indexes on a fixed sized buffer, network sockets, ...

Re:Ask HN: Learn C++11 or Rust in 2022? by junon on Wednesday May 04, 2022 @02:21PM (#31264022)
Yes, I'm aware, thanks. Lifetimes, ownership, etc. are all overlaps of RAII and associated concepts.

Again, what did being pedantic prove here? You clearly understood what I meant.

Re:Ask HN: Learn C++11 or Rust in 2022? by ncmncm on Tuesday May 03, 2022 @02:45AM (#31245427)
Yeah, doesn't make sense. Pointers are less useful in C++, because we have better things now.
Re:Ask HN: Learn C++11 or Rust in 2022? by junon on Tuesday May 03, 2022 @06:02AM (#31246499)
Of course we do. You still need to know how pointers work to use RAII effectively, though.
Re:Ask HN: Learn C++11 or Rust in 2022? by pjmlp on Tuesday May 03, 2022 @06:23AM (#31246635)
Not at all, because RAII is about constructors/destructors, and not at all about pointers.

Heap allocated data is one special case of OS resources that can be managed by constructor/destructor pairs.

Re:Ask HN: Learn C++11 or Rust in 2022? by junon on Wednesday May 04, 2022 @02:20PM (#31264013)
What did being pedantic prove here?
Re:Ask HN: Learn C++11 or Rust in 2022? by ncmncm on Thursday May 05, 2022 @05:22PM (#31278558)
The thread started with you insisting a C-level conception of pointers is essential to coding C++, which turns out to be false.

Learning C first is a very bad way to learn C++. One can pick up pointers later, and asm blocks after that.

Re:Ask HN: Learn C++11 or Rust in 2022? by kretaceous on Monday May 02, 2022 @07:26AM (#31233753)
The downvotes are probably because you said "start with C" while the OP has clearly stated they have experience with C and use it in their day job.

P.S. I haven't downvoted you.

Re:Ask HN: Learn C++11 or Rust in 2022? by junon on Monday May 02, 2022 @07:35AM (#31233795)
Oh I missed that line, thanks. The advice still stands, however - perhaps not to OP. But I think it's even more reason to learn C++20 in OP's case.
Re:Ask HN: Learn C++11 or Rust in 2022? by sharedptr on Monday May 02, 2022 @07:31AM (#31233776)
I use C at work and in the past for hobby projects C++ (11) to do some modifications to Quake 3.

Is C++20 support in compilers already? MSVC/GCC/Clang

Re:Ask HN: Learn C++11 or Rust in 2022? by gkuan on Monday May 02, 2022 @10:33PM (#31243769)
MSVC has a good amount of C++20 support now https://en.cppreference.com/w/cpp/compiler_support#cpp20.
Re:Ask HN: Learn C++11 or Rust in 2022? by junon on Monday May 02, 2022 @07:34AM (#31233791)
Not fully, but the important pieces yes. Clang and GCC in particular, not sure about MSVC as I don't use it.