Hacker News new | ask | show | jobs
by jolux 1649 days ago
> Rust is already as complicated to learn and use effectively as C++

I see a lot of claims to this effect but having tried to learn both I found Rust much easier. It's also safe by default, which C++ isn't. How exactly do you think it's equally complicated?

1 comments

We all know that Rust is "safe by default". That is part of what makes it complicated.

Most of the complexity of C++ comes from its long history, with new features layered on old, extra junk you have to say to get the new stuff, and old stuff to stay clear of. E.g., constructors should be explicit, and lots of things should be const, and you have to call std::move() to pass a value that way, and implicit conversions can happen accidentally. But actually using it, sticking to the modern bits, doesn't depend on much in the way of new concepts. Writing libraries for general use depends on deep lore, but that doesn't leak out to users of the libraries, who just get libraries that can do more for them.

In Rust, you need to learn a whole new regime to do even basic things. And, you need to learn workarounds for what C++ does but Rust doesn't, yet. There are literally thousands of times as many people who can answer questions about C++ than about Rust, so mysteries are shallower.

> In Rust, you need to learn a whole new regime to do even basic things.

Sure, but the same can be said of any language that’s significantly different from C++ (OCaml, or Erlang for example). That doesn’t mean they’re as complicated.

Rust syntax and semantics are basically ML syntax with curly braces and semicolons on top. Having already learned OCaml by the time I picked up Rust, all I needed to internalize was the borrow checker, which is simpler to appease than it first appears.

> There are literally thousands of times as many people who can answer questions about C++ than about Rust, so mysteries are shallower.

Again, this is an argument about adoption more than about the intrinsic complexity of the language. I agree it’s harder to find answers, but that’s always going to be true when the languages you’re comparing to are C/C++/Python/Java/JavaScript.

> But actually using it, sticking to the modern bits, doesn't depend on much in the way of new concepts.

I disagree that smart pointers and move semantics aren’t new concepts. But more importantly this is basically an admission that C++ is vastly more complicated. It doesn’t really matter that there are subsets of C++ that are simpler, because to be able to understand code written by other people, and old code, you will need to understand these bits. The same is not true of Rust.

The overwhelming majority of what you need to learn to understand old code is what was built out of the old code. Language complexity there is a rounding error. So, the relevant complexity is what you need to understand to write new code.

Detailed comparisons will be meaningless. It suffices that they are comparable, of similar order. Somebody coming from Haskell or an ML will have a completely different experience than somebody coming from JS or Python.

Move semantics and smart pointers are about the same in C++ and Rust, so do not count in a comparison.

I learned Rust a few years ago, but cannot follow Rust code examples published today. It has become markedly more complex in a short time.

For Rust not to fizzle, literally thousands of programmers wholly unacquainted with it will need to adopt it for each current user. None of the former come bought into any of what current users have chosen to endure. To get those programmers on board, things will need to happen that most current users do not perceive as necessary, many of which they would absolutely revile, and many others they do not consider worth enough effort.

Overcoming resistance to necessary change from current users will be much, much harder than getting the new users on board after changes. Getting enough new users on board without those changes is probably impossible.

> I learned Rust a few years ago, but cannot follow Rust code examples published today. It has become markedly more complex in a short time.

Interesting. I suspect this is where our experiences differ the most, I started learning Rust around when it came out and have felt it only get simpler and more consistent over time. I do not see many major differences between Rust written now and Rust written then. The biggest one is async, which is definitely a big difference.