Live data from Hacker News

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

risingwave-labs.com

281–290 of 307 posts

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

#281

Earlier quoted context omitted.

Is rust code heavily seasoned with unsafe keyword really that hard to prototype in? Is it meaningfully harder than c++ in this regard?

I assume they didn't mean compared to C++. If anything, saying prototyping in C++ is easier than Rust is beyond ludicrous even if you're a seasoned C++ developer. I'd have an easier time prototyping in Rust than C++, and I've been writing C++ for 10 years and Rust for a little over a year. However, prototype in something like Ruby (or even TypeScript, and some people mentioned Elixir) is in a different universe compa…

What makes Rust better at rapid prototyping? Cargo?

I find that modern C++ "kitchen sink" approach to features makes it good for rapid prototyping, a bit like Perl on the dynamic side. It won't force you into a specific approach, pick the one that gets you there the fastest. Use raw pointers and malloc(), or use fancy smart pointers and RAII, your choice, you can also do both, you have exceptions, you have goto, you can write(), printf() and cout, you have classes and lambdas and (multiple) inheritance and traits. More options are better for rapid prototyping.

Also, C++ is the most popular language for competitive programming, you can't get more "rapid" than that.

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

#282
post #80

Earlier quoted context omitted.

Yep. The one big beginner “mistake” I see people make in rust is overusing Box / String / Vec. Rust code that allocates everywhere can be even slower than javascript. The reason? Malloc is slower than you think. Slower than short allocations in V8 or Go. If you want performance, make friends with &str, &[], >, bumpalo, SmartString and SmallVec. (Or similar crates). Removing allocations from the hot path can improve p…

> Slower than short allocations in V8 or Go Slower than V8, definitely possible. Slower than Go, very unlikely, since it doesn't have a generational or compacting gc.

For some reason I always assume Go is faster than Javascript+V8. Is that actually true?

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

#283

Earlier quoted context omitted.

As a fellow Rust user, please stop saying this. Not everyone who codes like us is a bad programmer. It's this kind of sentiment that gives us a bad name. Rust may influence us into patterns that are better in some (likely even most) situations, but not always. Sometimes the situation calls for other approaches, and that's okay.

Think you're misunderstanding the OP. Do you think rust is hard to use?

The OP is crapping on people who find Rust hard to learn by broad-brushing them into the "bad programmer" bucket. It's a hallmark of Rust zealots, and one reason why the Rust community has such a bad name. Which is a shame because the language is decent and useful.

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

#284
post #224
post #207

You can't revert this trend - C++ is a legacy language being depreciated by more and more projects. C++ and Rust are simply not competing on the same level. You don't need a complicated "enterprise" building farm/cluster to build your project, dependencies are managed by the guys who also write your compiler, there is a growing community that actually listen to your feedback and you don't need to wait 40 years to get…

I’ve noticed that the tone is becoming rougher with each new Rust story. I’d be curious to know what kind of professional would choose to express themselves in this way, it’s pretty embarrassing. First of all, that blog post - as many Rust-themed blogs from start-ups - is a submarine article attempting to increase the notoriety of their product. Not enough to disqualify it, but a hint that it won’t necessarily be tec…

> I’d be curious to know what kind of professional would choose to express themselves in this way, it’s pretty embarrassing.

Embarrassing for pointing out that OO is dead and it is not acceptable to ask users to wait almost 40 years to get networking support into the standard library? No, C++ standard committee members should be embarrassed, not those disappointed users.

> that blog post - as many Rust-themed blogs from start-ups - is a submarine article attempting to increase the notoriety of their product.

As any article published by an commercial entity, it is always about increasing its economic benefits. Personally, I don't know anyone from the company but their blog is just one more success story of depreciating C++ and I applaud for that.

> Having memory leaks in 2021 is incomprehensible. This is an amateur mistake of the worst kind in modern C++.

