49 comments

  • rented_mule14 hours ago
    Something not unlike this happened to me when moving some batch processing code from C++ to Python 1.4 (this was 1997). The batch started finishing about 10x faster. We refused to believe it at first and started looking to make sure the work was actually being done. It was.<p>The port had been done in a weekend just to see if we could use Python in production. The C++ code had taken a few months to write. The port was pretty direct, function for function. It was even line for line where language and library differences didn&#x27;t offer an easier way.<p>A couple of us worked together for a day to find the reason for the speedup. Just looking at the code didn&#x27;t give us any clues, so we started profiling both versions. We found out that the port had accidentally fixed a previously unknown bug in some code that built and compared cache keys. After identifying the small misbehaving function, we had to study the C++ code pretty hard to even understand what the problem was. I don&#x27;t remember the exact nature of the bug, but I do remember thinking that particular type of bug would be hard to express in Python, and that&#x27;s exactly why it was accidentally fixed.<p>We immediately started moving the rest of our back end to Python. Most things were slower, but not by much because most of our back end was i&#x2F;o bound. We soon found out that we could make algorithmic improvements so much more quickly, so a lot of the slowest things got a lot faster than they had ever been. And, most importantly, we (the software developers) got quite a bit faster.
    • ameixaseca9 hours ago
      My experience is the exact opposite.<p>This was particularly true for one of the projects I&#x27;ve worked with in the past, where Python was chosen as the main language for a monitoring service.<p>In short, it proved itself to be a disaster: just the Python process collecting and parsing the metrics of all programs consumed 30-40% of the processing power of the lower end boxes.<p>In the end, the project went ahead for a while more, and we had to do all sorts of mitigations to get the performance impact to be less of an issue.<p>We did consider replacing it all by a few open source tools written in C and some glue code, the initial prototype used few MBs instead of dozens (or even hundreds) of MBs of memory, while barely registering any CPU load, but in the end it was deemed a waste of time when the whole project was terminated.
      • czhu123 hours ago
        Ditto for me. I had gotten so used to building web backends in Ruby and running at 700MB minimum. When I finally got around to writing a rust backend, it registered in the metrics as 0MB, so I thought for sure the application had crashed.<p>Turns out the metrics just rounded to the nearest 5MB
      • wiseowise6 hours ago
        &gt; but in the end it was deemed a waste of time when the whole project was terminated.<p>The main lesson of the story. Just pick Python and move fast, kids. It doesn’t matter how fast your software is if nobody uses it.
        • stephantul5 hours ago
          This is it. Getting something on the table for stakeholders to look at trumps anything else.
        • Aeolun2 hours ago
          You can use Go and get the best of both worlds.
          • nickserv57 minutes ago
            One of the slowest, most ineficient code bases I&#x27;ve ever worked on was in Go.<p>The mentality was &quot;the language is fast, so as long as it compiles we&#x27;re good&quot;... Yeah that worked out about as well as you&#x27;d expect.
        • littlestymaar4 hours ago
          And this is why pretty much all commercial software is terrible and runs slower than the equivalent 20 years ago despite incredible advance in hardware.
      • serial_dev7 hours ago
        Another anecdote, the team couldn’t improve concurrency reliably in Python, they rewrote the service in about a month (ten years ago) in Go, everything ran about 20x faster.
      • naasking1 hour ago
        &gt; just the Python process collecting and parsing the metrics of all programs consumed 30-40% of the processing power of the lower end boxes.<p>Just write the parsing loop in something faster like C or Rust, instead of the whole thing.
    • asveikau12 hours ago
      &gt; After identifying the small misbehaving function, we had to study the C++ code pretty hard to even understand what the problem was. I don&#x27;t remember the exact nature of the bug, but I do remember thinking that particular type of bug would be hard to express in Python, and that&#x27;s exactly why it was accidentally fixed.<p>Pure speculation, but I would guess this has something to do with a copy constructor getting invoked in a place you wouldn&#x27;t guess, that ends up in a critical path.
      • andrewflnr12 hours ago
        Given the context, I&#x27;m thinking bad cache keys resulting in spurious cache misses, where the keys are built in some low-level way. Cache misses almost certainly have a bigger asymptotic impact than extra copies, unless that copy constructor is really heavy.
        • asveikau12 hours ago
          I&#x27;m just remembering a performance issue I heard of eons ago where a sorting function comparison callback inadvertently allocated memory. It made sorting very slow. Someone said in a meeting that sorting was slow, and we all had a laugh about &quot;shouldn&#x27;t have used the bubble sort!&quot; But it was the key comparison doing something stupid.
      • branko_d2 hours ago
        My guess would be bad hashing, resulting in too many collisions.
      • NooneAtAll312 hours ago
        good ol&#x27; shallow-vs-deep copy
    • tda7 hours ago
      Ome advantage of python is that it is so slow that if you choose the wrong algorithm or data structure that soon gets obvious. And for complicated stuff this is exactly where I find the LLMs struggle. So I make a first version in Python, and only when I am happy with the results and the speed feels reasonable compared to the problem complexity, I ask Claude Code to port the critical parts to Rust.
      • rabisg7 hours ago
        The last part is really interesting. It feels like the whole world will soon become Python&#x2F;JS because thats what LLMs are good at. Very few people will then take the pain of optimizing it
        • eru4 hours ago
          The LLMs are pretty good at optimising.<p>Not because they are brilliant, but because they are pretty good at throwing pretty much all known techniques at a problem. And they also don&#x27;t tire of profiling and running experiments.
          • mirsadm26 minutes ago
            Not in my experience. They&#x27;re pretty good at getting average performance which is often better than most programmers seem to be willing to aim for.
          • elcritch4 hours ago
            Not just profiling, but decoding protocols too.<p>Recently I tried Codex&#x2F;GPT5 with updating a bluetooth library for batteries and it was able to start capturing bluetooth packets and comparing them with the libraries other models. It was indefatigable. I didn&#x27;t even know if was so easy to capture BLE packets.
            • anthk2 hours ago
              Wireshark would do that. But you need to understand low level tools because in case on some BGP attack you all LLM developers will be fired in the spot.<p>Flakey internet connection: most of current &#x27;soy devs&#x27; would be useless. Even more with boosted up chatbots.
        • 9rx32 minutes ago
          <i>&gt; JS because thats what LLMs are good at.</i><p>That&#x27;s not been my experience. JS&#x2F;TS requires the most hand-holding, by far. LLMs are no doubt assumed to be good at JS due to the sheer amount of training data, but a lot of those inputs are of really poor quality, and even among the high quality inputs there isn&#x27;t a whole lot of consistency in how they are written. That seems to trip up the LLMs. If anything, LLMs might finally be what breaks the JS camel&#x27;s back. Although browser dominance still makes that unlikely.<p><i>&gt; Very few people will then take the pain of optimizing it</i><p>Today&#x27;s LLMs rarely take the initiative to write benchmarks, but if you ask it will and then will iterate on optimizing using the benchmark results as feedback. It works fairly well. There is a conceivable near future where LLMs or LLM tools will start doing this automatically.
    • asa40013 hours ago
      Fun story! Performance is often highly unintuitive, and even counterintuitive (e.g. going from C++ to Python). Very much an art as well as a science.<p>Crazy how many stories like this I’ve heard of how doing performance work helped people uncover bugs and&#x2F;or hidden assumptions about their systems.
      • staticassertion8 hours ago
        It doesn&#x27;t come off as unintuitive by my read. They had a bug that led to a massive performance regression. Rewriting the code didn&#x27;t have that bug so it led to a performance improvement.<p>They found that they had fewer bugs in Python so they continued with it.
        • harpiaharpyja6 hours ago
          I think a lot of people (especially those who are only peripherally involved in development, like management) don&#x27;t really consider performance regressions at all when thinking about how to get software to go faster.<p>Meanwhile my experience has been that whenever there has been a performance issue severe enough to actually matter, it&#x27;s often been the result of some kind of performance bug, not so much language, runtime, or even algorithm choices for that matter.<p>Hence whenever the topic of how to improve performance comes up, I always, <i>always</i> insist that we profile first.
          • staticassertion6 hours ago
            My experience has been that performance bugs show up in lots of places and I&#x27;m very lucky when it&#x27;s just a bug. The far more painful performance issues are language and runtime limitations.<p>But, of course, profiling is always step one.
    • DaleBiagio13 hours ago
      [flagged]
      • Aurornis10 hours ago
        This comment comes from a bot account. One of the more clever ones I’ve seen that avoids some of the usual tells, but the comment history taken together exposes it.<p>I hit the flag button on the comment and suggest others do too.
      • furyofantares10 hours ago
        Thanks, Programming History Facts Bot<p>I was not actually sure this one was a bot, despite LLM-isms and, sadly, being new. But you can look at the comment history and see.
      • samiv10 hours ago
        Until at some point in a language like python all the things that allowed you write software faster start to slow you down like the lack of static typing and typing errors and spending time figuring out whether foo method works with ducks or quacks or foovars or whether the latest refactoring actually silently broke it because now you need bazzes instead of ducks. Yeah.
      • apitman12 hours ago
        I don&#x27;t think the better software part is playing out
        • ch4s311 hours ago
          There’s a lot of really great software out there right now, and a lot that’s terrible and I think powerful abstractions enable both.
        • remexre11 hours ago
          you&#x27;re thinking of the programs in low-level langs that survived their higher-level-lang competitors; if you plot the programs on your machine by age, how does the low quartile compare on reliability between programs written in each group
    • envguard13 hours ago
      [flagged]
    • shevy-java5 hours ago
      &gt; We immediately started moving the rest of our back end to Python. Most things were slower, but not by much because most of our back end was i&#x2F;o bound.<p>Would be kind of cool if e. g. python or ruby could be as fast as C or C++.<p>I wonder if this could be possible, assuming we could modify both to achieve that as outcome. But without having a language that would be like C or C++. Right now there is a strange divide between &quot;scripting&quot; languages and compiled ones.
      • nubg2 hours ago
        @dang this is an ai slop account, check his other comments
    • peter_retief5 hours ago
      I suspect that you used highly optimized algorithms written for python, like the vector algorithms in numpy? You will struggle to write better code, at least I would.
      • masklinn5 hours ago
        Python 1.4 would be mid-late 90s long before numpy and vector algorithms would have been available.<p>I suspect it’s more likely to be something like passing std::string by value not realising that would copy the string every time, especially with the statement that the mistake would be hard to express in Python.
        • johnisgood4 hours ago
          Everything is new to the uninitiated. :P
  • blundergoat16 hours ago
    The real win here isn&#x27;t TS over Rust, it&#x27;s the O(N²) -&gt; O(N) streaming fix via statement-level caching. That&#x27;s a 3.3x improvement on its own, independent of language choice. The WASM boundary elimination is 2-4x, but the algorithmic fix is what actually matters for user-perceived latency during streaming. Title undersells the more interesting engineering imo.
    • nulltrace14 hours ago
      Yeah the algorithmic fix is doing most of the work here. But call that parser hundreds of times on tiny streaming chunks and the WASM boundary cost per call adds up fast. Same thing would happen with C++ compiled to WASM.
      • hrmtst938376 hours ago
        WASM boundary overhead is only half the story. Once you start bouncing tiny chunks across JS and WASM over and over, the data shuffling and memory layout mismatch can trash cache behavior, pile on allocation churn, and turn a nice benchmark into something that looks nothing like a parser living inside a streaming pipeline. That&#x27;s why most &#x27;language duel&#x27; posts feel beside the point.
    • azakai14 hours ago
      O(N²) -&gt; O(N) was 3.3x faster, but before that, eliminating the boundary (replacing wasm with JS) led to speedups of 2.2x, 4.6x, 3.0x (see one table back).<p>It looks like neither is the &quot;real win&quot;. both the language and the algorithm made a big difference, as you can see in the first column in the last table - going to wasm was a big speedup, and improving the algorithm on top of that was another big speedup.
    • socalgal215 hours ago
      same for uv but no one takes that message. They just think &quot;rust rulez!&quot; and ignore that all of uv&#x27;s benefits are algo, not lang.
      • coldtea2 hours ago
        Just the fact that I can install a single binary is 10x better than an equally fast Python implementation.
      • estebank14 hours ago
        Some architectures are made easier by the choice of implementation language.
        • EdwardDiego9 hours ago
          UV also has the distinct advantage in dependency resolution that it didn&#x27;t have to implement the backwards compatible stuff Pip does, I think Astral blogged on it. If I can find it, I&#x27;ll edit the link in.<p><i>edit</i> wasn&#x27;t Astral, but here&#x27;s the blog post I was thinking of. <a href="https:&#x2F;&#x2F;nesbitt.io&#x2F;2025&#x2F;12&#x2F;26&#x2F;how-uv-got-so-fast.html" rel="nofollow">https:&#x2F;&#x2F;nesbitt.io&#x2F;2025&#x2F;12&#x2F;26&#x2F;how-uv-got-so-fast.html</a><p>That said, your point is very much correct, if you watch or read the Jane Street tech talk Astral gave, you can see how they really leveraged Rust for performance like turning Python version identifiers into u64s.
        • crubier13 hours ago
          In my experience Rust typically makes it a little bit harder to write the most efficient algo actually.
          • catlifeonmars10 hours ago
            That’s usually ok bc in most code your N is small and compiler optimizations dominate.
          • Defletter10 hours ago
            Would you be willing to give an example of this?
            • lukeweston12345 hours ago
              Not OP, but one example where it is a bit harder to do something in Rust that in C, C++, Zig, etc. is mutability on disjoint slices of an array. Rust offers a few utilities, like chunks_by, split_at, etc. but for certain data structures and algorithms it can be a bit annoying.<p>It&#x27;s also worth noting that unsafe Rust != C, and you are still battling these rules. With enough experience you gain an understanding of these patterns and it goes away, and you also have these realy solid tools like Miri for finding undefined behavior, but it can be a bit of a hastle.
            • foldr3 hours ago
              Mutating tree structures tends to be a fiddle (especially if you want parent pointers).
      • rowanG07714 hours ago
        That&#x27;s a pretty big claim. I don&#x27;t doubt that a lot of uv&#x27;s benefits are algo. But everything? Considering that running non IO-bound native code should be an order of magnitude faster than python.
        • jeremyjh13 hours ago
          Its a pretty well-supported claim. uv skips doing a number of things that generate file I&#x2F;O. File I&#x2F;O is far more costly than the difference in raw computation. pip can&#x27;t drop those for compatibility reasons.<p><a href="https:&#x2F;&#x2F;nesbitt.io&#x2F;2025&#x2F;12&#x2F;26&#x2F;how-uv-got-so-fast.html" rel="nofollow">https:&#x2F;&#x2F;nesbitt.io&#x2F;2025&#x2F;12&#x2F;26&#x2F;how-uv-got-so-fast.html</a>
          • staticassertion8 hours ago
            Do you actually believe that UV would be as fast if it were written in Python?
            • tinco6 hours ago
              It would come pretty close, probably close enough that you wouldn&#x27;t be able to tell the difference on 90% of projects.
              • staticassertion5 hours ago
                Vague. What&#x27;s pretty close? I mean, even for IO bound tasks you can pretty quickly validate that the performance between languages is not close at all - 10 to 100x difference.
                • tinco5 hours ago
                  Sure, within 100ms. Who cares what the performance multiples are?
                  • staticassertion5 hours ago
                    That literally makes no sense. 100ms... out of what? Is it 1ms vs 100ms? 100000ms vs 100100ms?<p>Anyway, dubious claim since a Python interpreter will take 10s of milliseconds just to print out its version.<p>Do you have any evidence? I can point at techempower benchmarks showing IO bound tasks are still 10-100x faster in native languages vs Python&#x2F;JS.
                    • tinco5 hours ago
                      I&#x27;m saying that the Rust might execute in 50ms and the Python in 150ms. You are the one not making sense, we are talking about application performance, why are you <i>not</i> measuring that in milliseconds.<p>That is assuming Rust is 100x faster than Python btw, 49ms of I&#x2F;O, 1ms of Rust, 100ms of Python.
                      • staticassertion1 hour ago
                        &gt; I&#x27;m saying that the Rust might execute in 50ms and the Python in 150ms.<p>Okay, so the Rust code would be 3x as fast. Feels arbitrary, but sure.<p>&gt; You are the one not making sense, we are talking about application performance, why are you not measuring that in milliseconds.<p>I explained why your post made no sense already...<p>&gt; That is assuming Rust is 100x faster than Python btw, 49ms of I&#x2F;O, 1ms of Rust, 100ms of Python.<p>That&#x27;s not how anything works. Different languages will perform differently on IO work, different runtimes will degrade under IO differently, etc. That&#x27;s why even basic echo HTTP servers perform radically differently in Python vs Rust.<p>This isn&#x27;t how computers work and it&#x27;s not even how math works.<p>This conversation has become nonsensical. The thing we can agree with is this - no, uv would not be as fast if it were written in Python.
                        • jeremyjh1 minute ago
                          &gt; Different languages will perform differently on IO work,<p>IO is done by kernel, file system or network drivers. It does not make any difference which language makes the syscalls.<p>&gt; The thing we can agree with is this - no, uv would not be as fast if it were written in Python.<p>In this thread, we are talking about the speed of uv in terms of user experience - how long a person waits for command line operations to complete. Things that pip takes multiple seconds to do, uv will do in dozens of milliseconds. If uv were written in python, it would take dozens of ms + a few dozens more, which means absolutely fuck all nothing in the context of the thousands of milliseconds saved over pip.<p>&gt; This conversation has become nonsensical.<p>Agreed. No one in this thread is disputing that Rust code is faster than Python, only that it is completely insignificant in the face of all the useless file and network I&#x2F;O that pip is doing. This is NOT a unique or special claim by the way.
          • rowanG07713 hours ago
            I don&#x27;t think the article you linked supports the claim that none of UV performance improvements are related to using rust over python at all. In fact it directly states the exact opposite. They have an entire section dedicated to why using Rust has direct performance advantages for UV.
            • jeremyjh11 hours ago
              What it says is this:<p>&gt; uv is fast because of what it doesn’t do, not because of what language it’s written in. The standards work of PEP 518, 517, 621, and 658 made fast package management possible. Dropping eggs, pip.conf, and permissive parsing made it achievable. Rust makes it a bit faster still.
              • rowanG07711 hours ago
                Yes exactly! That quote directly disproves that all of the improvements UV has over competitors is because of algos, not because of rust.<p>So the claim is not well supported at all by the article as you stated, in fact the claim is literally disproven by the article.
                • kyralis10 hours ago
                  This is either an overly pedantic take or a disingenuous one. The very first line that the parent quoted is<p>&gt; uv is fast because of what it doesn’t do, not because of what language it’s written in.<p>The fact that the language had a small effect (&quot;a bit&quot;) does not invalidate the statement that algorithmic improvements are the reason for the relative speed. In fact, there&#x27;s no reason to believe that rust without the algorithmic version would be notably faster at all. Sure, &quot;all&quot; is an exaggeration, but the point made still stands in the form that most readers would understand it: algorithmic improvements are the important difference between the systems.
                  • rowanG0779 hours ago
                    I think we might be talking past each other a bit.<p>The specific claim I was responding to was that all of uv’s performance improvements come from algorithms rather than the language. My point was just that this is a stronger claim than what the article supports, the article itself says Rust contributes “a bit” to the speed, so it’s not purely algorithmic.<p>I do agree with the broader point that algorithmic and architectural choices are the main reason uv is fast, and I tried to acknowledge that, apparently unsuccessfully, in my very my first comment (“I don&#x27;t doubt that a lot of uv&#x27;s benefits are algo. But everything?”).
                • jeremyjh11 hours ago
                  You are right. 99% is not 100%.
                  • rowanG07710 hours ago
                    I don&#x27;t think the article has substantive numbers. You&#x27;d have to re-implement UV in python to do that. I don&#x27;t think anyone did that. It would be interesting at least to see how much UV spends in syscalls vs PIP and make a relative estimate based on that.
        • thfuran13 hours ago
          More than one, I&#x27;d think.
    • catlifeonmars10 hours ago
      You’re not wrong, but that win would not get as many views. It’s not clickbaity enough
    • Aurornis15 hours ago
      &gt; Title undersells the more interesting engineering imo.<p>Thanks for cutting through the clickbait. The post is interesting, but I&#x27;m so tired of being unnecessarily clickbaited into reading articles.
    • sroussey15 hours ago
      Yeah, though the n^2 is overstating things.<p>One thing I noticed was that they time each call and then use a median. Sigh. In a browser. :&#x2F; With timing attack defenses build into the JS engine.
      • fn-mote14 hours ago
        For those of us not in the know, what are we expecting the results of the defenses to be here?
        • sroussey9 hours ago
          Jitter. It make precise timings unreliable. Time the entire time of 1000 runs and divide by 1000 instead of starting and stopping 1000 timers.
    • adastra228 hours ago
      No AI generated comments on HN please.
    • shmerl15 hours ago
      More like a misleading clickbait.
    • wolvesechoes3 hours ago
      &gt; The real win here isn&#x27;t TS over Rust<p>Kinda is. We came up with abstractions to help reason about what really matters. The more you need to deal with auxillary stuff (allocations, lifetimes), more likely you will miss the big issue.
      • coldtea2 hours ago
        The opposite: the more you rely on abstractions the more you miss the lower level optimization opportunities and loose understanding of algorithms and hardware.
        • wolvesechoes2 hours ago
          &gt; of algorithms<p>Yes, sprinkling your code logic with malloc, .clone() or lifetime annotations on the other hand brings algorithmic enlightenment.
  • simonbw11 hours ago
    Yeah if you&#x27;re serializing and deserializing data across the JS-WASM boundary (or actually between web workers in general whether they&#x27;re WASM or not) the data marshaling costs can add up. There is a way of sharing memory across the boundary though without any marshaling: TypedArrays and SharedArrayBuffers. TypedArrays let you transfer ownership of the underlying memory from one worker (or the main thread) to another without any copying. SharedArrayBuffers allow multiple workers to read and write to the same contiguous chunk of memory. The downside is that you lose all the niceties of any JavaScript types and you&#x27;re basically stuck working with raw bytes.<p>You still do get some latency from the event loop, because postMessage gets queued as a MacroTask, which is probably on the order of 10μs. But this is the price you have to pay if you want to run some code in a non-blocking way.
    • osullivj8 hours ago
      Strongly agree from an Emscripten C++ wasm pov: it&#x27;s key to minimise emscripten::val roundtrips. Caches must be designed for rectilinear data geometry, and SharedArrayBuffers are the way for bulk data. But only JS allows us to express asynchrony, so we need an on_completion callback design at the lang boundary.
      • tankenmate3 hours ago
        Indeed a whole class of issues become moot if you just don&#x27;t use javascript anywhere. In the browser world this is obviously difficult&#x2F;impossible; I look forward to the day when WASM can run natively in a browser and doesn&#x27;t need javascript at all, DOM, network, etc, etc. On the server side? Just steer clear of the javascript ecosystem altogether.
    • fHr2 hours ago
      So the actual processing is faster in rust&#x2F;c&#x2F;c++ but the marshaling costs are so big so ts is faster in this case? No vlue how something like swc does this but there it&#x27;s way faster then babel.
    • jesse__9 hours ago
      This should be the top comment
  • nine_k15 hours ago
    &quot;We rewrote this code from language <i>L</i> to language <i>M</i>, and the result is better!&quot; No wonder: it was a chance to rectify everything that was tangled or crooked, avoid every known bad decision, and apply newly-invented better approaches.<p>So this holds even for <i>L = M</i>. The speedup is not in the language, but in the rewriting and rethinking.
    • MiddleEndian15 hours ago
      Now they just need a third party who&#x27;s never seen the original to rewrite their TypeScript solution in Rust for even more gains.
      • nine_k15 hours ago
        Indeed! But only after a year or so of using it in production, so that the drawbacks would be discovered.
    • azakai14 hours ago
      You&#x27;re generally right - rewrites let you improve the code - but they do have an actual reason the new language was better: avoiding copies on the boundary.<p>They say they measured that cost, and it was most of the runtime in the old version (though they don&#x27;t give exact numbers). That cost does not exist at all in the new version, simply because of the language.
      • necovek4 hours ago
        It&#x27;s doing copies and (de)serialization on both sides into native data types.<p>If they used raw byte structures, implemented the caching improvements on the wasm side, the copies might not be as bad.<p>But they still have an issue with multi-language stack: complexity also has a cost.<p>Python&#x2F;C combo does not have this issue because you can work with Python types natively in C, but otherwise, this is a cross-language conversion issue, and not a Rust issue at all.
    • rabisg7 hours ago
      One of the authors here. While that’s generally true, in this case it wasn’t time that helped us learn what worked. It was a nagging sense that the architecture wasn’t right, just days before launch, along with heavy instrumentation to test our assumptions.
    • baranul15 hours ago
      Truth. You can see improvement, even rewriting code in the same language.
    • johnisgood4 hours ago
      I have been saying this for a while now (thought it was obvious), and often I get downvoted when I point this out.
    • awesome_dude12 hours ago
      I think that they were honest about that to a degree, they pointed out that one source of the speed up was caused by the python fixing a big they hadn&#x27;t noticed in the C++<p>Edit: fixed phone typos
  • moomin2 hours ago
    “We saw huge speed-ups when changing technology.”<p>Looks inside<p>“The old implementation had some really inappropriate choices.”<p>Every time.
  • evmar15 hours ago
    By the way, I did a deeper dive on the problem of serializing objects across the Rust&#x2F;JS boundary, noticed the approach used by serde wasn’t great for performance, and explored improving it here: <a href="https:&#x2F;&#x2F;neugierig.org&#x2F;software&#x2F;blog&#x2F;2024&#x2F;04&#x2F;rust-wasm-to-js.html" rel="nofollow">https:&#x2F;&#x2F;neugierig.org&#x2F;software&#x2F;blog&#x2F;2024&#x2F;04&#x2F;rust-wasm-to-js....</a>
    • slopinthebag13 hours ago
      Did you try something like msgpack or bebop?
  • spankalee15 hours ago
    I was wondering why I hadn&#x27;t heard of Open UI doing anything with WASM.<p>This new company chose a very confusing name that has been used by the Open UI W3C Community Group for over 5 years.<p><a href="https:&#x2F;&#x2F;open-ui.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;open-ui.org&#x2F;</a><p>Open UI is the standards group responsible for HTML having popovers, customizable select, invoker commands, and accordions. They&#x27;re doing great work.
  • pjmlp2 hours ago
    This is why, when a programming language already has tooling for compilers, being it ahead of time, or dynamic, it pays off to first go around validating algorithms and data structures before a full rewrite.<p>Additionally even after those options are exhausted, only a key parts might need a rewrite, not the whole thing.<p>However, I wonder how many care about actually learning about algorithms, data structures and mechanical sympathy in the age of Electron apps.<p>It feels quite often that a rewrite is chosen, because knowing how to actually apply those skills is the CS stuff many think isn&#x27;t worthwhile learning about.
    • coldtea2 hours ago
      &gt;<i>However, I wonder how many care about actually learning about algorithms, data structures and mechanical sympathy in the age of Electron apps.</i><p>Never mind the age of Electron apps, even fewer care about those in the age of agents.
      • pjmlp2 hours ago
        Agreed, however I would assert that in the age of agents, programming languages will become irrelevant to most, other those lucky enough druids to write AI runtime stack, at the AI overlords.<p>And those will still care about CS.
  • joaohaas14 hours ago
    God I hate AI writing.<p>That final summary benchmark means nothing. It mentions &#x27;baseline&#x27; value for the &#x27;Full-stream total&#x27; for the rust implementation, and then says the `serde-wasm-bindgen` is &#x27;+9-29% slower&#x27;, but it never gives us the baseline value, because clearly the only benchmark it did against the Rust codebase was the per-call one.<p>Then it mentions: &quot;End result: 2.2-4.6x faster per call and 2.6-3.3x lower total streaming cost.&quot;<p>But the &quot;2.6-3.3x&quot; is by their own definition a comparison against the naive TS implementation.<p>I really think the guy just prompted claude to &quot;get this shit fast and then publish a blog post&quot;.
    • chvish8 hours ago
      This. It’s so annoying to read these types of blogs now where the writer clearly didn’t put the effort to understand things fully or atleast review the blog their LLM wrote. Who is this useful for?
    • rabisg6 hours ago
      as an author of the blog - ouch did a little bit more than prompt claude but a lot of claude prompting was definitely involved<p>I understand your frustration with AI writing though. We are a small team and given our roadmap it was either use LLMs to help collate all the internal benchmark results file into a blog or never write it so we chose the former. This was a genuinely surprising and counterintuitive result for us, which is why we wanted to share it. Happy to clarify any of the numbers if helpful.
    • JimDabell8 hours ago
      The article as a whole makes no sense. They are generating UI with an LLM. How fast the UI appears to the user is going to be completely dictated by the speed of the LLM, not the speed of the serialisation.
  • LunaSea2 hours ago
    This has been known by Node.js developers for a while with many C++ core and NPM modules being rewritten in JavaScript to improve performance.
  • athrowaway3z8 hours ago
    Its also worth underlining that it&#x27;s not just &quot;The parsing computation is fast enough that V8&#x27;s JIT eliminates any Rust advantage&quot;, but specifically that this kind of straight-forward well-defined data structures and mutation, without any strange eval paths or global access is going to be JITed to near native speed relatively easily.
  • gettingoverit2 hours ago
    In ye olden days of WASM just added to the browser, the difference between native JS and boost::spirit in WASM was x200.<p>In their worst case it was just x5. We clearly have some progress here.
  • Dwedit5 hours ago
    JS and WASM share the main arraybuffer. It&#x27;s just very not-javascript-like to try to use an arraybuffer heap, because then you don&#x27;t have strings or objects, just index,size pairs into that arraybuffer.<p>Anyway, Javascript is no stranger to breaking changes. Compare Chromium 47 to today. Just add actual integers as another breaking change, then WASM becomes almost unnecessary.
  • vmsp13 hours ago
    Not directly related to the post but what does OpenUI do? I&#x27;m finding it interesting but hard to understand. Is it an intermediate layer that makes LLMs generate better UI?
    • rabisg6 hours ago
      Its the library that bridges the gap between LLMs and live UI. Best example would be to imagine you want to build interactive charts within your AI agent (like Claude)<p>The most obvious approach would be to let LLMs generate code and render it but that introduces problems like safety, UI consistency and speed. OpenUI solves those problems and provides a safe, consistent and token optimized runtime for the LLMs to render live UI
      • aquariusDue2 hours ago
        Is it kinda similar to the new GenUI SDK for Flutter in that sense?<p><a href="https:&#x2F;&#x2F;docs.flutter.dev&#x2F;ai&#x2F;genui" rel="nofollow">https:&#x2F;&#x2F;docs.flutter.dev&#x2F;ai&#x2F;genui</a>
        • rabisg34 minutes ago
          Haven&#x27;t looked in depth but yes it feels like they are solving the same problem.<p>This is an alternative to json-render by Vercel or A2UI by Google which I&#x27;m guessing the flutter implementation is based on
  • jeremyjh13 hours ago
    &gt; The openui-lang parser converts a custom DSL emitted by an LLM into a React component tree.<p>&gt; converts internal AST into the public OutputNode format consumed by the React renderer<p>Why not just have the LLM emit the JSON for OutputNode ? Why is a custom &quot;language&quot; and parser needed at all? And yes, there is a cost for marshaling data, so you should avoid doing it where possible, and do it in large chunks when its not possible to avoid. This is not an unknown phenomenon.
  • horacemorace10 hours ago
    I’m more of a dabbler dev&#x2F;script guy than a dev but Every. single. thing I ever write in javascript ends up being incredibly fast. It forces me to think in callbacks and events and promises. Python and C (or async!) seem easy and sorta lazy in comparison.
  • bulbar5 hours ago
    Is this an outlier or has Rust started to be part of the establishment and being &#x27;old&#x27; so that people want to share their &quot;moving away from Rust&quot; stories?<p>I didn&#x27;t mind reading articles that are not about how Rust is great in theory (and maybe practice).
    • zozbot2344 hours ago
      This story is about moving away from WASM for an application that&#x27;s unsuitable for it. It&#x27;s not really about Rust.
    • quotemstr5 hours ago
      There&#x27;s a certain segment of the industry that&#x27;s always chasing the newest thing. Many of them like Zig for some ghastly reason.<p>That said, Rust does have real problems. Manual memory management <i>sucks</i>. People think GC is expensive? Well, keep in mind malloc() and free() take global locks! People just have totally bogus mental models of what drives performance. These models lead them to technical nonsense.
  • jesse__9 hours ago
    This somehow reminds me of the days when the fastest way to deep copy an object in javascript was to round trip through toString. I thought that was gross then, and I think this is gross now
  • slopinthebag13 hours ago
    This article is obviously AI generated and besides being jarring to read, it makes me really doubt its validity. You can get substantially faster parsing versus `JSON.parse()` by parsing structured binary data, and it&#x27;s also faster to pass a byte array compared to a JSON string from wasm to the browser. My guess is not only this article was AI generated, but also their benchmarks, and perhaps the implementation as well.
    • StilesCrisis13 hours ago
      It&#x27;s vibe code all the way down!
  • mwcampbell8 hours ago
    I hope we can still get to a point where wasm modules can directly access the web platform APIs and get JS out of the picture entirely. After all, those APIs themselves are implemented in C++ (and maybe some Rust now).
  • sakesun10 hours ago
    I heard a lot of similar stories in the past when I started using Python 20+ years ago. A number of people claimed their solutions got faster when develop in Python, mainly because Python make it easier to quickly pivot to experiment with various alternative methods, hence finally yield at more efficient outcome at the end.
  • envguard13 hours ago
    The WASM story is interesting from a security angle too. WASM modules inheriting the host&#x27;s memory model means any parsing bugs that trigger buffer overreads in the Rust code could surface in ways that are harder to audit at the JS boundary. Moving to native TS at least keeps the attack surface in one runtime, even if the theoretical memory safety guarantees go down.
  • ivanjermakov14 hours ago
    Good software is usually written on 2nd+ try.
  • nallana14 hours ago
    Why not a shared buffer? Serializing into JSON on this hot path should be entirely avoidable
    • mavdol0413 hours ago
      I think a shared array just avoids the copy, not the serialization which is the main problem as they showed with serde-wasm-bindgen test
    • devnotes7714 hours ago
      [dead]
  • owenpalmer12 hours ago
    So this is an issue with WASM&#x2F;JS interop, not with Rust per se?
  • nssnsjsjsjs14 hours ago
    Rewrite bias. Yoy want to also rewrite the Rust one in Rust for comparison.
    • jeremyjh13 hours ago
      It would be surprising if rewriting in Rust could change the WASM boundary tax that the article identified as the actual problem.
      • rabisg6 hours ago
        (author here) We&#x27;d be really surprised if a rewrite could fix the boundary tax but if it does, we&#x27;d happily move over to it. People (including me) really underestimate how insanely fast browser&#x27;s JSON.parse is
  • dmix15 hours ago
    That blog post design is very nice. I like the &#x27;scrollspy&#x27; sidebar which highlights all visible headings.<p>Claude tells me this is <a href="https:&#x2F;&#x2F;www.fumadocs.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.fumadocs.dev&#x2F;</a>
    • sroussey15 hours ago
      Interesting, thanks. I need make some good docs soon.
      • dmix15 hours ago
        Good documentation is always worth the effort. Markdown explaining your products is gold these days with LLMs.
    • rabisg6 hours ago
      [dead]
  • bluelightning2k1 hour ago
    Great write up. It feels like craft in the age of slop.<p>Not sold about the fundamental idea of OpenUI though. XML is a great fit for DSLs and UI snippets.
    • rabisg30 minutes ago
      We tried all formats - XML, json, jsonl, even toon - before deciding that we need to invest in OpenUI Lang<p>The primary motivation was speed and schema cohesion. We were running a JSON based format, Thesys C1, in production for a year before we realized we cannot add features fast enough because we were fighting the LLMs at multiple levels. It&#x27;s probably too much to write in a comment but we&#x27;d like to write about the motivation and all the things we tried ona a separate blog soon
    • twoodfin1 hour ago
      Are you kidding? To the extent this was “crafted” it was by an LLM from somebody’s notes in a prompt.<p>The other day, someone linked back to this 2018 post on finding a cache coherency bug in the Xbox 360 CPU:<p><a href="https:&#x2F;&#x2F;randomascii.wordpress.com&#x2F;2018&#x2F;01&#x2F;07&#x2F;finding-a-cpu-design-bug-in-the-xbox-360&#x2F;" rel="nofollow">https:&#x2F;&#x2F;randomascii.wordpress.com&#x2F;2018&#x2F;01&#x2F;07&#x2F;finding-a-cpu-d...</a><p>So much more genuinely engaging than <i>any</i> of the AI-“enhanced” sloppy, confused, trite writing that gets to the front page here daily because it’s been hyper-optimized for upvotes.
  • kennykartman13 hours ago
    I dream of the day in which there is no need to pass by JS and Wasm can do all the job by itself. Meanwhile, we are stuck.
  • marcosdumay13 hours ago
    It would be great if people stopped dismissing the problem that WASM not being a first-class runtime for the web causes.
  • caderosche15 hours ago
    What is the purpose of the Rust WASM parser? Didn&#x27;t understand that easily from the article. Would love a better explanation.
    • joshuanapoli14 hours ago
      They use a bespoke language to define LLM-generated UI components. I think that this is supposed to prevent exfiltration if the LLM is prompt-injected. In any case, the parser compiles chunks streaming from the LLM to build a live UI. The WASM parser restarted from the beginning upon each chunk received. Fixing this algorithm to work more incrementally (while porting from Rust to TypeScript) improved performance a lot.
  • fHr2 hours ago
    I almost can&#x27;t believe this swc for example is 80x faster then babeljs.
  • shevy-java5 hours ago
    So ...<p>Rust.<p>WASM.<p>TypeScript.<p>I am slowly beginning to understand why WASM did not really succeed.
  • szmarczak14 hours ago
    &gt; Attempted Fix: Skip the JSON Round-Trip &gt; We integrated serde-wasm-bindgen<p>So you&#x27;re reinventing JSON but binary? V8 JSON nowadays is highly optimized [1] and can process gigabytes per second [2], I doubt it is a bottleneck here.<p>[1] <a href="https:&#x2F;&#x2F;v8.dev&#x2F;blog&#x2F;json-stringify" rel="nofollow">https:&#x2F;&#x2F;v8.dev&#x2F;blog&#x2F;json-stringify</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;simdjson&#x2F;simdjson" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;simdjson&#x2F;simdjson</a>
    • kam13 hours ago
      No, serde-wasm-bindgen implements the serde Serializer interface by calling into JS to directly construct the JS objects on the JS heap without an intermediate serialization&#x2F;deserialization. You pay the cost of one or more FFI calls for every object though.<p><a href="https:&#x2F;&#x2F;docs.rs&#x2F;serde-wasm-bindgen&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;serde-wasm-bindgen&#x2F;</a>
      • szmarczak3 hours ago
        Indeed, you&#x27;re right. However, it still needs to encode and decode strings. WASM just needs native interop.
  • measurablefunc11 hours ago
    I tried a similar experiment recently w&#x2F; FFT transform for wav files in the browser and javascript was faster than wasm. It was mostly vibe coded Rust to wasm but FFT is a well-known algorithm so I don&#x27;t think there were any low hanging performance improvements left to pick.
    • wintermute428259 minutes ago
      It looks like FFTW3 is working on wasm support: <a href="https:&#x2F;&#x2F;github.com&#x2F;FFTW&#x2F;fftw3&#x2F;issues&#x2F;293" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;FFTW&#x2F;fftw3&#x2F;issues&#x2F;293</a><p>You could also try pretty fast fft: <a href="https:&#x2F;&#x2F;github.com&#x2F;JorenSix&#x2F;pffft.wasm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;JorenSix&#x2F;pffft.wasm</a>
  • slowhadoken14 hours ago
    Am I mistaken or isn’t TypeScript just Golang under the hood these days?
    • jeremyjh13 hours ago
      There is too much wrong here to call it a mistake.
    • iainmerrick14 hours ago
      Hmm, there&#x27;s an in-progress rewrite of the TypeScript compiler in Go; is that what you mean?<p>I don&#x27;t think that&#x27;s actually out yet, and more importantly, it doesn&#x27;t change anything at runtime -- your code still runs in a JS engine (V8, JSC etc).
      • koakuma-chan12 hours ago
        npm i -D @typescript&#x2F;native-preview<p>You can use it today.
  • wangnaihe5 minutes ago
    [dead]
  • arthurjean32 minutes ago
    [dead]
  • Yanko_115 hours ago
    [dead]
  • dualblocksgame13 hours ago
    [dead]
  • derodero2411 hours ago
    [dead]
  • DaleBiagio13 hours ago
    [dead]
  • aimarketintel11 hours ago
    [dead]
  • patapim14 hours ago
    [dead]
  • SCLeo14 hours ago
    They should rewrite it in rust again to get another 3x performance increase &#x2F;s
  • ConanRus13 hours ago
    [dead]
  • neuropacabra14 hours ago
    This is very unusual statement :-D