Hacker News new | past | comments | ask | show | jobs | submit login
[flagged] Google's Lars Bergstrom: Rust teams are twice as productive as teams using C++ (twitter.com/spastorino)
64 points by martijnarts 30 days ago | hide | past | favorite | 35 comments



For everyone asking: in the talk, Lars mentions that they often rely on self-reported anonymous data. But in this case, Google is large enough that teams have developed similar systems and/or literally re-written things, and so this claim comes from analyzing projects before and after these re-writes, so you’re comparing like teams and like projects.

Timestamped: https://youtu.be/6mZRWFQRvmw?t=27012

Some additional context on these two specific claims:

Google found that porting Go to Rust "it takes about the same sized team about the same time to build it, so that's no loss of productivity" and "we do see some benefits from it, we see reduced memory usage [...] and we also see a decreased defect rate over time"

On re-writing C++ into Rust: "in every case, we've seen a decrease by more than 2x in the amount of effort required to both build the services written in Rust, as well as maintain and update those services. [...] C++ is very expensive for us to maintain."


More timestamps:

- Graph on time to become sufficiently productive in Rust to comfortably contribute to a codebase: https://youtu.be/6mZRWFQRvmw?t=27149

- Graph on time to become as productive in Rust as in other languages: https://youtu.be/6mZRWFQRvmw?t=27240

- "Yes, it takes some time, but people do feel like they are as productive in Rust as they were in the language that they previously were writing in." https://youtu.be/6mZRWFQRvmw?t=27274

- Graph on the ease of code review in Rust vs other languages: https://youtu.be/6mZRWFQRvmw?t=27304

- Graph on confidence in Rust code correctness: https://youtu.be/6mZRWFQRvmw?t=27361

- Code example vs C++ #1: https://youtu.be/6mZRWFQRvmw?t=27431

- Code example vs C++ #2: https://youtu.be/6mZRWFQRvmw?t=27656


I remember there were several pilots to rewrite some of C++ libraries in Rust at the exploration stage, keeping their behavior as close as possible. IIUC, the outcome was positive in general, consistent with the tweet's claim.


Do you think “Lars”, as chair of the Rust Foundation board of directors and previous Servo project member could have a conflict of interest here?

Something that should be mentioned as a disclaimer when quoting his opinion on Rust vs. other languages and that would significantly water down the strength of their claims.


Could? Sure, in an abstract sense.

What would the motivation be for someone so senior to lie on stage about this stuff? Just because he likes a programming language?

This is conspiracy style thinking.

Thankfully, if Lars is lying about this, there's tons of Google folks here on Hacker News. I haven't seen anyone yet make an actual claim with any evidence that he's not telling the truth here.


If you ever used Rust I am sure you already are aware of one major reason for the discrepancy, which surprisingly has nothing to do with the language. The tooling around rust is just so much better.

CMake, include conflicts, dependency management, etc. either don't exist or are all much less painful in rust. There is just so much annoying stuff that you do not have to deal with when using it.

There isn't really much revolutionary that rust the language does. Explicitly having to describe the behavior of memory takes getting used to, but lifts some weight of your shoulders. Other than that it has a somewhat better, and less verbose, syntax than C++. But that really is it.


A lot of this tooling is available for C++ development at Google.

Includes are added automatically when you use code completion. There is also a simple IDE command to add all the include dependencies to your build file.

I don't know how well rust is integrated with Googles internal tooling.

The golang integration is incredible, though. You don't need to touch includes or build dependencies at all. They are fully automated.


>A lot of this tooling is available for C++ development at Google.

No, it isn't. Google even has their own build system, because obviously CMake is so bad, but it it is made for insanely large systems not ease of entry for medium/small projects.

C++ slowly is adopting the language features that allow for such integrated tooling, but it isn't there yet. But right now the tooling can't exists simply because of what C++ is. The problems you can't easily solve in C++ are things like "how do I integrate this already existing library into our build chain", that is a legitimately hard question and millions of lines of code have been written trying to solve that problem.

There is no equivalent to cargo for C++, there is build2, there is conan there is vspkg and the VS build system. ALL of them suck and have their own gigantic problems which will raise their head and suddenly you are struggling with include and build problems.

Google hasn't fixed C++, nobody has.


All libraries you would need are already in Google's monorepo. There is no need for a package manager.

There are a few external libraries in the monorepo. Maybe it's a trickier task to add those. Most Googlers don't need to do that, though.


Mono repos don't make it so that suddenly you don't have to manage dependencies for a project. They certainly don't fix CMake.


CMake is something you set up once and then mostly add source files which is a one liner. A platform like Android would have an SDK with all dependencies pre-installed, anything else would be nuts.

Have no idea what “include conflicts” are supposed to be. The compiler receives a series of paths and searches for files by name.


You can't be serious.

>A platform like Android would have an SDK with all dependencies pre-installed, anything else would be nuts.

Android is usually Java, but you still have to manage dependencies yourself. There is no SDK which includes "all" dependencies, that would be absurd. You are going to create your own dependencies.

For CMake, it is so bad that there are many high effort attempts to replace it, by Google, Microsoft and some others, just to not have to deal with it.


Android APPLICATION development is typically in Kotlin (and of course Java), but Android OS doesn't contain a large percentage of Java. That's C/C++ land and now increasingly Rust.


I think this is an incredibly kind take for CMake... what about projects that automatically generate bindings (like swig), or attempt to find system-installed header files (like CUDA)? Look at, for example, pytorch (huge amounts of autogenerated code via ATen, at least a few years ago). In my experience C++ projects rarely live in a vacuum and projects build up cruft very easily.


It's easy to be 2x productive in a language that's bound to be biased toward greenfield projects.


