The AI cost of JavaScript frameworks

(nolanlawson.com)

97 points | by luu 5 hours ago

24 comments

  • jvanveen 22 minutes ago
    Besides a rewrite to another framework using AI, another option is to modernize the framework with AI instead. Personally, I started to like Mithril after having worked with it for a few years. Instead of rewriting it to a better maintained alternative (mithril doesn't have much active development going on since 2015), I used agents to add signals, proper state management, typing, ssr, computed properties, Bun tooling and more to it. Thanks to the existing test suite, changes landed quite reliably. Source: https://code.garage44.eu/jeroen/mithril
    • noiv 3 minutes ago
      Yes, Mithril enhanced with signals feels very efficient und saves tokens.
  • torginus 7 minutes ago
    It's astonishing to me that even after a decade of SPA frameworks, most authors don't understand how a browser engine like Chrome works. There's enormous cost of manipulating the DOM from JS, as HTML elements get bound to JS objects lazily.

    An actual high performance framework should manipulate HTML as a string directly, or through HTML templates (another feature that has existed in most browsers for a decade).

    If you're not building a complex application on top of the web stack (interestingly these increasingly use WASM and their own GUI frameworks, so another moot point), but building an interactive consumption website (scrollable lists of static contents), I'd say instead of fronted frameworks, what most people actually would need is Chrome's experimental declarative partial updates:

    https://developer.chrome.com/docs/web-platform/declarative-p...

    Which basically stream HTML fragments from the web.

    • Devasta 0 minutes ago
      They don't care. The big selling point besides being able to run on every platform is that users understand there is no reasonable expectation of quality when it comes to the web. If a desktop application freezes up and crashes, users will gnash their teeth and curse your name while they are pressing ctrl-alt-del and trying to get their system going again. A massive pile of react slop? Just shrug and refresh the page.
  • shermantanktop 1 hour ago
    This is buried at the end.

    > My goal here is not to write the end-all-be-all benchmark for “I’m a vibe-coder, which framework should I choose?” The point of this post is to demonstrate that it’s possible in the era of AI coding to still make decisions based on evidence rather than vibes.

    But it’s obvious that the article will be understood as a useful benchmark, so author probably should have addressed that point earlier and more thoroughly.

    Taking the authors pov for a moment, they just showed you how to put all your criticisms to work in making a newer better benchmark :)

  • neya 3 hours ago
    This benchmark is too simplified to be meaningful. The choice of a framework is rarely based on speed alone, it factors in other elements like the user's domain knowledge, long term maintainability and the framework's track record itself w.r.t security and development of features.

    In this regard alone, it will make a lot of sense to spend extra $2 and 2 mins to trade off for a long-term maintainable codebase and code you can reason about than just something made quickly just to get it deployed fast.

    In my personal use case, that would be Svelte 5 for me and I'm sure it will be something else for everyone.

  • unsloppable 1 hour ago
    HTMX is interesting.

    I have most of my apps in it without much trouble.

    One of my recent ones had a very complicated form and state management.

    AI really struggled with HTMX in that use case.

    Like the form might work but the page would take 30s to load. Or some state would randomly drop or a toggle wouldn't work after changing a dependency.

    If I rewrote that in react it would have one shot it without a doubt. Some things are just better models for different problems.

    For the record I eventually got enough tests in place to keep the agent honest and the HTMX version is now a lot faster anything I could have got out of react but yeah, it was an adventure.

    • whatthejesus 1 hour ago
      I judge languages by how they look. JavaScript is a wall of const/async/await these days, which is ugly. Functionality aside (the APIs have gotten pretty decent), the language has gotten uglier. It used to be nice and nuanced even with boilerplate. Closures and prototype inheritance is neat. Walls of const are not. Does every enclosed function need a million consts for every expression?

      Also, it’s a language where everything happens somewhere else. Not here and now, somewhere else on some other event. That sucks for the small stuff.

      • unsloppable 1 hour ago
        I am still 95% sure async/await was a mistake.

        Async JavaScript using callbacks had a learning curve, but once you learned how to contain it and treat callback indentation as an opportunity to refactor it felt similar to coding in lisp.

        The problem was the learning curve, and the fact you had to rewire your brain a bit compared to coding in something procedural.

        • torginus 34 minutes ago
          Yes, I keep saying this. Async await is like loading spinners - a fix for a problem that shouldn't exist in the first place.

          As much as possible should be happening locally, synchronously on the computer, in-process, or at least without yielding your thread context (and even then there are things like page faults which async/await wont save you from, they are 'invisible' to a regular developer).

          While you might dismiss this idea, page faults used to be THE leading cause of delays back when hard drives were the norm.

  • tancop 3 hours ago
    Astro comes out on top with the best time, #2 lowest spend and zero client side JS. I know what I'm using for my next project.
    • skrebbel 2 hours ago
      It scores well here because Astro is for “content-driven websites” and that’s what the benchmark app was. I’d be curious how different the results would be if the app was highly interactive, with nontrivial realtime/async stuff going on etc.
      • elxr 58 minutes ago
        Agreed. Go with solidstart (who just released a big V2 upgrade a few months back) if you want an extremely elegant solution to async, error handling and heavily concurrent behaviors.

        Very easy to setup and way more readable than the equivalent React code.

      • csnweb 1 hour ago
        And then you just use your favorite js framework with Astro and it will still be good. I use Astro with react and heroui a lot. Since the latter does not need any js for many components anymore you still get zero js builds unless you actually need interactivity.
    • vermilingua 3 hours ago
      Can confirm Astro is very very pleasant to use, and the escape hatches for when you do need something a bit more heavy hitting feel very well designed.
    • andybak 1 hour ago
      > I know what I'm using for my next project.

      Django?

    • truetraveller 3 hours ago
      next project? pun of the year?
  • mmusc 2 hours ago
    Java script frameworks are just extra boiler plate that isn't needed in the age of ai-coding.

    Server side page generation with a sprinkle of js will give you the same results with GBS less of packages and comple time

    • Joeri 2 hours ago
      The vanilla advantage is also there in a pure client-side pwa. Arguably it’s even bigger, because the bundle size ends up way smaller and the agent needs to hold less in context.

      Plus all the other vanilla advantages: fewer dependencies, lower maintenance, less retraining, etc…

    • andai 2 hours ago
      I'm reading that agents can now mash up video games that were written in assembly. At that point I have to wonder if the abstractions are adding anything.

      Of course, there is the question of "the human can still understand what is going on", but it's not clear the new frameworks are optimizing for that...

      • conartist6 2 hours ago
        [flagged]
        • andai 2 hours ago
          LOL
          • conartist6 2 hours ago
            I mean maybe I'm too grumpy, but never in my life did I think I'd have to fight against a strong contingent of people who really don't see the value of abstraction. Taking crazy pills must feel like this.
            • imtringued 1 hour ago
              Your mistake is trying to fight people. You don't have to do that. You can just let them suffer from the consequences of their own decisions.
    • realusername 42 minutes ago
      They also were unnecessary even before AI, the biggest advantage of React over HTMX-style apps was that you could recruit someone more easily but the SPA complexity wasn't worth it and it scaled terribly.

      Now that you don't write the code now, I don't see why I would pick React style libraries unless the codebase is already there.

      • io4throwaway 1 minute ago
        We just write different stuff. For content driven websites you can skip js frameworks altogether. For web apps it would not be a good idea.

        It's all about how much interactivity you need. A lot of business web apps are full featured commercial software packed in SPA form. You will need a lot of stuff client side and without framework it will be a mess. Unless you write framework yourself but the you are reinventing a wheel.

  • iperov 2 hours ago
    > in the agentic era, when developers are no longer typing code by hand

    I hope I'll be the last person on Earth writing code by hand.

    • Culonavirus 1 hour ago
      Plenty of people will be coding by hand for years to come. They just wont be employed for doing so.
      • iperov 49 minutes ago
        Thank the gods, nobody's forcing me to be employed.
    • ArcHound 2 hours ago
      Neocities ride hard on the old-internet hand-crafted HTML aesthetic. Maybe we could start a similar club?
  • ivanjermakov 1 hour ago
    The point of using a framework is to reduce mental load at expense of customizability. The moment you need to change something in the framework - this mental model falls apart.

    Obvious solutions are to vendor your dependencies (compile the framework from owned source) or to drop to the lower level of abstraction.

    LLMs should have no problem using browser/node APIs directly since they're very well used, well documented, and not changing as much as higher level software does.

  • samayashar 1 hour ago
    Solid work, but it would be really cool if we can also test Pokemon motions and how the game responds in real-time. Is an agent able to think about reactions, directional movements and attack patterns of each Pokemon is where the real intelligence test lies.

    Traditional languages may have their limitations, but [C++, Rust, JavaScript, TypeScript etc] can still do pretty well.

  • iammrpayments 3 hours ago
    Interesting, I’m just sad svelte didnt behave better because of the LLM reading migration guide on every answer
  • andai 2 hours ago
    Interesting article. Kind of seems like you'd want a more complex task, there's not much differentiation here.
  • genshii 3 hours ago
    Glad to see Astro doing well here. It's by far my favorite way to build sites of all kinds, both content rich MPAs, and react heavy web apps.
  • jawngee 2 hours ago
    Nice to see Nuxt holding its own. Astro or Nuxt are my gotos for client work and personal projects.
  • chvid 2 hours ago
    It is fairly obvious that it is all going to be some kind of React/JSX with tailwind.
    • etatester 1 hour ago
      It's definitely all tail wind
  • injidup 1 hour ago
    my experience is that one-shotting a simple front end works great. Then you want to add features and move things around and each turn starts getting slower and the single page with JS and CSS and HTML starts to turn into a 3000 line monster and your context window starts to creak under the strain of even simple changes, because the LLM has to keep more and more of the application in its head just to make relatively small changes without breaking something else. Either you should have started with some kind of framework with hygienic rules on how to separate concerns or at minimum a good set of coding standards that force the LLM to start building clean components from scratch. The benefit isn't necessarily cleaner code for its own sake, it's that the LLM can work on one part of the application without having to understand the whole thing every time. That being said, once you have a 3000 line prototype it's not that complex to simply ask the LLM to refactor it into a set of orthogonal components. As long as it was building unit tests using playwright or something this can turn your slop into framework code cleanly. The interesting question is whether you saved anything by putting off that structure in the first place.

    I run into this problem turning claude artifacts into things I might want to maintain longer term.

  • usernametaken29 3 hours ago
    Angular sucks, I always knew it, and now we have some data that it’s broken even for agents. I’m not surprised
    • ozim 2 hours ago
      > The Pokémon app is small and doesn’t represent a large, complex real-world application.

      If you aim to make small apps that don’t represent complex real-world applications you should not use Angular.

      But blanket statements like yours are what I hate the most in software industry.

    • alex_suzuki 1 hour ago
      When I was running a small dev agency with a sprinkling of web projects, Angular was useful because it every project looked more or less the same. The rigidity (and verbosity) it imposed was an advantage in this setting, as it helped with the cognitive load when switching between projects. Apart from that, I wasn’t a fan either.
    • Aozora7 1 hour ago
      I suspect that results would be different if the app was a bunch of boring forms with complex validation rules, which is often encountered in jobslop.

      Not necessarily that Angular would win that, but I imagine that it would at least significantly shuffle the order.

  • borzi 1 hour ago
    I mean it just seems like even in the agentic era, you should know when to use the right tool for the right job. The site shown seems perfect for htmx style websites, so idk why you would use an SPA. Still very cool experiment, appreciate the data and human writing!
  • electroplankton 2 hours ago
    where is jquery? :(
  • drnick1 3 hours ago
    Just use plain HTML for God's sake. HN demonstrates very well that you can do plenty without some Javascript monstrosity. At the very least, make your your websites degrades gracefully when JS is turned off.
    • bazoom42 2 hours ago
      HN uses JavaScript though, not just plain HTML.
      • stephbook 2 hours ago
        And it certainly doesn't do "plenty."
      • phil-pickering 1 hour ago
        HN is perfectly usable without JavaScript enabled.

        The only feature that appears to require JavaScript is search.

    • r_lee 3 hours ago
      "do plenty" or just use React for everything and have a single thing where you don't need to worry about the limitations or having to remake the same stuff the framework provides?

      and what % of users have JS turned off? 0.00001%?

    • andybak 1 hour ago
      At least one (or maybe two depending how you define things) of the examples does that. Because you mean "client side javascript".
  • sachahjkl 1 hour ago
    htmx for the win, as always
  • BatchJob 4 hours ago
    Unfortunately the author is not only correct about front end development vibes, but due to this state of affairs, I ceased to recognize browser based UIs as being software development at all. Too much browser tech is broken to call it software. As for agents, good for them!
  • mastic 2 hours ago
    [flagged]
  • dceniac 2 hours ago
    [flagged]