TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Rust – A hard decision pays off

474 pointsby muizelaarover 2 years ago

32 comments

nu11ptrover 2 years ago
This doesn&#x27;t surprise me and matches my own experience. Rust literally makes a codebase nearly void of most bug classes with the exception of logic bugs (Unfortunately, in a huge codebase, there can still be tons and tons of logic bugs).<p>Still, when I migrated my Python codebase to Rust I got rid of whole classes of bugs and honestly code faster in Rust on a &quot;per debugged line of code&quot; basis. In Python, every line MUST be run or could trigger an exception (and so many do and it is hard to see). This now requires a test harness that tests every single line which is a huge pain. In Rust, the things that can obviously panic are pretty easy to see and are limited (unwrap, expect, indexing, etc.) making it much easier to write robust code, even with a more limited test suite.
评论 #32583391 未加载
评论 #32583500 未加载
评论 #32580544 未加载
评论 #32580866 未加载
评论 #32588295 未加载
throwaway894345over 2 years ago
&gt; Dev velocity, which was supposed to be the claim to fame of Python, improved dramatically with Rust.<p>I don&#x27;t doubt this in the least. I&#x27;ve been a professional Python developer for 15 years, and I can&#x27;t believe Python ever had the reputation for &quot;high dev velocity&quot; beyond toy examples. In every real world code base I&#x27;ve worked in, Python has been a strict liability and the promise that you can &quot;just rewrite the slow parts in C&#x2F;C++&#x2F;Numpy&#x2F;etc&quot; has never held (you very often spend at least as much time marshaling the data to the target language format than you gain by processing in the faster language <i>and</i> you have all of the maintainability problems of C&#x2F;C++&#x2F;Numpy). Python trades developer velocity for poor runtime performance.<p>I don&#x27;t think Rust is the paragon of high dev velocity languages either, but it seems to be more predictable. You don&#x27;t have something that works as a prototype, but then you run into a bunch of performance problems (which virtually cannot be worked around) when you go to productionize, nor do you get all of the emergent quality and maintainability issues that come about from a dynamic type system (and last I checked, Python&#x27;s optional static type system was still pretty alpha-grade).<p>I strongly recommend avoiding Python for new projects. Use Go if you&#x27;re looking for an easy GC language with max productivity and a decent performance ceiling. Use Rust if you&#x27;re writing really high performance or correctness-is-paramount software. I&#x27;m sure there are other decent options as well (I&#x27;ve heard generally good things about TypeScript, but I&#x27;d be concerned about its performance even if it is better than Python).
评论 #32584581 未加载
评论 #32580428 未加载
评论 #32580575 未加载
评论 #32580537 未加载
评论 #32584204 未加载
评论 #32580732 未加载
评论 #32579907 未加载
评论 #32580654 未加载
评论 #32582530 未加载
评论 #32584763 未加载
评论 #32580178 未加载
评论 #32583078 未加载
评论 #32579926 未加载
评论 #32584141 未加载
评论 #32580338 未加载
评论 #32583676 未加载
评论 #32579940 未加载
评论 #32586389 未加载
评论 #32585878 未加载
评论 #32582393 未加载
评论 #32583491 未加载
评论 #32585934 未加载
评论 #32583579 未加载
评论 #32587689 未加载
评论 #32581796 未加载
评论 #32587803 未加载
评论 #32581129 未加载
benreesmanover 2 years ago
So I was one of the 3 hackers who wrote the LSM that predated Rocks at FB, and as a result I distinctly remember when Rocks overtook it in features by trading off performance, and again when it met and exceeded the performance while keeping the greater capability. RocksDB kicks ass and has for a long time, I’d recommend it to anyone in the market for that sort of thing.<p>FAISS is also great, and has been for years. I don’t doubt that someone has done a meaningful rev on it.<p>But as someone who likes Rust and wants to like it more: don’t lead with that. The software speaks for itself. Or should.
评论 #32579504 未加载
mhaberlover 2 years ago
&gt; ..complex runtime issues which were almost impossible to reproduce or isolate<p>&gt; That’s when internal murmurs about a complete rewrite started brewing…<p>&gt; We decided to move our entire codebase to Rust<p>&gt; there was still one minor problem - no one on the team knew Rust<p>&quot;We have runtime issues so we will fix them by a complete rewrite in a language that no one on the team knows.&quot;<p>I would not call that a &quot;hard decision&quot;, rather &quot;rolling the dice&quot;. It awesome that they managed to make it work.
评论 #32579562 未加载
评论 #32580852 未加载
评论 #32581605 未加载
评论 #32579482 未加载
评论 #32580832 未加载
jhggover 2 years ago
Writing Rust at scale, I concur with some of these findings. Nowadays, my team exclusively writes Rust. Our rationale is two-fold.<p>1) We want to write software that is fast and inexpensive to run. Our rust services are quickly growing, but cumulatively, they remain in the sub-1000 core count, while processing many millions of requests per second across our service with excellent latency.<p>2) We want to write software that won&#x27;t break and page us in the middle of the night, or blow up when we deploy it. We operate some of the core persistence primitives at our company, so the consequence for error in the worst case could be corruption or loss of user data. Our experience thusfar with Rust is that we&#x27;re able to confidently iterate and deploy our services. The developer velocity is indeed higher, and continues to grow with your experience in the language.<p>Our team of 10 (with 3 engineers having started in the last 2 weeks) owns all of the database clusters, and all of the services surrounding them. Our on-call is surprisingly quiet, with maybe 0-3 low sev incidents a week, with most of them being due to the underlying database&#x2F;hardware, and not the rust services. We are actually writing a Rust control plane for our databases soon, which seeks to automate most of the response and remediation of most of the incidents we experience in a given week, and also to automate a bunch of manual work that we currently do around operations of the databases.<p>The learning curve can be a bit rough, but our team of engineers is motivated to learn, and we have a great culture of mentorship and teaching from the engineers who are familiar with Rust.
评论 #32585382 未加载
nazkaover 2 years ago
I like this &quot;and an overzealous compiler increased engineers’ confidence in pushing changes&quot;.<p>If you think about it, you can try to optimize a Rust program through trying brute force stuff and trying weird things that you are not even sure will break something or not. But you can try ~without 100% knowledge or confidence~ and boom the compiler will tell you if you are shooting yourself in the foot. Now try to that in C++. Even with 95% knowledge and confidence I will be very worried as a Lead or CTO.
RcouF1uZ4gsCover 2 years ago
&gt; Dev velocity, which was supposed to be the claim to fame of Python, improved dramatically with Rust. Built-in testing, CI&#x2F;CD, benchmarking, and an overzealous compiler increased engineers’ confidence in pushing changes, and enabled them to work on the same code sections and contribute simultaneously without breaking the code base. Most impressively though, real time operational events dropped almost to zero overnight after the original release.<p>I think Rust is really shaping up to be in a sweet spot.<p>One thing that is not talked about enough with Rust, is that you do not need to start with fighting the borrow checker from day one.<p>Making copies and using Rc can bypass a lot of the trickier parts of the borrow checker and still allow you to access much of the benefits of Rust in terms of performance and correctness, especially compared to a dynamic language like Python.<p>As you get more experience, you can then use references and other techniques to eliminated unnecessary copies, etc.
评论 #32579944 未加载
评论 #32579814 未加载
throwaway642012over 2 years ago
I don&#x27;t want to be dismissive but how much of this success belongs to the team of rock solid senior engineers with enough experience under their belt rather than rewrite in Rust?
评论 #32579571 未加载
评论 #32579386 未加载
评论 #32579578 未加载
评论 #32579470 未加载
评论 #32579739 未加载
评论 #32579824 未加载
t43562over 2 years ago
Writing something for the second time is a significantly different experience so that makes the conclusion much less definitive to me. Did they need python at all the first time - maybe not.<p>Python &quot;velocity&quot; is, to me, more about the ease with which you can make changes without breaking other code. You can still break other code and if you don&#x27;t have a proper test suite then you&#x27;re wasting your time - which is something that smells slightly in the story.
评论 #32583539 未加载
评论 #32584940 未加载
jraphover 2 years ago
The title is &quot;Inside the Pinecone&quot;. &quot;Rust – A hard decision pays off&quot; is only one of the three major subsections of this article.
评论 #32578999 未加载
评论 #32579118 未加载
评论 #32580262 未加载
endisneighover 2 years ago
Maybe it’s just me but it seems irresponsible to move your entire team to a programming language none of them knows.<p>Rust is great, but modern C++ is great too.
评论 #32579679 未加载
评论 #32579500 未加载
评论 #32579414 未加载
评论 #32579596 未加载
评论 #32579838 未加载
评论 #32579642 未加载
lmeyerovover 2 years ago
Something I still struggle to understand with these systems is why indexing 1-10M things is hard &#x2F; their sweet spot, when that is basically a small dataframe in pandas or a small SQLite, vs the 10B+ rowa &#x2F;&#x2F; GBs+ I was expecting them to be discussing
FpUserover 2 years ago
Frankly on larger projects overall time to create and test the whole thing in modern C++ or (I assume) in Rust should not take longer than in Python. I do not understand this idea of mixing languages where one is enough.<p>In my own case I rewrote decent size Python app in C++ and it had taken me about the same time as for original developers. And no I was not porting code but rather working with the specs so did my own design.
kartoolOzover 2 years ago
Sidenote, been using pinecone for semantic search recently, and it&#x27;s been a joyful experience.
theptipover 2 years ago
I&#x27;d be interested in a bit more detail on the technical migration strategy. Did they just cut over to a version of the project built in Rust? (I.e. vN is Python+C&#x2F;C++, vN+1 is Rust?) Or something more gradual?<p>How did they verify that the new code was conformant with the old app&#x27;s behavior&#x2F;logic?<p>&gt; To make matters worse, we would discover issues only after deploying (or in production!) due to Python’s run time nature.<p>I don&#x27;t want to infer too much, but this makes it sound like perhaps they didn&#x27;t have a very robust set of E2E&#x2F;Acceptance tests, which would make a full-cutover migration scary to me. If you&#x27;re finding Python bugs only after deploy, how can you find the inevitable rewritten-Rust-code incompatibilities before deploying&#x2F;production?<p>I&#x27;ve been digging into Rust&#x2F;Python interop recently using <a href="https:&#x2F;&#x2F;github.com&#x2F;PyO3&#x2F;pyo3" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;PyO3&#x2F;pyo3</a> and maturin, and this points to an interesting migration strategy; PyO3 makes it quite easy to write a Python module in Rust, or even call back and forth between them, so you could gradually move code from Python to Rust. A migration path to full-Rust might be:<p>1. Incrementally replace all your fast-path C&#x2F;C++ code with Rust, still having Python call these compiled modules. End-state: You now have a Python&#x2F;Rust project instead of Python&#x2F;C&#x2F;C++.<p>2. Gradually grow the surface area of your Rust packages, moving logic from Python into Rust. Your existing Python tests can still run, and your existing entrypoints are the same Python.<p>3. At some point, you presumably need to cut over the entrypoint layer (the API?) to use pure Rust, instead of Python. This should be a much less scary migration since both versions are calling into the same underlying Rust library code. Depending on your architecture, if you have an API Gateway you can split your service backends to migrate one endpoint at a time to the new Rust API service, while keeping the old Python API service around to fail back to. (They are using k8s so you can do this with your Ingress for example).<p>I&#x27;m interested in others&#x27; experiences with Rust&#x2F;Python interop, are there any rough edges worth knowing about?
ameliusover 2 years ago
Nice to see that Rust is working for your particular usecase!
AtNightWeCodeover 2 years ago
Dev velocity with new projects is often higher so I am not convinced by that argument.<p>With that said. I learned Rust recently. I think it is a viable choice for a business core. Rust is not at all that difficult to learn as some claim. The tuts are great. Some things are very different though.
liminalover 2 years ago
Any plans to open source the kv store?
4m1rkover 2 years ago
&gt; we would discover issues only after deploying (or in production!) due to Python’s run time nature<p>I love Rust but seems like they just needed to write some test before shipping to prod?<p>&gt; Built-in test, CI&#x2F;CD<p>Does it have anything to do with the language?
lucidguppyover 2 years ago
Python has built in testing and C++ has libraries like catch2. I would have liked some initial comment that said &quot;we had a good suite of tests&quot;. Python has plenty of benchmarking tools available.<p>IMHO - a db is all core. Everything should be fast. Even the CLI tools - Rust is pretty good at cli tools. Why is he building a database out of python? How much python is in this repo anyway?<p>Also this is a Python + C++ app - not python. And the article critiques python, not c++. Which is weird, because I would have thought the source of problems would have been C++ not python.<p>Don&#x27;t get me wrong - Rust is great. Cargo is great too. Compiled programs are great to deploy rather than python (pip hell) and C++ ({CMAKE_HELL}). But this is apples to oranges comparison.<p>The things that make Rust better than C++ &#x2F; Python are not the things this article talks about.
fb03over 2 years ago
Would you guys start a GraphQL Api today using Rust? I&#x27;m very tempted to hint at that but am still insecure about my &#x27;options&#x27;. This is coming from a very comfortable python + fastapi + sqlalchemy ecossystem
linsomniacover 2 years ago
The steps some people to go to to avoid writing tests is shocking. (I say this as someone who has written Python programs and been tired of deploying them only to find a runtime bug, and solved it by writing tests)
apiover 2 years ago
We&#x27;re rusting at the moment too. Encouraging. :)
shrubbleover 2 years ago
Has anyone ever compared Rust with Modula-2&#x2F;3 or Oberon family of languages? I would think it would be an interesting comparison.
bfrogover 2 years ago
This very closely matches my own experience nearly 4 or 5 years ago now rewriting an ad server in rust from another scripty language.
jmartin2683over 2 years ago
This is all directly in line with my experience having ported several production applications to Rust.
ncmncmover 2 years ago
Leading with several pages of what amounts to smug self-congratulation does not inspire finishing.<p>Rust deserves mention in the title only if actually getting it done in Rust was particularly difficult.
haskellandchillover 2 years ago
so how are graphs used for vector search?
评论 #32579682 未加载
whoomp12342over 2 years ago
;lkj
t6jvcereioover 2 years ago
&gt; We decided to move our entire codebase to Rust (and Go for the k8s control plane).<p>&gt; there was still one minor problem - no one on the team knew Rust.<p>Is this real or satire? I can&#x27;t tell.
评论 #32581130 未加载
评论 #32582238 未加载
kissgyorgyover 2 years ago
Expectation: this article.<p>Reality: It&#x27;s insanely hard to find talented developers, but Rust makes people excited, so they are just using it as a marketing tool.
ramozover 2 years ago
&gt; Simultaneous fetches of thousands (sometimes tens of thousands) of objects started becoming inefficient, especially when fetching from collections of tens of millions of objects<p>Why not try leveldb. We&#x27;re doing random reads of 170,000 vectors (&#x2F;130M) a second. No startup needed.
评论 #32579850 未加载
评论 #32579770 未加载