Re:Rust can be difficult to learn and frustrating, but it's ...
by zlynx on Tuesday October 23, 2018 @02:42AM
(#18281216)
Actual problems like:
- sending dangling references to thread functions. Lambdas with automatic reference capture creating threads from inside functions that exit are terrible here.
- returning a pointer or reference to an invalidated iterator
- returning a pointer or reference to the contents of a temporary
Yes indeed, C++ programmers never actually have these problems, they are purely imaginary. /sarc
Re:Rust can be difficult to learn and frustrating, but it's ...
by MarkovUnchained on Tuesday October 23, 2018 @03:46AM
(#18281497)
Yeah, I don't think there is a professional C++ developer who has any of these problems. It's called static analysis... welcome to a decade ago. Why on earth would an organisation move their codebase to Rust when they can just run Clang? Which they should be doing anyway.....
Re:Rust can be difficult to learn and frustrating, but it's ...
by unrealhoang on Tuesday October 23, 2018 @04:21AM
(#18281673)
Unfortunately a lot of browser's CVEs tell a different story.
> Why on earth would an organisation move their codebase to Rust when they can just run Clang? Well, you can ask C++ professional at Mozilla.
Re:Rust can be difficult to learn and frustrating, but it's ...
by mbrubeck on Wednesday October 24, 2018 @10:15AM
(#18292573)
In my experience, even modern C++ code and cutting-edge static analyzers still have a lot more holes than Rust when it comes to borrowing and lifetimes. Unsound code like this (which in Rust is the most basic form of lifetime error) still manages to slip past the CppCoreGuidelines static analyzer that Microsoft has been developing for years, which includes "lifetime checking":
#include <iostream>
#include <string>
#include <string_view>
int main() {
std::string s = "Hellooooooooooooooo ";
std::string_view sv = s + "World\n";
std::cout << sv;
}
C++ types simply don't contain the information needed to do Rust-style lifetime analysis. C++ static analyzers have to hard-code this knowledge themselves about every library type (will never be complete for every library in existence), use heuristics (will always have some false positives and false negatives), or rely on whole-program analysis of function bodies rather than signatures/types (runs into incomputability problems, and validity ends up depending on things the analyzer can't know, like which version of a dynamic librariy ends up linked at run time).
Re:Rust can be difficult to learn and frustrating, but it's ...
by ilovecaching on Tuesday October 23, 2018 @12:03AM
(#18280637)
Rust is based on ADTs, typeclasses, and type parameters. C++s toolkit for abstraction is templates and OOP. They're completely different, and it sounds like you're just trolling anyway.
Re:Rust can be difficult to learn and frustrating, but it's ...
by MarkovUnchained on Tuesday October 23, 2018 @01:26AM
(#18280911)
C++ has ADTs from C++17 and will have typeclasses from C++20. Templates with type traits are effectively a superclass of type parameters anyway.
Re:Rust can be difficult to learn and frustrating, but it's ...
by Rusky on Tuesday October 23, 2018 @08:04PM
(#18288569)
C++'s ADTs are std::variant, which is horrific.
C++'s type classes are concepts, which are hardly more than syntactic sugar over SFINAE.
Neither can really compare to Rust's enums or traits.
Given that Rust doesn't actually solve any of the actual problems C++ programmers have, there is no motivation to switch.