Live data from Hacker News

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

risingwave-labs.com

31–40 of 307 posts

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

#31
post #9

"The STL library lacks support for some modern programming tools, for example, native co-routine support. As a result, developers must rely on many community projects, and most lack long-term support." I couldn't agree more with this comment. As great as the community is, there's a lot of projects that are just not maintained. I wish this was different.

Projects going stale is a cross-language problem really. Rust will also encounter this at some point.

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

#32

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

> ....since C++11 there is no reason for not using smart pointers.

Sadly there is, lack of security culture and plenty of devs won't allow them on a PR.

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

#33

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

> since C++11 there is no reason for not using smart pointers There are many reasons for not using smart pointers, first amongst them for me being performance. Smart pointers do allow you to remove a large class of memory bugs from your code (albeit not memory leaks) in the same way that Rust's safe references do. However C++ smart pointers impose a run time performance penalty on your code, whereas in Rust the check…

> However C++ smart pointers impose a run time performance penalty on your code.

i'm not sure if this is the case. unique_ptr doesn't really do much other than use the type system to ensure that only one instance of the pointed-to value exists at once. as far as i understand, it doesn't strictly do anything at runtime.

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

#34
post #13
post #9

"The STL library lacks support for some modern programming tools, for example, native co-routine support. As a result, developers must rely on many community projects, and most lack long-term support." I couldn't agree more with this comment. As great as the community is, there's a lot of projects that are just not maintained. I wish this was different.

Boost ASIO has some coroutine support. I would not call it a hobby project either.

Indeed.

Also seastar comes with coroutine supports[1], and incidentally it was written for a very high performance C++ database implementation.

[1] https://docs.seastar.io/master/split/5.html

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

#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.

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

#36

Author quoted C/C++, I immediately knew what conclusions I’d find. If on the other hand they had seasoned C++ devs (instead of C/C++), they might have had a different outcome.

That is the current issue with most C++ codebases nowadays, I only see modern C++ on conference slides, when I look into codebases even from ISO C++ members, it is always C++ full of C idioms no matter what.

I bet most candidates to C++ job offers end up discovering the hardly reality of existing code.

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

#37
Every time I read of memory leaks in C++ codebase, I get no idea why RAII didn't work in those cases. Even if the codebase was huge and complex. Circular references? Some special cases why one can't use RAII?

Forget unique pointer or smart pointers. People had been coding in C++ far before that without fearing memory leaks by following RAII principals.

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

#38
>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 even going to mention sanitizers, probably rocket science for them

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

#39

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”.

[dead]

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

#40
post #21
post #9

"The STL library lacks support for some modern programming tools, for example, native co-routine support. As a result, developers must rely on many community projects, and most lack long-term support." I couldn't agree more with this comment. As great as the community is, there's a lot of projects that are just not maintained. I wish this was different.

C++20 comes with coroutines, no?

[deleted]
Post reply on HN