News for hackers. Stuff that matters.
Re:Why I love Rust by jbandela1 on Friday January 08, 2016 @09:19AM (#10864966)
I think that is a great answer. I actually see some parallels between the relationship of Rust/C++ to Scala/Java. Both basically use the backend of the established language and provide an 'improved' language on top of it. Scala uses the JVM, and Rust uses LLVM.

What is interesting is that with the release of Java 8, a lot of Scala early adopters and cutting back their investment in Scala in favor of Java (for exampled LinkedIn). This is despite the fact that Scala is widely used in production, has a killer app in Spark, and allows pretty seamless use of the Java library.

Now compare this to Rust. Rust also provides an 'improved' language in the same space as C++ utilizing LLVM. However, what is interesting is the nature of the improvements. The biggest feature of Rust is the memory safety. However, the memory safety is not a productivity improvement as more of a safety improvement. Unlike garbage collection where you just do not have to think about memory allocation issues, Rust forces you to think about ownership and mutability. That same exact thinking will allow you to pretty much get the same memory safety in C++ using unique_ptr and shared_ptr and const. The difference is that the compiler makes you think about it in Rust. Much like Scala inspired the adoption of features for Java, you can see C++ adopting pretty much the borrow checker as a tool - see Herb Sutter's talk at CppCon 2015 - https://www.youtube.com/watch?v=hEx5DNLWGgA .

As the experience with Scala shows, the adopted features of the established language do not have to perfectly match the 'improved' language to convince people to migrate back to the established language. The adopted features just have to be in the ballpark. I think the new C++ tooling will be in the ballpark in much the same way that Java 8 is in the same ballpark as Scala and remove much of the impetus for moving to Rust from C++.

In addition, Rust is not as well positioned as Scala. Scala is actually deployed in production and has a killer application. Rust has no major production deployments of which I am aware and no killer application (the equivalent of Spark). In addition, while Rust can interface with C libraries, Rust cannot interface with C++ libraries unlike Scala which can interoperate with the Java standard library.

Rust has some brilliant aspects just like Scala has some brilliant aspects. However, C++ (like Java) is not sitting still but has been incorporating the best ideas. In addition, when people choose a system language, they are inherently conservative because the system they are creating will typically be long lived and mission critical. If you are writing something that you hope will power your company for the next 20 years, do you want to go with a language created and driven by Mozilla with no major use in production, or with the language that powers Google, Microsoft, Apple, and Facebook?

Here is what I recommend. Learn C++11/14/17. Learn Haskell to really open your mind to what is possible. Learn Rust to learn about the borrow checker. Then apply what you have learned to make yourself a better C++ programmer. Some of the best, most insightful C++ programmers I know are people who are actually well-versed in other languages, especially functional programming languages.

Re:Why I love Rust by danieldk on Friday January 08, 2016 @09:45AM (#10865151)
I think the new C++ tooling will be in the ballpark in much the same way that Java 8 is in the same ballpark as Scala and remove much of the impetus for moving to Rust from C++.

I think that you extrapolate from an incorrect analogy. Java is a relatively simple language (except the mess introduced by generics through type erasure), that is mostly understood by regular practitioners. Java suffered far more from the lack of modern language features than technical debt. Consequently, it benefitted from language extensions tried first in Pizza/Scala, etc.

C++, on the other hand, is a very complex language as a result of inheriting C, the lack of deprecation of misfeatures for compatibility, and perhaps questionable design choices. C++ suffers not so much the lack of language features (though support for real algebraic data types and modules would be nice), but from complexity. Complexity of the language can only be reduced by breaking compatibility.

Re:Why I love Rust by fiedzia on Friday January 08, 2016 @10:07AM (#10865328)
"However, the memory safety is not a productivity improvement as more of a safety improvement."

I disagree. It frees you from chasing safety bugs and allows to invest more time in the features and that's clearly productivity win. For example rust does not suffer from compiler bugs as much as compilers written in C/C++ used to. Chrome and firefox developers spend a lot of time fixing buffer overflows and are likely to do this for many years to come. They certainly could do something more productive for everyone's benefit.

Re:Why I love Rust by pcwalton on Friday January 08, 2016 @11:46AM (#10866180)
> you can see C++ adopting pretty much the borrow checker as a tool - see Herb Sutter's talk at CppCon 2015 - https://www.youtube.com/watch?v=hEx5DNLWGgA .

I have a lot of questions about this tool, both in terms of soundness/expressivity (how do you deal with shared_ptr and similar things if your goal is to statically guarantee no-alias on function entry) and in terms of practicality (the massive subsetting it requires basically makes ISO Core C++ an entirely new language).

Also, Herb's claims about the ISO Core C++ lifetime profile requiring fewer annotations than Rust were incorrect.

I gave basically this exact answer last time you posted a variant of this same comment on the last Rust thread.

Re:Why I love Rust by kod on Friday January 08, 2016 @11:49AM (#10866202)
Anyone who's actually used Rust, C++, Scala, and Java knows that Rust and Scala involve considerably less suffering than their counterparts. The "adopted features" don't change the fundamental problems.

Java 8 lambdas are fundamentally broken due to checked exceptions, and the likelihood that checked exceptions are going to be removed from the language is essentially nil.

Likewise, Rust error messages are already better than C++ compiler error messages, and the nature of C++ template expansion makes that unlikely to change.

Learn what you want to learn... not what large companies have decided to adopt (or not) based on a number of factors that have nothing to do with the quality of the language or its educational value.

Re:Why I love Rust by steveklabnik on Friday January 08, 2016 @09:40AM (#10865119)

  > you can see C++ adopting pretty much the borrow checker as a tool
This may be because I'm too close to it, but the Core Guidelines are similar in ways, but also very different. Preventing data races is an explicit non-goal, for example, whereas in some ways, it's the focus of the borrow checker.

  > Rust has no major production deployments of which I am aware
Dropbox is the latest production user, as of last month. And it's serious production usage: how the bytes get stored on disk, basically the core of the whole business.
Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @10:26AM (#10865479)
I'd really like to know how well that works out at Dropbox. How honest and public do you think they'd be if major data losses resulted from Rust crapping out on them? I'm not sure about them but lots of businesses keep such things on the DL.

I think it's a risky move. I'd have first deployed existing, native code along with Rust in parallel using the data splitting technique so some is saved with original and some with Rust. Any compiler or library related issues on Rust side would be caught without data loss. I wonder if they did this in alpha stage and how long that lasted.

I mean, I love seeing Rust in production and some success stories would be great. It's just... wow, that's pretty mission critical for what I gather is still a beta-phase tool. I'd be testing on the middle or front-end layers first given they're usually stateless(ish).

Re:Why I love Rust by pcwalton on Friday January 08, 2016 @11:48AM (#10866198)
> I think it's a risky move.

> It's just... wow, that's pretty mission critical for what I gather is still a beta-phase tool.

I think this is very '90s thinking. Extreme "if it's not C++, you can't deploy it!" conservatism about programming languages hasn't been true for well over a decade. Paul Graham has written some nice essays about this very phenomenon.

Also, Rust is not "a beta-phase tool".

New languages are much easier to deploy since the PL Renaissance. There are a few holdout industries that still stick with C++ no matter what, such as games, but they'll come around eventually. :)

Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @11:58AM (#10866288)
You've been in discussions on this forum where I slam both C and C++. I'm clearly against it unless I absolutely have to use it due to its issues. That's why your strawman is more amusing than most. My actual argument was that new tools are usually unstable in terms of features, implementation bugs, and (with compilers) performance. So, default recommendation for mission-critical apps are mature tools whose strengths and weaknesses are well-understood so pro's can use them robustly.

Back to beta-phase claim, you're saying the core features and compiler of Rust are no longer in development or testing? Totally stable now with only extensions, library features, and optimizations being added? If so, that's good news and I'll drop that claim in the future. Otherwise, it's in the beta phase. Another hint would be existence of any bugs with core functionality in your compiler or libraries.

Again, though, if the spec and core functionality are frozen with all bugs fixed then I won't call it beta. Is it there yet?

Re:Why I love Rust by pcwalton on Friday January 08, 2016 @12:32PM (#10866577)
Yes, 1.0 is stable and the language will not change in backwards incompatible ways. It's been that way for months (google "rust stability deliverable").

"All bugs fixed" rules out every language in existence except CompCert, so I don't think that's a very interesting metric.

Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @01:16PM (#10866913)
Good to know on stability part. Far as bugs fixed, it's more on the lines of day-to-day use of the language in common scenarios. Are people getting unnecessary troubles out of the compiler? Typically don't for most languages as they work out most of them in common idioms and library functions in first, few years. If they're serious rather than 1-3 people's hobby, that is.

I certainly won't expect it to be bug free. Nice comeback with CompCert, though. ;)

Re:Why I love Rust by fiedzia on Friday January 08, 2016 @02:36PM (#10867578)
I've seen rust compiler bug once and that was long before 1.0. The only issue now is that some important API's are not yet declared stable (RFC still being open), so many 3rd-party libraries target nightly and won't work in stable. This is however matter or 1 or 2 releases, and proves that rust developers take this matter seriously and don't wont to stabilize anything they aren't 100% sure. For all practical purposes rust is usable now, and more and more people are using it - certainly more then 3. Generally looking at rust projects on github, most of issues are feature requests. I don't see issues with crashes or panics, while I know plenty for similar projects written in C, at least in their early days.
Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @04:38PM (#10868499)
Thanks for the detailed assessment. Sounds like a high quality, Beta to me. I also like the good things I keep hearing about the quality of libraries, etc.
Re:Why I love Rust by kibwen on Saturday January 09, 2016 @06:56AM (#10870952)

  > I'd have first deployed existing, native code along with 
  > Rust in parallel using the data splitting technique so 
  > some is saved with original and some with Rust.
Yes, this is how Dropbox tests all of their features, and they did this with their new Rust-based storage engine as well. This tool has been in development for over a year by now and has seen extensive multi-stage testing (at first handling only a few terabytes of data, then "just" petabytes, and now exabytes).
Re:Why I love Rust by nickpsecurity on Monday January 11, 2016 @03:21PM (#10883146)
I was expecting they probably did given what's on the line. Re-reading it, I realize it probably didn't come off that way. Gotta work on that.

Thanks for the confirmation, though. I do look forward to reading the experience report. Hoping they include data on all key attributes vs prior language: productivity, debugging time comparison, CPU use, memory use, integration issues, and any changes in defect rates. Community evaluating Rust needs that data for something at this level.

Re:Why I love Rust by steveklabnik on Friday January 08, 2016 @10:38AM (#10865577)
The project lead already said on Reddit that if Dropbox loses data, it's now Rust's fault, so... :)

The project was a whole team of engineers working for almost a year, with extensive testing. At least, that's what I've heard. So like, I think they did exactly what you said, it's just that it's ready by now.

Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @11:26AM (#10865998)
Oh shit! That's one hell of an endorsement [in the making]. I bet the excitement and suspense are thick in the office, eh? Hope it works out for adoption reasons.
Re:Why I love Rust by steveklabnik on Friday January 08, 2016 @12:48PM (#10866685)
Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @01:35PM (#10867076)
I appreciate that. It has some good details. Gotta leave to get some work done but I'll take the time to drop you a compliment related to this:

"Edit: also worth adding that he Rust core team has been amazingly friendly and helpful. We've had several meetings with them where they came to our office and basically said "how's it going? what do you need? open up your laptop and show us your biggest problem." The project is under very good management."

When Rust was being developed, the two languages that got me most excited as next-gen, systems tech were Julia mainly and Nim somewhat. They had a great choice of features balancing all sorts of attributes as PL's that might get easy adoption as C++ alternatives. Thing is, many blog posts reported their communities and dev teams were downright vicious on everything from questions to compiler bugs (wtf!?). That made it a no-go as there's an upper-bound on how good those projects can get building on such a creaky, hostile foundation.

That leaves Rust as my default recommendation for new, non-critical projects in this space. Like Dropbox employee, what I've noticed is the two of you on Rust teams here are unusually helpful and respectful compared to many in PL communities defending their work. Even pcwalton when he's clearly less than happy with my comments. ;)

The combination of brilliant design and seemingly (from my little exposure) excellent community is why I promote Rust. So, keep up the great work all of you! :)

Re:Why I love Rust by steveklabnik on Friday January 08, 2016 @01:37PM (#10867096)
Thanks so much. :)