by simonw · 6y ago · 0 comments
I've collaborated with many different teams that use the modern JavaScript stack. It seems to me that it takes multiples of time to deliver features compared to the old forms-and-HTML-with-a-tiny-bit-of-JavaScript-enhancement methodology.
Are we really optimizing for developer efficiency here? We've given JavaScript-everything a decade to prove that it's a better, more productive way of building higher quality websites and applications. I don't think it has.
A sign-up form? Yeah, you aren't getting much from your SPA framework. Pure overhead.
A data-table with user-selectable columns, pagination, and arbitrary sorting and filtering, where the data is too large to fit in memory (billions of rows) so you have to re-render by hitting the server; but the rows contain view-state components, so you can't re-render on the server? Two lines of code in an SPA; three months on your own. Equal resulting JS size, either way.
And something like Grafana: how would you even do that server-side? Emit a server-sent-event stream of SVG images? This is a case where server-side rendering would result in heavier client-side code than an SPA would!
-----
Now, the majority of people using SPAs don't need SPAs. I think people get into SPA frameworks like React because everybody wants to learn the frameworks and libraries, to have them in their pocket and on their resume, for when they (hypothetically) one day get hired for that one job where they do get to build the fancy slice-and-dice analytical data dashboard. That job probably would pay pretty well. They want to be qualified for that job.
If you're a project manager, and you really value getting an MVP shipped quickly, you should push back on the engineering lead's desire to use an SPA framework. Ask them whether there's anything they're really gaining for this specific project. If there's no reason not to, then just suggest they build the app as a plain-old server-side-rendered-HTML app. Use Rails; heck, use PHP. (Or be fancy and use Phoenix LiveView.)
I worked through the pre-Javascript world, the jquery world, the angular1 world, and now the react world (not to mention a decade of native GUI development before that). I am vastly more productive with react and my UIs are much easier to use.
Every time I submit some 1990s or 2000s era form that gives me an error because I typed some field wrong, but also wipes out half the other fields I spent 15 minutes typing... and of course, hitting the back button wipes out the remaining fields... I want to reach into the screen and throttle someone.
No thanks.
Back button stuff; I mean, it's not trivial to support it correctly now, and it might just be an increased focus on usability and testing of this sort of thing, but hitting back was always dicey -- half the time you'd get some error about re-posting form data when you hit back, and if you said no, bad things happened, and if you said yes, worse things happened.
Back button works every time if you create pages, and navigate between them using links.
There are some garbage web forms out there, but if we're comparing building SPA in 2020 or webforms in 2020, webforms is unlikely to screw up your back button.
That's exactly why we put so much effort into making sure Django's forms framework didn't wipe out the values you had already filled in if there was a validation error.
When a programmer says "I am vastly more productive" then I know the project is vastly over budget, vastly missed all deadlines and has a vast headcount delivering something vastly unusable.
Programmer feels on their own 'productivity' are inversely correlated with real-world project productivity.
This is because programmers love to code, so more code and more complex code == 'productivity', while in the real world code is a liability, not an asset. The less code in a project, the better.
The problem you describe is solved by frameworks like Rails, and has been for at least 10 years.
It turns out there's no need to bring in hundreds to thousands of JS dependencies to implement your frontend. SSR gets the job done in a superior manner, both in DX and UX.
A couple months in he gave me kudos for getting something done in “only two weeks”
This was work that would have taken less than a week on my first big frontend job and here it was noteworthy that I did it in twice the time. Confusing emotions. Initially I felt dirty. Or like I was in the beginning of a horror movie where it turns out the happy guy is the killer.
And while I agree with the title on the article, I think it’s a shame because what we should be rewarding is effectiveness, not efficiency. I probably spend 20% of my time working on improving productivity and reducing variability for the whole team. Which means I get a little bit faster (and a lot less stressed out) in aggregate while everyone else gets a lot faster. That lead’s boss hired me specifically for that, but not all bosses are so enlightened (and he left a year later).
It's trivially easy to hook up a "delete" button such that it works without JavaScript, but if JavaScript is available it turns into a fetch() POST that removes the item (with a CSS animation) once it completes.
Or if you're too lazy for progressive enhancement, you can skip the "works without JavaScript" bit.
I used to do this kind of thing with jQuery one-liners all the time. Today browser compatibility is good enough that you don't even need jQuery.
Oh and the user is logged in and is receiving a notification that an item they were watching is now available, better show a toast.
Sorry but the simple jQuery sites turn into soup once the requirements are what they are today. You can still do it, it's possible, it becomes harder and harder to maintain long-term though. Then efficiency becomes worse than how people do it today.
Look at how many content-oriented news website article pages have gone all-in on React, with the result that they serve up over 1MB of JavaScript just to show you an article with a "save" button that no-one ever clicks.
> First and foremost, there’s the end user. If a technology choice harms the end user, avoid it. I’m thinking here of the kind of performance tax that a user has to pay when developers choose to use megabytes of JavaScript.
I believe the author is indeed talking about React (and other frameworks), SPA, big JS bundles. The developer efficiency being alluded to here is for tech startups to scale a team. A component-based frontend is valuable in providing that efficiency. The efficient is not about building a form in a few hours vs 2 days with React, but about code maintenance and scaling a team so many developers can work on the frontend at once in a sensible way.
However, having said that, I am not an advocate for a React frontend. I actually recently wrote an article, on a different topic, but with a very similar theme [1]. I think component-based frontend framework solves a real problem in an organization, but it does not have the best UX in mind.
[1]: https://dev.to/bigi/dev-to-is-the-perfect-demonstration-of-h...
Today's apps are immense JS programs - tens if not hundreds of thousands of lines.
Good luck scaling that without modern tooling.
If the thing you are building needs that then go ahead and build it like that. But SO MUCH of what I see built on the modern JavaScript didn't need to do that at all.
A lot of websites were converted to this paradigm during the pandemic because the initial UX was that the site got DDOSed by legitimate, high load, or hacked.
And this is from quick conversion (e.g. scraping a dynamic page, Wordpress plugins, etc). I think there's a lot more potential when sites are built with the static paradigm in mind.
My personal blog for example is created by a static site generator I wrote in Rust myself. Instead of manually writing HTML, or using PHP and Javascript at runtime, I handle the complexity at build time. After having done frontend dev for 10 years this approach seems much more sane to me.
Good question, we’re really not, we’re optimizing for making websites and webapps work and feel like desktop apps.
>We've given JavaScript-everything a decade to prove that it's a better, more productive way of building higher quality websites and applications. I don't think it has.
Not unless you count things like Google Maps, which wouldn’t be possible without SPA-style JavaScript.
Most of the things I've seen built using the modern JavaScript stack don't warrant working and feeling like desktop apps. They should work like fast-loading websites - especially on mobile phones, which is the source of most traffic these days.
I think it might just be a matter of what feels like home to you.