HN user

cppishellacool

-6 karma
Posts0
Comments3
View on HN
No posts found.

Don't get me wrong I respect Rust core team as theorists and think rust is an important research project.

But in C++ if you have a const member function F() then F() can only change member variables that use the "mutable" key word.

If you default to all methods are const you have much much safer C++. As safe as rust? not probably but combined with liftimes proposal and static analysis rules we have a language good engineers can sufficiently work with.

    struct Foo 
    {
         mutable auto a = 4;
         auto increment() const -> void 
         {
              this->++a;
         }
    };
If we train engineers to use const member functions, then the programmer is forced to think about state and mutation.

As C++98 PTSD begins to fade and C++17 becomes the cultural mental image of the language, the argument for switching to rust will become less and less compelling.

Eventually, the only "advantage" will be ML influenced syntax.

The reason is there are only three languages that can easily call into C++ code. Objective-C (swift by proxy), D, and of course C++.

Why rust didn't prioritize compatibility with C++ like C++ did with C boggles my mind. Why do you think C++ became so popular? Near perfect C compatibility (until recently) is literally the only reason. Instead of focusing on pragmatisim Rust focused on language purity.

At what cost?

Did you watch the video?

Curious why you think using const functions doesn't prevent data races after watching

at 29:00 he says the C++ standard guarantees const member functions are data race free.

Do you want C++ compiler to also prevent data races? Then use const functions by default, seriously.

http://youtu.be/Y1KOuFYtTF4 (starts at 29:00)

C++ template meta programming language is such a powerful and expressive tool for writing libraries and safe abstraction. Imagine if all the effort of 8 years of Rust team went into a modern C++ safety library.

Such a library would have been more useful contribution and more people would have benefited.