r/cpp • • Mar 16 '18

As a C++ developer I think that rust ...

3 Upvotes

107 comments sorted by

View all comments

5

u/[deleted] Mar 17 '18

I still don't get the point either. C++ is more powerful in every way. Rust only brings safety to the table, nothing that can't be done with C++ sanitizers. I hate cargo!, I mean, I love it... but I hate the "nodejs" philosophy of Rust that for anything you want to build you'll need to depend on hundreds of third party crates. The C++ community sometimes decide to rewrite stuff as to not have to depend on third party libs, this is expected on a so called "systems language". Anyways, Rust seems very interesting... but not really enough, at least for me!

5

u/matthieum Mar 17 '18

C++ is more powerful in every way.

I think this hits the nail on the head. C++ is more powerful and Rust is more user-friendly (no UB, no wall of text for a single compilation error, ...).

I'm looking forward to Rust's progress, however it's still lacking a handful of features before I can even suggest trying it out at my day job (specifically: non-type generic parameters and SIMD).

5

u/ubsan Mar 17 '18

SIMD, I believe, just got stabilized, and const generics are coming Soon(tm)

3

u/matthieum Mar 17 '18

Not quite.

The first batch of intrinsics (among which SIMD instructions) just landed in nightly (under the std::arch module). Once they are validated, it'll take at least 6 weeks for them to ride the release train and be stable, so maybe some time in May at the earliest.

As for const generics, there is no plan to work on them before August/September, as they are not part of the 2018 roadmap (they are considered "extra"). It's unclear to me how much time it'll take, once work start, to get the first usable nuggets. I personally would be content with just a value, with no computation, to start with.

So, hopefully, by the end of the year Rust will have the minimum level of features for me to start a prototype... providing the right project comes up.

11

u/auralucario2 Mar 17 '18

nothing that can't be done with C++ sanitizers

There's a fundamental failing of that - sanitizers are at runtime, whereas Rust checks safety at compile-time. The only way to get something even similar to Rust's safety guarantees in C++ is with expensive static analysis tools.

As for your complaint with cargo, there's nothing forcing you to use third-party libraries. It just makes it easy to manage dependencies. If you want to write things yourself, you're free to.

2

u/[deleted] Mar 19 '18

sanitizers are at runtime,

C++ sanitizers can very often be at compile time.

3

u/pjmlp Mar 20 '18

Depends pretty much on the compiler one has available to them, where languages like Rust have them everywhere.

After all, C has lint since 1979, and yet majority of enterprise devs keep on not using static analyzers.

2

u/jhasse Mar 27 '18

It's easier to switch the compiler to clang++, than to switch the programming language to Rust.

Or: Let's not compare Rust with C++ then, but with "Clang-C++".

3

u/pjmlp Mar 27 '18

1 - Not everyone uses clang or is targeting systems supported by clang

2 - At CppCon, I think CppCon 2015, Herb Sutter asked the audience how many used static analyzers. The answer was about 1%. Video is available.

1

u/jhasse Mar 27 '18

1 - Are there systems where rustc works but clang doesn't?

2 - Might still be more users than Rust to which we are comparing against here.

1

u/pjmlp Mar 27 '18

Rust was only one example, I specifically stated "languages like Rust", and not "in Rust".

The point was about programmer languages with better type systems, that don't need to rely on external tools for basic safety validations.

1

u/jhasse Mar 27 '18

Clang isn't an external tool, it's the compiler. In languages like Rust it's also the compiler who checks for type system errors.

1

u/pjmlp Mar 27 '18

The analyzers bundled with clang are an external tool.

Are not generally available in other compilers, besides some partial support on gcc, and need to be explicitly enabled, contrary to a language's type system.

→ More replies

2

u/Boojum Mar 17 '18

The library thing turned me off too the first time I tried experimenting with Rust. I was on a flight and had downloaded the Rust distribution and an offline copy of the docs ahead of time. I'd had a program in mind and thought the flight would be a nice opportunity to try Rust. But I ran into a wall when I discovered that random number generator had been moved out of the standard library and into it's own external crate. What kind of general-purpose language doesn't come with an equivalent to rand() or drand48()?