Sorry but I stopped reading after this. I've been writing software for the past 20 years, worked for the biggest names in industrial, had my PhD in CS about 15 years ago, I write code on almost daily basis (Linux kernel modules, database kernel, infrastructure kind of code). I make the above mentioned amateur mistakes pretty often.

Not saying I am highly skilled, just saying if I can make such mistakes after working 20 years in the field, it wouldn't be rare for other people especially those young developers.

btw, I recently had a nasty memory leak bug in golang that took me a couple days to reproduce and debug, yes, in a GC based language.

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

#285

10 seasoned C++ devs could probably make a killing in the finance sector right now.

Can you elaborate?

The finance sector has lots of bespoke C++ code driving for example hedge funds, even real time trading and C++ coders are aging and retiring...

They certainly pay better, upfront, than a startup does.

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

#286

Earlier quoted context omitted.

It would not. Rust needs ASAN/UBSAN/TSAN/MSAN sanitizers for a reason.

Can you point me to any significant primarily rust codebase that runs sanitizers? I've never heard of that. Unless you mean miri.

Not miri. I mean the actual ASAN, UBSAN, TSAN, MSAN and LSAN sanitizers that are also commonly used in C and C++ codebases. Descendant is the same: LLVM [1]

> Can you point me to any significant primarily rust codebase that runs sanitizers? I've never heard of that

Not sure what do you mean by that, surely there are. At least the ones who are serious about the development. Sanitizers are part of official documentation in Rust [2].

[1] https://github.com/rust-lang/rust/issues/39699

[2] https://doc.rust-lang.org/unstable-book/compiler-flags/sanit...

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

#287

Earlier quoted context omitted.

Both viewpoints make sense; whether Rust is good for prototyping depends on the domain. If it fits the borrow checker well (like in CLI apps, stateless servers, data transformation) then the borrow checker fits beautifully and seamlessly. In other settings (complex turn-based games, some compilers, GUI), the borrow checker can cause some artificial complexity and prototyping slowdowns compared to other paradigms.

I guess it depends on your point of view. For me, having Rust catch issues even when prototyping makes me enjoy prototyping more. I absolutely hate (even when prototyping) when I try to run something, it chugs along for a bit, and then hits a runtime error due to some stupid typo. In fact I like Rust for prototyping precisely because I don't yet have tests, and the extra compiler diligence frees me to focus on the pr…

> and then hits a runtime error due to some stupid typo.

I don't think that the parent comment implied prototyping in dynamic languages but rather in statically compiled ones.

FWIW in C or C++ you don't have to do as much code gymnastics to satisfy the compiler so consequently prototyping is both faster and easier when compared to Rust.

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

#288

>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. - Seasoned devs but they never heard of clang tidy/format - Memory leaks on a new db codebase where each component should have clear ownership of data or pass to the next pipeline/stage - you dont even need smart poirters here, just a half decent design. - I am not e…

From what I understood, clangd was not enough to make new developers write good enough code.

The problem was not the seasoned core of developers, but the fresh hires.

Now, this would be an interesting problem. Just as Python has PEP8 and some other programmable coding guidelines, we should have different sets of modern programmable C++ coding guidelines, which can be checked by clangd.

And I mean modern, logical, Rust challenging, C++20 coding guidelines. Something this particular team would follow. Nonsense like Orthodox C++ doesn't cut it.

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

#289
post #207

You can't revert this trend - C++ is a legacy language being depreciated by more and more projects. C++ and Rust are simply not competing on the same level. You don't need a complicated "enterprise" building farm/cluster to build your project, dependencies are managed by the guys who also write your compiler, there is a growing community that actually listen to your feedback and you don't need to wait 40 years to get…

> and you don't need to wait 40 years to get networking support into the standard library

This one hurts, but so true =)

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

#290

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+…

Yes, and competition is good. Rust is good and I expect they keep making great things.

C++ is also becoming better with every release, and C++20 is a huge improvement.

In all honesty, code written in C++20 feels just like code I have written in Python and/or JavaScript. And 20–40 times faster.

Post reply on HN