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

In what world is C++ harder to learn than Rust?


This world - the one you exist in right now. I say that as someone that wrote C++ for 10 years before moving to Rust.

Rust was by far easier.

That said - that’s an extremely biased statement and I recognize that. I think it was largely the compiler that helped make it easier.


I think have 10 more years of programming experience probably makes it easier to pick up a new language


I'd argue that your parent is right. In the superficial sense, of learn the syntax and can spit out code.

That said code in C++ would just vomit cryptic messages about templates and SEGFAULT nearly all the time.

What I'm trying to say skill floor - minimum skill/time needed to learn something to do it however in Rust is higher than C++. Although not in the sense of you must be this smart to enter, but you need this much time to learn it. If I can learn it, and I'm a mediocre programmer it's not an issue of skill.

That said skill ceiling - skill needed to do it efficiently and without error is much higher in C++ than in Rust.


Speaking as someone for whom programming is only ancillary to my job and who previously use python as my primary language, I wouldn't touch C/C++ with a 10-foot pole simply because I don't trust my own abilities to not screw it up and don't have the time to put into learning them to a level where I know I'm not.

Things that Rust does that makes things easy for me as a less-experienced non-systems programmer:

- very good documentation and compiler errors

- cargo makes dependency management and distribution a breeze (big plus over python)

- footguns are easily recognizable and avoided (unsafe)

- strong typing allows me to express more invariants in the type system which makes my code easier to reason about (another big plus over python)

The borrow checker can be an impediment at times and I'm probably leaving some performance at the door by generally avoiding references in data structures. I've found that this is less of a problem over time. It can also be way more verbose. But I have way more confidence that things will work at the end of the day, which makes it worthwhile for me, even if on the surface it is take longer and be harder to write than python.


Rust isn't actually that complicated and more importantly, most of it makes sense. I don't feel the same way about C++.


I feel that C++ makes sense.

It doesn't actually make for a good argument.

C++ makes more sense to me than Go or PHP. And probably Python.


For the vast majority of programmers who don't know either. learning how to write correct Rust is easier than learning how to write correct C++.


Cargo is the number one feature of Rust that makes it easier for a newbie to use. New users of C++ struggle the most with building and linking projects together. Cargo makes that newbie proof. Source: I teach C++ and Rust to new programmers, and they almost universally get further, faster with Rust than C++.


Meson has improved the build situation in C++ significantly.


Kind of, but it also exacerbates one of the problems with C++ build systems which is there are so many and none of them are the build system. On one hand this is desirable from the perspective that it avoids monoculture. But it's a bad thing from the perspective of a new programmer in that it causes a lot of confusion and a form of "choice paralysis", where programmers become overwhelmed by options and choose nothing out of a fear of making the wrong choice.


I concede that the Rust tooling is miles ahead no question.


Time to write a program that compiles and seems to do what it does: Takes ages longer in Rust, unless you're experienced.

Time to be reasonably sure your multi-threaded code won't crash randomly: Takes ages longer in C++, even if you're experienced.


Rust exists in a way to point out that C++ is waaaaaaaayyyyyy harder than it looks.


There is C++ code that 99.999% of people that list C++ in their resume are unable to explain.

You can get comfortable with some idioms of C++, that's fine. Can you understand what any valid C++ code means? No. Such person does not exist, not even Bjarne.


You can say the same of any language. Deobfuscation is a hard problem. Only code meant to be reasonably understood is a valid comparison.


I don't mean obfuscation, I mean features of the language and their interactions.

C++ is a mine field. You need to learn where all the mines are and spend your day carefully walking around them.


Sure, but that's not what you said. If what you meant is that there is no one that can read anh more or less reasonably written code in C++, then I believe you'd be wrong.


I was scared of C++ but Rust offered me some confidence to start.

Some languages (like C) are easy but using them is hard.




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

Search: