Live data from Hacker News

Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

risingwave-labs.com

191–200 of 307 posts

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#191

What's often neglected is the excellent tooling around Rust, that alone is reason enough to switch from C++, where you have a really fragmented tooling ecosystem and you're often required to deal with complex Makefiles or build config as well as download dependencies manually. Most of that just disappears with Rust, unless you're developing code that interfaces with existing C/C++ libraries.

This, also. C and C++'s build model is a train wreck, especially in C++ code gets rebuilt dozens of times due to headers being simply plopped into whatever translation unit you are building. Rust efficiently solves this by defining building abstractions in the language itself, instead of relying on hacks such as #include, PCH, ...

C++ modules....

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#192

> But as more and more engineers joined us, some shortcomings > of C++ came to bite us: unreadable coding style, memory leak, > segmentation fault, and more. * unreadable coding style: This is not a C++ problem. * memory leak: Memory leak is an old C++ problem, since C++11 there is no reason for not using smart pointers. The only point that could be attributed to C++ is the segfaults perhaps, due to its lack of safet…

As a long time c++ developer there's a big difference between when something shouldn't happen and when it can't happen. Rust makes certain classes of issues fundamentally impossible (ironically, leaks are possible in Rust), while in C++ it depends on how well you can enforce certain code guidelines on yourself and anyone that works on your same codebase. Also, you get like zero assurances that other people code has been written with the same quality standards as yours, as long as something is very easy to mess up, it will probably be inadvertantly messed up by someone.

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#193

Earlier quoted context omitted.

> re-use data structures That's funny. I've been going mostly the other direction. I'm avoiding mutable structures whenever possible. I have a much easier time reasoning about stuff when I know that things aren't going to change mid-life.

I don't know what you're programming, but it's pretty hard to not use more complex structures like Vecs and HashMaps without them being mutable. Also, that is exactly what Rust's borrow-checker is there for. It doesn't allow you to mutably borrow the same data structure multiple times.

I was thinking more about the things being contained rather than the containers themselves. But you're right - they are all data structures.

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#194

Earlier quoted context omitted.

I would hope they are, otherwise why are you even writing C++. I might have too high expectations though...

The idea that ref-counting is automatically "better" than a garbage collector is still pretty popular unfortunately (and that's just the tip of the iceberg).

A bump allocator + state of the art compacting GC is MUCH faster on a naïve basis which is why it is important to minimize number of allocations in non-GC langs and use stack based RAII when possible. When building things like trees in a non-GC language, arena allocation should be considered for max performance. This is just another low level vs high level trade off IMO.

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#195

Fascinating how defensive C++ lifers can be. Rust builds on the knowledge of decades of C++ programming. It’s basically a compiler enforced set of C++ best practices. It’s strange how hostile some in the C++ community are to Rust.

You have to remember that we die. So what you learn til 30, say, you capitalise on till 70, and then you retire & die. There isn't another live to live until 30 "again", and then be within the Rust culture. Rust has, by analogy, stapled it's "Ninety-five Theses to the door" of C++ and those C++atholics are afraid their way of life is ending before they do.

Taking that analogy further, Catholicism didn't die out. Protestantism definitely grew, then there were hostilities and outright fighting for hundreds of years in some cases.

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#196

I really like Rust. I like C, and C++ too. I find a lot of C++ and C detractors are nit-picking and over-promising the-new-shiny-thing, or are probably not great engineers to begin with and are blaming the tool. In this instance, I'm leaning towards the latter. Although Rust is an improvement in many ways, I actually think it is becoming more C++ like with every release. I think it has a good chance of over-taking C+…

> ...it has a much better user story around build & package/module/library management

Cargo sure does, but support for rust outside of cargo is much, much worse than equivalent support for C and C++. It doesn't matter for self-contained projects like simple Makefile ones, but at large scales, moving everything to cargo doesn't seem reasonable right now. Maybe eventually?

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#197
post #35

Building a database is brave or stupid or both. Over the last 15 or 20 years I’ve tried lots of databases of all flavors and every time come back to Postgres. What can’t it do. And like Linux it’s written in C. Not that means much. “Never bet against Postgres”.

Betting against Postgres all the time, since the .com age I have mostly used Oracle and SQL Server, and Postgrest only in a single projec that was alive during 4 years. There was also Informix, SYBASE and DB2, but those hardly matter nowadays.

Why doesn't DB2 matter?

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#198

Fascinating how defensive C++ lifers can be. Rust builds on the knowledge of decades of C++ programming. It’s basically a compiler enforced set of C++ best practices. It’s strange how hostile some in the C++ community are to Rust.

the fact we might have got sick of your evangelism and lies hasn't crossed your mind I guess

>It’s basically a compiler enforced set of C++ best practices

Its not, its a whole different programming paradigm where the compiler dictates how you write your software. You dont let your creative facilities to drive you or whats best for your domain - you just obey the language rules...

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#199

Earlier quoted context omitted.

> Rust can already be very arcane to decipher sometimes, especially when you start getting errors from async libraries. For what it's worth, the community, library authors, and most importantly the language design teams are all very aware of this. And there's efforts being made to make all these pain points things more ergonomics and approachable. I think it just a slower process than we'd like. I think in part it's…

I think GATs in Rust are really cool. Just like template meta programming in C++ is really cool (despite the countless articles on why it shouldn't be used by mere mortals in production code--it's too powerful and unwieldy!). I worry that Rust will become just as arcane as C++ but will look better at a surface level because it has modern and sane defaults and not 40 years of baggage. Perhaps I'm worried I'm just not…

I do understand what you mean abou complexity creep, and hope it doesn't happen, but also fear that it might in due time.

The thing about GAT is that it was never meant to be a feature. It just removes a non-obvious limitation from the language. I remember when learning Rust, I expected "GAT syntax" to just work, and was surprised when it didn't.

So, for me it makes the language less arcane.

> Perhaps I'm worried I'm just not smart enough to be a Rust programmer.

I think everyone can learn anything. It's just a matter of finding the right angle to understand a concept. If something hasn't click, force yourself to use those parts until they do.

> Off topic: I also find the Rust community unwelcoming and very clique-ish, I get the very strong "you're not apart of the cool gang" vibes and I'm too old to care to navigate this.

Ah maybe. I've not experienced this personally, but I've seen others make similar claims. It's generally aways very welcoming from what I've seen. There's the occasional smartass on their Discord, but that's just... Discord Things(TM). People ignore them, and if they're obnoxious they get called out and asked to chill out a bit.

Out of curiosity, what are your main interaction channels/places with the community? Maybe you just accidentally navigated into ones that don't suit you personally

Re: Building a Cloud Database from Scratch: Why We Moved from C++ to Rust (2022)

#200
post #178

Earlier quoted context omitted.

> It’s basically a compiler enforced set of C++ best practices. It’s strange how hostile some in the C++ community are to Rust. Well, the syntax is alien and new, it doesn't do OO the way 9 out of 10 working developers expect it to, almost all C++ popular design patterns have to be rejected, many of the claims("fearless concurrency") are exaggerated and the Rust evangelists are really really toxic when referring to C…

I've seen an order of magnitude more people complaining about Rust evangelists as I've actually seen Rust evangelists, and they've been significantly more hostile and toxic. The majority of Rust programmers I know were C++ programmers in the past. Many, including myself, use both professionally.

> I've seen an order of magnitude more people complaining about Rust evangelists as I've actually seen Rust evangelists, and they've been significantly more hostile and toxic.

Does this, to you, look like a response that is welcoming to C++ devs? I gave careful and impassive reasons, and you strike back with literal ad hominem attacks.

This sort of reply is what makes Rust, as a community, look shallow-minded and toxic.

Post reply on HN