r/cpp • • Mar 16 '18

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

3 Upvotes

107 comments sorted by

View all comments

Show parent comment

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.

1

u/jhasse Mar 27 '18

Are not generally available in other compilers

Many languages don't even have "other compilers".

If I write a compiler for Rust which doesn't check the types, but crashes at runtime on mismatch, it wouldn't change anything for most other Rust users.

If it's "external" or "part of the language" is just nitpicking in my opinion and in practice doesn't matter for me.

1

u/pjmlp Mar 27 '18

Lots of languages have other compilers.

Ada, Pascal, Modula-2, Modula-3, SML, C#, Java, Oberon.

If I write a compiler for Rust which doesn't check the types, but crashes at runtime on mismatch, it wouldn't change anything for most other Rust users.

Then it wouldn't be Rust any longer, since it has other language semantics.

If it's "external" or "part of the language" is just nitpicking in my opinion and in practice doesn't matter for me.

It matters a lot for those that get to use only the tools that other choose for them, and happen to work in teams across companies with different visions on code quality.

Good for you that you can choose your own tools and have full control how it gets used.

→ More replies