Hacker News new | ask | show | jobs
by vbtemp 1368 days ago
> Either Rust is significantly better than C++ in his view

Do you remember the Paul Graham essay on the Blub programming language? (http://www.paulgraham.com/avg.html)

C++ is kind of like the Blub language. If you know C++ well enough, you can do anything you need to do, so something like Rust just seems too esoteric and weird and pretentious.

Fortunately, I spent many years using Rust recently (coming from primarily a C background) and when I'm on a project using C++, it just feels too weird and rudimentary and horribly over-complicated.

To end with a quote from the PG article:

_But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well. Blub is good enough for him, because he thinks in Blub._

2 comments

Interesting. In my experience, seasoned C++ programmers grasp the advantages of Rust very quickly. Not all of them are convinced that the advantages outweigh the practical problems, but they don't deny the existence of the advantages.

I would have said C is firmly a Blub, though.

Paul Graham favored Lisp, which gives programmers limitless freedom to implement whatever they want, Rust is the opposite side of that.

C++ is full of footguns and it is easy to make mistakes, but it is also one of the most powerful and expressive languages out there.

Rust gives you data race freedom and memory safety and a myriad of other great correctness preserving qualities like Options, `unsafe {` and a high quality type system.

Not to mention that it is blazingly fast.

Rust is literally designed to constrain what you can do much more tightly than C(++)/Python/Lisp. That's basically the opposite of the common definition of "freedom".

You can argue that what you give up in exchange for this freedom is more valuable, but don't twist the definitions of words.

> That's basically the opposite of the common definition of "freedom".

It depends on which "common definition" you're working from. To make an analogy, both GPL advocates and MIT/BSD license advocates argue that their conception of freedom is "more free."

Rust is closer to the GPL here. By limiting certain things that you can do, you are free to do things that would be harder if you're allowed to do anything. The canonical example here is Stylo; the project was attempted with C++ multiple times, but was too buggy. But Rust's restrictions allowed the Rust version to succeed. You can argue it both ways: Rust limits certain kinds of code patterns (outside of unsafe, of course...) but that may enable you to do things that were too hard to do when there were no safeguards.

(A more generalized version of this debate is the distinction between "positive liberty" and "negative liberty," this debate transcends software.)

Yeah Rust forces your program to use certain patterns. But in return, other users can assume those patterns exist. In result, Rust is one of the best programming languages to do refactorings in that exist. You are less free to write code that can be refactored badly, you are more free to do refactors. A sensible trade in my opinion.
Rust is literally designed with the `unsafe` keyword that tells the compiler: "hey you won't be to prove this is correct, but I'm going to do it anyway, don't check it".

The restrictions merely apply to provably correct code.

I'm not sure how telling the compiler to disable the safety features so you can do your thing is unbearably limiting.

Indeed, but in a similar manner, lisp restricts you out of the low level architecture, and you operate in a higher free-er plane where most ideas will work fine. Rust constraints are mostly liberating because you're safe to assume things will work.
Yes, Rust is much easier to write and faster to learn than C++. This makes Rust better for many cases, but you can't really say it is more powerful.

C++ templates are hard to learn and understand, but they are one of the most powerful constructs we have in any programming language, I miss them when I work in other languages.

This is a good point. Rust is better than C++ in many ways but when it comes to templates and compile time optimizations then its flipped and C++ is much better. The Rust trait system also feels pretty limited too.

Though as far as compile time templates go I think Nim templates generally meets or exceeds C++ templates in most areas. But I've become addicted to compile time type ducking, which is antithetical to Rust's vision of programming.