I maintained large C++ and large Rust codebase, and maintaining Rust codebases is much easier too.

Granted, Rust projects I worked didn't have as much scope creep as C++ projects, but I feel like that's in part due to Rust's ecosystem having better glue (cargo) than C++ alternatives


Full quote: "Rust teams at Google are as productive as ones using Go, and more than twice as productive as teams using C++."

From his keynote presentation the RustNation UK conference.


I do not wonder about the double productivity increase compared between Rust and C++. But what really makes me wonder is the comparable productivity of Rust vs. Go. I thought Go is much easier than Rust and that people could write applications much faster in Rust. I would expect that Rust takes at least 2-3 times more time to write an application, compared to Go, but then I would also expect it to run at least 2-3 times faster than the Go version, hence it is a fair trade-off.


If you write Rust where you copy all the time instead of borrow, it can save you enormous amounts of time with arguably minimal performance degradation. This can make up a lot of the perceived time disparity between Go and Rust, and leave C++ in the dust. (Yes, I know C++ can copy as well, but in my experience, it can be very difficult to teach old C++ devs new habits.)

After you've profiled your working code, you can go back and optimize with less copying, more borrowing, and other optimizations where it matters.

Go has the same issue. After it's working, you go back to profile, and those optimization steps can often take longer than original development. (Which is why you profile before optimizing.)

With C++ you must add on time to catch all the memory access bugs and fix them, which is time you don't have to take in Rust and Go due to the borrow checker and garbage collector respectively.

In Go you have to find all the spots where you didn't check the error return code or other unhandled branches, hopefully before deploying to prod. This is time you don't have to take in Rust since it catches these errors during compile.

The advantage of Go is that the typical path is easier, the learning curve is much shallower, and its orders of magnitude faster to compile leading to faster dev feedback loops. On the Rust side, you've got a longer learning curve, and you really have to actively resist the urge to prematurely optimize.


I don’t mean this post to be about Go; I have never written significant amounts of Go and have no opinion on its productivity.

Productivity in Rust is difficult to talk about, because of differences in opinion and what I like to call “the TCO problem.”

Because Rust is hard to learn, a lot of folks assume it’s that hard all the time. Which means they assume things take just as long for a new Rustacean as they do an experienced one. This is generally not the case. Once things click and you’re over that hump, it feels like programming in any other language. If there are similar libraries available and I don’t need to create the world from scratch, I am just as productive in Rust as in other languages that also have those libraries, generally.

But that kinda leads into the other thing I alluded to; a lot of people think of “productivity” as “whatever lets me see something quickly.” But this doesn’t capture real prodctivity, in my mind, which includes the total development time, aka, how many bugs do I have to deal with later. Rust moves a lot (but not all, of course!) of this up front. Which can feel like it slows you down (but again, with experience, I find this is actually kinda minimal), but then you save time on the back end by needing to debug less. This means that robust features end up being developed more quickly than in some other “productive” languages I’ve used in the past.

TL;DR things aren’t simple, and “fast to get going” doesn’t inherently mean “productive.”


For anyone like me who wondered what "TCO" is: In this context "TCO" stands for "time-cost optimization," basically the idea that time is money and so you shouldn't be scared of weighing:

- an alternative that costs a small amount of money over a long span of time, against one that costs a large amount of money for just a short span of time

- an alternative that costs money (or time) up front, against one that costs a money (or time) later on

I'm still not 100% sure what "_the_ TCO _problem_" is, specifically; but it definitely has nothing to do with tail-call optimization. :)



Ha! I guess at least "time-cost optimization" and "total cost of ownership" aren't too terribly different. :)

But there's an interesting difference in framing or worldview between the two acronyms: My assumption of "time-cost optimization" assumed that such tasks as debugging were part of _producing_ a software artifact. Our implied goal (just like in the Rust talk's title) was to maximize _production_ of such artifacts at a reasonable level of quality. The back-loaded testing and bugfixing work might go on for a while (if you made that tradeoff), but it eventually ends in a "product" (or in project failure).

On the other hand, "total cost of ownership" emphasizes that our primary job isn't production but _ownership_ of software, which is open-ended and goes on forever. We have to think not only about "How long will it take to get it right?" but (mostly!) about "How costly will it be to maintain, year after year, even _after_ we get it right?"


Agreed! I also was like "... that's not what I meant but that does kind of work, when I read your comment." :)


How was productivity measured? I doubt that teams of Rust and C++ developers were given the same projects to implement.


They actually were given the same projects! It was anonymously self-reported.


They must have a ton of comparative data on releasing new chat apps.


This is Google we're talking about, so maybe they were :)


Probably hobbyists were more likely to join rust side after learning about its pros?


People working at Google are by definition not hobbyists.


Ok, people with "passion" then


You could just like, say what you mean rather than try and launder the opinion through insinuating things about the people involved.

If someone is passionate but that makes them more productive, why would that be a bad thing? At the end of the day, they’re still more productive?

Regardless, there’s nothing to indicate that the folks involved are new, or “more passionate” or whatever. They’re Google engineers doing their job at Google. Google has a bunch of Rust projects, some large ones too, that have been going on for years.


It's bad because people that write C++ for a living got all the joy and happiness sucked out of them and since Rust is in a similar playing field regarding performance, they can't say that they need to use C++ for performance reasons and therefore would admit that all the pain and suffering would be for nothing if they let one good word regarding Rust stay uncontested on the Internet.

I don't even like Rust that much but it's like Stockholm Syndrome is a requirement to have a positive opinion regarding C++.


I meant that people who write Rust may be more curious about tech, so they could be better devs


In the Q&A from the video, there's a question very similar to yours.

As an answer, Lars specifies that these are regular engineers who were asked to learn Rust, and not early adopters who like shiny things.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: