1073 points · by samename · 5y ago · 545 comments
From the turbo handbook: "An application visit always issues a network request. When the response arrives, Turbo Drive renders its HTML and completes the visit." Using the phrase "When the response arrives" begs the question of what happens if it doesn't arrive, or if it takes a minute for it to arrive, or if it arrives but with a faulty status code.
Not saying this is better from an error handling perspective, but at least the whole idea of Hotwire and its peers (Turbolinks, etc) is that there is no state and it should thus be safer and quicker to reload the page should things go wrong.
> there is no state and it should thus be safer and quicker to reload the page should things go wrong.
That's not exactly true since there are non-idempotent HTTP methods and while the browser will prompt you if you want to resend a non-idempotent HTTP request when refreshing a normal form POST I don't think that turbo/turbolinks/similar will allow you to prompt or resend.
On refresh should turbo retry a POST? The "right way" is to keep the state of the last POST and prompt the user for confirmation, but it seems like it is undocumented as to what it does. I'm guessing it either does not retry or it retries and hopes effect will be idempotent.
No one (SPAs, traditional webpages and "spiced" webpages like this included) is doing everything right, but my objection to this framework is that it seems to try to say things are simple or easy when they clearly aren't.
> it seems to try to say things are simple or easy
That's an unfair mis-characterisation. The developers are not pitching a universal panacea that solves all your problems and handles every edge case. They are offering an architecture that simplifies many common scenarios, and one that is thoroughly developer-friendly when it comes to supplying observability and integration hooks for edge cases.
For this latter purpose it merely remains to bother with reading the (clean & elegant) source code to enlighten oneself.
> it seems like it is undocumented
On the contrary, the behavior w.r.t full-page replacement on non-idempotent verbs is extensively discussed in the Turbolinks repo.
The "Turbo Drive" component appears to me as essentially unchanged behaviour in Turbo 7.0.0beta1 from Turbolinks versions 5.x. Turbolinks was introduced in 2013, has many years of pedigree and online discussion, and is well understood by a large developer community. Turbolinks was always maintained, even being ported to TypeScript (from the now venerable CoffeeScript) ca. two years ago with no change in behaviour. Turbo Drive is, practically, just a slightly refactored rebrand of the TypeScript port.
The stuff everyone is so excited about are Turbo Frames and Turbo Streams. These are new, and may be used without adopting Turbo Drive: as with practically everything from Basecamp, the toolkit is omakase with substitutions. They are, nevertheless, complementary, so you get all three steak knives in one box.
If I know the network is always there, why bother.
The entire design philosophy here is to mimic apparent browser behaviour, or to delegate to it. Hence, to GP's question; you should expect the appearance of browser-like behaviour in any circumstance, modulo anything Turbo is specifically trying to do different. Deviation from baseline browser semantics was certainly a basis for filing bugs in its predecessor (Turbolinks).
As for what Turbo actually does, I checked the source. Good news, even for a first beta, they're not the cowboy nitwits alleged; it gracefully handles & distinguishes between broken visits and error-coded but otherwise normal content responses, and the state machine has a full set of hooks, incl. back to other JS/workers, busy-state element selectors, and the handy CSS progress bar carries over from Turbolinks.
https://htmx.org/events/#htmx:responseError
in general, the right approach in HTML-oriented, declarative libraries appears to be triggering error events and allowing the client to handle them, since it is too hard to generalize what they would want
1. What if something goes wrong?
2. How do I test for handling success/error?
They never address this stuff.
However, another big issue is the dominance of mobile. More and more, you’ve got 2-3 frontends (web and cross-platform mobile, or explicitly web, iOS and Android), and you want to power them all with the same backend. RESTful APIs serving up JSON works for all 3, as does GraphQL (not a fan, but many are). This however is totally web-specific - you’ll end up building REST APIs and mobile apps anyways, so the productivity gains end up way smaller, possibly even net negative. Mobile is a big part of why SPAs have dominated - you use the same backend and overall approach/architecture for web and mobile.
I’d strongly consider this for a web-only product, but that’s becoming more and more rare.
They have accompanying https://github.com/hotwired/turbo-ios and https://github.com/hotwired/turbo-android projects to bridge the gap.
This, while very interesting and might have a preferable set of constraints for some projects, is simply not a good fit for many others, as you mentioned in your comment. This looks amazing, and I would definitely try it for a project in which it would fit, but I don't really see a reason to disparage the work others have been doing over the past decade. We need those other tools too!
(sorry for the rant)
However I think that for iOS they're still offering server side rendering via Turbo-iOS and Turbo-Android so you can build quickly and then replace that later if you need to.
This is one of the primary promises of MVC in the first place: views can be rendered independently of controllers and models. For a given controller method call, a view can be specified as a parameter.
In this case, swap "view" for JSON sent back over the wire...
RESTful APIs serving up JSON works for all 3, as does GraphQL [...]. This however is totally web-specific - you’ll end up building REST APIs and mobile apps anyways, so the productivity gains end up way smaller, possibly even net negative.
I bet someone will produce a native client library that receives rendered SPA HTML fragments and pretends it's a JSON response. They might even name it something ironic like "Horror" or "Cringe".
That said, an ideal API for desktop web apps looks rather different than one for mobile web or native clients. Basically, for mobile you want to minimize the number of requests because of latency (so larger infodumps rather than many small updates) and minimize the size of responses due to bandwidth limitations and cost (so concise formats like Protocol Buffers rather than JSON).
It is definitely possible to accommodate both sets of requirements at the same API endpoint, but pretending that having a common endpoint implies anything else about the tech stack is rather disingenuous. If you want server-side rendering and an API that delivers HTML fragments instead of PB or JSON, that can be done too.
Really, an incredible bang for the buck.
HTML is a machine-readable format, like XML and JSON. Have your back end represent a given resource as microformatted-semantic markup, send it gzipped over the wire, and you've got the data exchange you need, even if your mobile app isn't already dressed-up webview.
At that point you might as well serve XML and use an XSLT transform (+ CSS) to render the view on the client (yes, this is still possible without JavaScript).
Generally the projects I've felt best about have two features:
1) The API knows how to represent resources across multiple media types, usually including at least markup and JSON.
2) UI is well-annotated enough that developers and machines find it easy to orient themselves and find data.
But you're quite right that this isn't common. I have my own guesses on the reasons why. My observation's been that the workflow and stakeholder decision making process on the UI side places semantic annotation pretty low on the priority side; most places you're lucky if you can get a style guide and visual UI system adopted. And there has to be cooperation and buy-in at that level in order for there to be much incentive to engineer and use a model/API-level way of systematic representing entities as HTML, which often won't happen.
And TBH it is extra effort.
If I recall correctly, this made use of that new technology of the time called "XMLHttpRequest" (/s) which pretty much jump-started web 2.0.
[fn]: Arguably, the web is worse with chat bots, sticky headers, and modals constantly vying for your attention.
We can blame this on the MBA types. I've literally never heard a software engineer say "hey, let's make this pop-up after they've already been looking at the page for a minute!" or anything like it.
But there is suprisingly little layers on layers. Part of what has been amazing about the web is that the target remains the same. There is the DOM. Everyone is trying different ways to build & update the DOM.
Agreed that there are better alternatives than a lot of what is out there. We seem to be in a mass consolidation, focusing around a couple very popular systems. I am glad to see folks like Github presenting some of the better alternatives, such as their Catalyst tools[1] which speed up (developer-wise & page-wise (via "Actions") both) & give some patterns for building WebComponents.
The web has been unimaginably stable a platform for building things, has retained it's spirit while allowing hundreds of different architectures for how things get built. Yes, we can make a mess of our architectures. Yes, humanity can over-consume resources. But we can also, often, do it right, and we can learn & evolve, as we have done so, over the past 30 years we've had with the web.
So call it either one and people will know what you're talking about.
And for actual ducts you'll want to use foil-tape because temperature changes wreck the adhesion of duct-tape, then the moisture leaks into the walls/ceiling which is $$$$ bad.
I use alot of Duck Tape .
From the little language study I've done, English is one of the most flexible. You can discard entire parts of speak and it still works.
Saying , ,'ey you woke up yet', is ok in many contexts.
"Most outrageous and absurd language ever," "Megabytes of javascript", "corporate-grade bandwidth", "8th-gen i7 and 8GB of memory" to open "3 images and a contact form."
I'm sure you can find one or two poorly-optimized sites that have 2MB of javascript to download, but it's by no means the necessary outcome of using "ridiculous libraries and frameworks," and not even a particularly common one.
The real world disagrees with you; go check out any major website and observe as your laptop's fans spin up.
However I think the main problem here isn't the symptom (websites are bloated) but the root cause of the problem. I'm not sure if it's resume-driven-development by front-end developers or that they genuinely lost the skill of pure CSS & HTML but everyone seems to be pushing for React or some kind of SPA framework even when the entire website only needs a handful of pages with no dynamic content.
Try every old media site and most e-commerce.
In the Microsoft-verse, this might also draw some comparisons to the more modern server-side blazor.
I used it 13 years ago. It was fancy.
I don't know if it's so much 'everything old is new again' as it is a problem of market penetration.
The allure of xmlhttprequest was that over connections much slower than today, and with much less powerful desktop computers, a user didn't have to wait for the whole page to redownload and re-render (one can argue that focusing on better HTTP caching on the server and client might have been smarter) after every single user interaction. This was also much of the draw of using frames (which were also attractive for some front-end design use-cases later re-solved with CSS).
As apps got more complex, clients got more compute, bandwidth grew, and as web audiences grew, offloadingl much of the page rendering to the client helped to both contain server-side costs and increase or maintain responsiveness to user interactions.
Now, as desktop client performance improvement slows down (this isn't just the slowing of computer speeds, computers are also replaced less frequently), average bandwidth continues to grow, app complexity and sophistication continues to grow, but as server compute cost falls faster than audience size grows, shifting rendering to HTML back to the server and sending more verbose pre-rendered HTML fragments over the wire can make sense as a way of giving users a better experience.
As someone who implemented a SPA framework prior to "SPA" being a word much less React or Angular, I have to say for my company, it was all about state management.
Distinguishing between web apps (true applications in the browser), and web pages (NYT, SEO, generally static content), state management was very hellish at the time (~2009).
Before that, pages were entirely server rendered, and JavaScript was so terrible thanks to IE and a single error message (null is null or not an object) that it was deemed insanity to use it for anything more than form validation.
However, with the advent of V8, it became apparent as an ASP.NET developer that a bad language executing at JIT speeds on the browser was "good enough" to not send state back and forth through a very complex mesh of cookies, querystring parameters, server-side sessions, and form submissions.
If state could be kept in one place, that more than justified shifting all the logic to the client for complex apps.
Reminds me of saving Rich Text content on the server side. It was nightmare.
Also reminds me of the Microsoft RTF format. It's basically a memory dump of the GUI editor.
The state binded on a tree was never a good idea to start with.
I think what drives this crazy train of overengineered solutions of SPAs and K8s for hosting single static page is deep separation of engineeres from the actual business problems and people they are trying to help. When all you have are tickets in Jira or Trello you don't know why you should do or if they actually benefit someone then it's natural to invent non-existant tech problems which are suddenly interesting to solve. That is natural for curious engineers and builders. Then mix in 1% of big apps and companies which actually do have these tech problems and have to solve them and everybody just wants to be like them and start cargo culting.
I recently wrote a SPA (in React) that, in my opinion, would have been better suited as a server-side rendered site with a little vanilla js sprinkled on top. In terms of both performance and development effort.
The reason? The other part of the product is an app, which is written in React Native, so this kept a similar tech stack. The server component is node, for the same reason. And the app is React Native in order to be cross-platform. We have ended up sharing very little code between the two, but using the same tech everywhere has been nice, in a small org where everyone does everything.
----------
Making teams responsible
Third, we give full responsibility to a small integrated team of designers and programmers. They define their own tasks, make adjustments to the scope, and work together to build vertical slices of the product one at a time. This is completely different from other methodologies, where managers chop up the work and programmers act like ticket-takers.
Together, these concepts form a virtuous circle. When teams are more autonomous, senior people can spend less time managing them. With less time spent on management, senior people can shape up better projects. When projects are better shaped, teams have clearer boundaries and so can work more autonomously.
----------
I wonder if other industries suffer from the same problem, bored engineers.
Almost 20 years ago, one of my professors told us before graduation that hot tech is mostly about the idea pendulum swinging back and forth. I immediately chalked it up to 65+ above white wise men snobbery.
However, this is exactly that. We started with static pages, then came Ajax and Asp.net and the open source variants, then we went full SPA, now we are moving back to server side because things are too complicated.
Obviously tech is different, better, more efficient but the overall idea seems to be the same.
People have been pointing out it's a shit show with no end in sight for the entire duration of the phase. Pointing out the performance impact and cost to end users, how diabolical it is for those on lower latency or poorer network connectivity (i.e. most of the world), and so on.
Same thing as always happens with these pendulum swings, newer engineers come in convinced everyone before them is an idiot, are capable of building their new thing and hyping it up such that other newer engineers are sold on it while the "old guard" effectively says "please listen to me, there's good reasons why we don't do it this way" and get ignored. Worse, they'll get told they're wrong, only to be proven right all along.
I'm not denying there are obstructionist greybeard types that just refuse to acknowledge merits in new approaches, but any and all critique is written off as being cut from the same cloth.
It's perfectly possible to iterate on new ideas and approaches while not throwing away what we've spent decades learning ('Those who do not learn history are doomed to repeat it'), but tech just seems especially determined not to grow up.
Then, remember the awful awful #! URLs? Atrocious, and seemed like obviously a terrible idea from the start, yet they spread, and have mostly died, thankfully. But even with the lessons from these bad tech designs, new frameworks come out that repeat mistakes, yet get incredible hype.
A fair number of people would disagree. I'd say it's advanced a lot, considering the limited role of JavaScript on the client in the past.
Here's the Netscape Enterprise Server manual from 1998[1]. Sorry I couldn't find an earlier version.
1. https://docs.oracle.com/cd/E19957-01/816-6410-10/816-6410-10...
Anecdotally, most people I see who really really love JavaScript are kids who haven't really don't much else.
We started out on mainframes.
Then things moved to the desktop, with some centralized functionality on servers (shared drives, batch jobs).
The processing moved to centralized web servers via the web, SAAS, and the cloud.
Then more moved into the client through React & similar.
And now things are moving back to the server.
Tick. Tock.
These changes are not just arbitrary whims of fashion, though. They're driven by generational improvements in technology and tooling.
Like thin client (VT100), to thick (client/server desktop app), to thin (browser), etc.
Similarly, console apps (respond to a single request in a loop), to event-driven GUI apps, to HTTP apps that just respond to a simple request, back to event-driven JS apps.
It depends on how you define the boundaries, but history rhymes.
https://en.wikipedia.org/wiki/VM_(operating_system)
Notably, the VM operating system could run an instance of itself in one of its own virtual machines.
I'd say they're driven by corporate greed. Cloud computing is basically renting time, and so the more you use them, the more $$$ they make.
I sense that you're right about swings requiring change to older techniques. But I think there's also a component of being fed up with the direction things are currently facing.
At the beginning of college everyone was SUPER into NoSQL. All my friends were using it, SQL was slow, etc.
Nearing the end of college and the beginning of my job I began seeing articles saying why NoSQL wasn't the best, why SQL is good for some things over NoSQL, etc.
Technology is cyclical. 10 years from now I expect to read about something "new" only to realize that it was something old.
I sit in design meetings all the time where people with <5 years experience go out of their way to avoid using a relational database for relational data because "SQL is slow". They will fight tooth and nail, shoe-horning features in to the application which are trivial to do with a single SQL command.
I helped out on one project lead by a few younger devs who chose FireStore over CloudSQL for "performance reasons" (for an in-house tool). They had to do a pretty major rewrite after only a few weeks once they got around to deleting, because one of their design requirements was to be able to delete thousands of records; a trivial operation in SQL, but with FireStore, deleting records requires:
> To delete an entire collection or subcollection in Cloud Firestore, retrieve all the documents within the collection or subcollection and delete them. If you have larger collections, you may want to delete the documents in smaller batches to avoid out-of-memory errors. Repeat the process until you've deleted the entire collection or subcollection.
> Deleting a collection requires coordinating an unbounded number of individual delete requests.
Turns out, once they started needing to regularly delete thousands-millions of records, the process could run all night. Luckily, moving over to CloudSQL didn't take very long...
I mean, this is just dumb. I have less than 5 years experience and I understand that SQL isn't "slow", there are just different tradeoffs between SQL and NoSQL databases and you have to pick the right tool for the job.
JSON is just a media type that a resource can be rendered as. HTML is another media type for the same resource. Which is better? Neither, necessarily, it depends on the client application. But if you are primarily using JSON to drive updates to custom client code to push to HTML, well, that should give you something to think about.
Perhaps this can be the opportunity for you to look through your past and consider and reevaluate other ideas you discarded because of your own bigotry.
Which part of that is supposed to be a reasonable thing to say?
None of it - that's the point. They are self-deprecatingly pointing out how naïve and judgemental their younger-self was.
https://en.wikipedia.org/wiki/Clarke%27s_three_laws
Youth are always writing off the oldies - I did it, and now that I am old, I see it happening to me - and that is ok - we need that passion to shake things up, even if they end-up eerily similar to the way things were done before...
Rails never did, and even actual SPA frameworks (e.g., React) have had SSR support/versions for quite a while. Basecamp introducing yet another iteration of front-end-JS dependent mostly-SSR for Rails isn't a pendulum swinging anywhere.
I don't see much merit in moving back to server side rendering aside from obfuscation & helping SEO ratings (web crawlers have a hard time with SPA)
This doesn't save battery life on a device. If someone downloads a few meg of JS their browser has to parse and execute that JS locally. This use of processing uses power. If that same person had half as much JS to parse and execute it would use less power.
A CDN does not save from this happening.
When power use happens on a server it's more on the server but less on devices with batteries. Batteries aren't used up as quickly (both between recharges and in their overall life).
A server side setup can cache and even use a CDN to only need to render parts that change.
My points are that it's not all cut and dry along with considering batteries.
Oh, and older systems (like 5 year old ones)... surfing the web on an older system can be a pain now because of JS proliferation.
Yes, I'm aware that "it will be cached" lost most of its glory when bundling became mainstream, but I still hear it as an argument when pulling things from common CDNs.
The server's hardest work is usually in the database: scanning through thousands of rows to find the few that you need, joining them with rows from other tables, perhaps some calculations to aggregate some values (sum, average, count, etc.). The database is often the bottleneck. That isn't to say I advocate NoSQL or some exotic architecture. For many apps, the solution is spending more time on your database (indexes, trying different ways to join things, making sure you're filtering things thoroughly with where-clauses, mundane stuff like that). A lot of seasoned programmers are still noobs with SQL.
Anyway, if rendering is lightweight, then why does it bog down web browsers when you move it there? I don't think it does. If all you did was ship the JSON and render it with something like Handlebars, I think the browser would be fine, and it would be hard to tell the difference between it and server-side rendering.
I think what causes apps to get slow is when you not only render on the client but implement a single-page application. (It's possible to have client-side rendering in a multipage application, where each new page requires a server roundtrip. I just don't hear about it very much.) Even client-side routing need not bog down the browser. I've tested it with native JavaScript, using the History API, and it is still snappy.
I guess what it is, is that the developers keep wanting to bring in more bells and whistles (which is understandable) especially when they find some spiffy library that makes it easier (which is also understandable). But after you have included a few libraries, things start to get heavy. Things also start to interact in complex ways, causing flakiness. If done well, client-side code can be snappy. But a highly interactive application gets complicated quickly, faster than I think most programmers anticipate. Through careful thought and lots of revision, the chaos can be tamed. But often programmers don't spend the time needed, either because they find it tedious or because their bosses don't allot the time --- instead always prodding them on to the next feature.
Nice! Casual ageism and racism mixed into one post.
On one hand, it’s true. It’s part of white privilege which is tangible.
On the other hand, however less often people in a privileged class are realistically impacted by discrimination, it’s still > 0.0%. Since it usually costs nothing more to include everyone it seems useful.
But I think the biggest reason it’s important to care about discrimination wherever it shows up and not let people off the hook is that it’s unifying.
There’s a story out of Buddhism that suggests it’s important to think equally kindly about rich people, kind of similar in that they’re a privileged class.
I know it’s a hard sell. I don’t do it justice here. However a powerful argument can be made that not disparaging privileged classes, actually helps us all in the long run/big picture.
If I get down voted I understand, that’s ok. If it makes a difference I don’t mean to minimize the 10,000 year history of pain suffered by any humans due to discrimination.
The powerful argument is that you should treat everyone well, period, and not do some kind of calculation to decide how cruel you're allowed to be to them.
Edit: I've had just about enough of people using "white privilege" to justify violence and blatant discrimination because "they haven't been exposed to enough". Its just another way to justify racism. Plenty of white people live in poverty. Its not ok in either direction.
And there are definitely applications I would prefer to write as an SPA over the Hotwire approach. But given that the vast majority of websites are just a series of simple forms, I prefer this approach over the costs you incur from building an entire complex SPA.
Also a lot like React Server Components that we saw on HN yesterday[2]
It seems like this is the next wave of web apps. Hopefully once the hype settles, we'll be able to decide which approach is best for which project.
It's much different based on a preliminary reading of Hotwire's docs.
Live View uses websockets for everything. If you want to update a tiny text label in some HTML, it uses websockets to push the diff of the content that changed. However you could use LV in a way that replaces Hotwire Turbo Drive, which is aimed at page transitions, such as going from a blog index page to contact form. This way you get the benefits of not having to re-parse the <head> along with all of your CSS / JS. However LV will send those massive diffs over websockets.
Hotwire Turbo Drive replaces Tubolinks 5, and it uses HTTP to transfer the content. It also has new functionality (Hotwire Turbo Frames) to do partial page updates too instead of swapping the whole body like Turbolinks 5 used to do. Websockets is only used when you want to broadcast the changes to everyone connected and that's where Hotwire Turbo Streams comes in.
IMO that is a much better approach than Live View, because now only websockets get used for broadcast-like actions instead of using it to render your entire page of content if you're using LV to handle page transitions. IMO the trade off of throwing away everything we know and can leverage from HTTP to "websocket all the things" isn't one worth making. Websockets should be used when they need to, which is exactly what Hotwire does.
I could be wrong of course but after reading the docs I'm about 95% sure that is an accurate assessment. If I'm wrong please correct me!
Rarely admitted, but absolutely truth.
His work inspired me to build my app (TravelMap) with SSR views: https://clem.travelmap.net
I like Hacker News in part because the tech is so boring. Server-side rendered, static HTML with a minimal amount of JS[0].
Source: UI/UX researchers tell me this when I push back and say "let's keep the tech simple and forgo some of the animations, etc in the name of using simple OOTB stuff without hacking thousands of lines of JS together." Also family members will tell me the same things.
They need to be performant and they need to improve the usability of the system, not reduce it. That's the criteria. It's often not achievable with the web, though people try.
Is that with respect to Web Page / Tech?
Because people expect different things for Apps and WebPages.
But this isn’t really about the tech, it as much a productivity hack that allows people to be much closer to that old fashioned concept of a full stack developer
This is what has allowed Basecamp to create Hey with a team just a fraction of the size of their competitors
Does it really take a team of 800 engineers to maintain your fancy todo list app, rather than your focussed team of 10 or 20? What are all of those people doing except piling on organisational cruft so the business has no choice but to over-encumber itself with talent? Most of them aren't working on the product, that's for sure.
Talented engineers are tied up doing menial tasks but getting paid $300k/year, cheaper than having to compete?
LiveView on Phoniex
Blazor on .Net
- Elixir / Phoenix
- .NET / Blazor
- Laravel / Livewire
- Rails / Hotwire
Or hold on for the JS ecosystem to figure out good patterns that balance performance/maintainability (React Server Components look ok, and will probably trickle into Next.js for those who want a framework).
Does one of the above stand out as a good thing to learn from a career perspective, say, for a JS developer growing tired of frontend?
Is the thirst for React developers ever likely to dry up and leave devs who know these frameworks with an advantage?
It works just fine with Django.
It seems easier to accomplish this with Liveview and perhaps Alpine.js for displaying stuff like modals etc. It's a really good way to build applications I think for places that need a server roundtrip anyway which is most of the stuff in a modern app.
I write a SPA app for work in javascript and about 90% of the issues that occurs are mainly state issues where the state differs or is in a bad state for some reason. State management is very hard to do right and I think solutions like these simplyfies it a lot!
I urge people to check out Elixir and Phoenix Liveview which I think is the "original gangsta" when it comes to sending small updates over websockets and if you try it I will guarantee you will be blown away of the speed of which you can develop web apps as a solo dev.
I think this HTML SSR approach have different tradeoffs and uses compared to Single Page Applications.
The HTML SSR works best with a stable connection and being close to the server for good enough latency. Higher cost on the backend is a tradeoff on how much computation/complexity you want to offload to the client, and also what language/framework you want to work with more.
Some HN comments from previous related topics suggest these approaches (Hotwire / LiveView / Blazor? / StimulusReflex / Intercooler / HTMX / Unpoly) fare better with apps targeting a specific region so roundtrip latency is lower. One can optimize the reads with DB replicas + app servers closer to any user, but the write DB is the bottleneck (I think). This also ties in with the feedback that US/EU HEY/BC users perceive the app as snappy enough while AU users feel the latency a lot more.
SPA (properly built) should be more resilient in regards to network stability/condition/latency and expose a lot more offline capability.
I feel like the ideal app is HTML SSR + an app shell to serve some offline capabilities. Scaling the write DB globally is a hard problem though.
Curious to hear about the success/horror stories in a few months/years from any adopters :)
which is a fair complaint, I would say.
.NET's Blazor (server based) uses this.
I preloaded data such that a user could navigate via search or clicking through some drill-down menus without having to wait for a full page refresh. The data would hydrate the views so that the transition time between views was almost always fast, even on slow mobile traffic.
One aspect that was very difficult to figure out was incorporating views that would require more data from the server. Once a user drilled down to such a view, the challenge became how to load the view via AJAX without having to make another AJAX call to load more data.
The solution was to return server side rendered HTML instead of JSON...
Looking at the demo, this seems very similar to some of the things I had to do minus 95% of the hacky Angular/PHP code I had to set up.
This is a killer feature to have in Rails and I am looking forward to learn more of the conventions that will surround the implementation.
Hotwire is backend agnostic.
Afaik Meteor is the only major full-stack framework handling this. Any other takers?
I have thought in the past I wish I could have a frameworky component-style frontend, but where the component is HTML rendered by my rust (or whatever) backend. This would seem to get me a lot closer to that.
Stimulus is also not any different from any other javascript you'll write. There's no need for any kind of scaffolding from the backend stack except for some features - and those aren't particularly hard to implement either.
Source: Using Turbolinks & Stimulus js with Django.
I am still wondering if there is any benchmark presenting some objective facts
The introductory video is far too long, far too technical (I know a lot about web dev but don't know a lick of Ruby or Rails) and far too fast to follow. I was really interested in Hotwire because of the comments here and now… not so much anymore.
(Which of course doesn't say anything about the quality of the tech. I just thought I'd post my first impression of the website.)
I've seen a lot of DHH's talks and demos and never had a problem listening to them at 2x. This is the only time where it feels like he scripted out the entire video word for word and then talked over a screen recording that was recorded separately from his voice. This video sounds nothing like what he normally sounds like (both tone and speed). I really wonder if he recorded this in a booth.
the tech is dope
It's trying to standardize a fullstack approach to it I presume.
Source: I've been using turbolinks and stimulus with Django for a good year and a half.
I gotta give them credit for revisiting server-side page assembling though; moving application logic and templating mostly to the front end was a HUGE mistake. JS is very fast now, but it's still absolutely glacial in its speed compared to server-side code written in compiled languages.
I don't think I've ever seen DHH or the Basecamp crew advertise any of this type of stuff as some groundbreaking new approach that nobody has ever tried before. On the contrary, I usually see them talking about how those old ways of doing web development were actually better in many ways, which is why they're pushing to move away from the current "everything is an SPA" approach.
And all this new tooling makes the experience much better than it ever was in the past.
Not disagreeing with the rest of the stuff. But they literally call it "NEW MAGIC" per DHH's tweet.
Servers could maintain an open connection and stream new data to the browser.
html, http, js, css are pretty thorough in their design, and it shows.
all the features described here are possible without any frameworks, this is merely a much easier way to build it than from scratch.
For those not familiar, rather than using a standard web framework where a lot of processing is done client side, these frameworks allow html buttons etc to call native Ruby, C#, or Elixir functions on the server rather than using some sort of post/get request to do that. Every UI interaction goes over the wire, which is where performance can be hurt.
Having used Blazor in production for nearly a year, it speeds up development, but your server is doing a lot more processing and will not be able to handle an equivalent amount of users that a normal web app would because it’s keeping a copy of the clients DOM in memory. It’s updates the dom on the server then streams that update through websockets to the clients dom, creating your magic Single Page App experience.
I think it’s cool tech, but not necessarily scalable due to the increased server load. I’d be interested to hear from people using it to serve large orders of magnitude of clients at once.
There are forms being submitted, there are normal requests happening, there are templates being rendered on a per-request basis (just like a full page load).
This is like a normal web application that renders HTML, from the perspective of how the server works. Just as scalable as every other Rails application that renders HTML. Be that GitHub or Shopify or Zendesk or Basecamp or HEY or any of the many, many other apps that have long ago definitively proven that Rails Scales.
Although I do find the commentary that the current #1 comment on the HN thread is literally a "bUt DoES iT SCaLE??" take, based on a misunderstanding of how this works. All is indeed as it's always been
That's not how it works, at all.
What doesn't work quite as well is when the app is operating a freemium / ad based model. Where a large volume of traffic are required before you start generating revenue.
You don't need scale at a startup. You need velocity. If you're hitting scale at a startup, you've done one of two things:
* Written absolutely terrible software
* Succeeded
Unless you've hit the second one, it will almost always be cheaper to simply spin up another server.
While this is truly clever and being based on sockets does seem to simplify communications between client and server, I'm not fully convinced.
Currently I see client side rendering as a way to delegate some computing to the clients. Which is a nice way to lower operating costs.
I can see the benefit of this and the reasoning behind it. Because SPA still need a server (serverless still implies server side coding) as long as you are executing code on the client you need two codebases. One for the client, one server side.
With this solution it would seem that it's possible to serve a web app with only one codebase, so that's definitely a plus. But then performance and costs do preoccupy me a little.
Perhaps the ideal scenario for this tech would be for (enterprise) apps to be deployed on proprietary servers, where scale is a minor concern.
Rendering (or anything else that you can choose to do on the server or the client) has no impact on data coherence. Thus, as optimization goes, it's something you care about less than nearly anything else.
By the way, I have seen my share of really horrendous code though my life. Only twice I have seen something that isn't data coherence being a bottleneck to anything. Both times were really stupid bugs.
My first impression is that the API seems a little convoluted, but that might just be me. In an ideal world, I'd love to just build components (similar to React components) on the server side, and let the framework intelligently handle synchronizing state over the network (Phoenix LiveView seems closer to that), but this feels like it involves a lot more framework-specific logic (and markup) with special cases - stuff that's likely to change as the framework evolves, so I'm not sure how I feel about it.
I guess it makes sense in terms of making this easier to add to an existing rails app incrementally (since it's more-or-less "opt-in" for each model, view, and controller), but if I'm building a new project with this and want it on everything, it feels like it will necessitate a lot of code duplication. Either that, or I use it judiciously only when absolutely needed (and use traditional rails behavior for everything else), but that feels like a mess of two very different approaches bundled together in one codebase.
But I doubt they'll integrate this into Rails. They'll just create better and better tooling to make using this with rails a cinch.
I think this will just remain backend agnostic, like turbolinks and stimulus were before "hotwire".
It's the answer for people that sick of the weight of modern webapp, where everything need to be rendered client side.
Web sites are heavyweight, serving megabytes of useless nonsense just to display an article. With a bunch of ads obviously.
The new thing about it are the name and associating it with Stimulus and some features, not the general concept.
The video was however a great tutorial, although a bit too fast. (I had to pause and replay a few times). But it did not sell me on the concept.
A more simple approach would be to send a (head) request to the server every 5 second asking if the source/HTML/state has changed. Then do a sophisticated diff/replace of the DOM (like in React, but without React) making the smallest change to the DOM as possible (only change what was updated). eg. no full page refresh, nor iframes. (and also send a diff over the wire, not the full page).
If you would make the app fully functional/pure you would then be able to cache many states (input->output) and predict them on the client and prefetch, for example a link click, would instantly do the DOM/diff and update the page with the new content. For example in a tic-tac-toe game you could pre-render all states and have the client pre-fetch them.
The same thing will happen to micro services (especially, distributed monolith) and Kubernetes. They are just overhyped.
Productivity matters most!
When it comes to VC-funded crap or big legacy enterprise trying to "modernise" itself, over-engineering allows grifters to twist the situation for their own personal gain. The business problem the tech is supposed to solve often warrants a simple solution, but why would someone solve it with a simple solution and 3 people when they can bring Kubernetes, microservices, "service mesh", blockchain and multiple programming languages to the mix and suddenly become an "engineering manager" managing 30 people, put big words on their resumes and speak at conferences about how they solve big (self-inflicted, as a side-effect of the overengineering) problems where more of their peers (either new and genuinely believing this is the proper way to do things - like I once was - or experienced enough to know this is BS but support it as it paves the way for their own career) encourage them?
This happens at multiple levels too, it's not just developers or would-be engineering managers. The funding side of things is also broken in the sense that you'll attract more investors and raise more money (some of which you'll keep in your pocket as salary, even if the company folds in the end) if you throw big words and pitch an over-engineered solutions such as blockchain as opposed to a simple and proven one (even though the latter is more likely to actually pay off).
This is just demonstrably false. Both paradigms have areas where they shine. One or the other is not better across the board.
I guess the point of Hotwire is that there isn't pretty much anything you can't do with the "old tech" that you can with the modern javascript CF.
This is how I used to build web apps 20 years ago! :)
Render all HTML on the server side using a lightweight templating engine, make page loads fast and make all interactions reload the current page avoiding all client side JavaScript for validation and logic. (except for hotkeys for quick nav)
One thing that is kind of broken out of the box is form submissions: so a common pattern with server side rendering is to re-render the form with validation errors, but otherwise redirect to wherever.
The workaround here I think is to use turbo-streams and just re-render the invalid form HTML snippet rather than the whole page. While this is probably ok for most cases, I have some forms (3rd party library stuff) where this is going to be more work than I'd like, and due to a bug in the beta release you can't override the default form submission behavior - Turbo throws an error if a form POST returns anything other than a redirect. So it's probably not quite ready for production yet.
Is this a new, giant complexity or a nice add-on? A huge mental/development shift or a nicely paved new path to something better?
Turbolinks (the project at Basecamp that Hotwire grew out of, now it seems it's called Turbo Drive) was a way to bring single-page style load times to traditional, server-rendered apps. Hotwire is the evolution of that: Turbo Frames let you dynamically replace certain parts of the page on the frontend, rather than having to throw the baby out with the bathwater on every page action. If you're used to developing server-rendered applications without much JavaScript using Ruby on Rails, Django, or a similar "batteries included" backend framework, then you'll be able to add a more dynamic feel to your web app without much of a mental shift: certain template partials (basically the components of your frontend) will be wrapped in this `turbo-frame` HTML tag, which will be slotted in to your page dynamically by Turbo.
I would argue it looks a lot simpler than the average SPA framework or library.
Honestly it's pretty straightforward and the API is tiny. It's great for that grey area between serving server-loaded static pages and full-blown SPA - for example CRUD apps (and lots of things are pretty much CRUD apps). Turbolinks gives you a "poor man's SPA" for little effort (albeit with some gotchas) and Stimulus is fine, although it gets tedious for when you have to work with a lot of DOM elements e.g. "when I click the Subscribe button, change it to an Unsubscribe button". Maybe a less imperative framework like AlpineJS might be simpler.
That lets me have quick development on the frontend, server side rendering for fast first page load and use of a typed language for the backend. The client is also overburdened with a large JS framework.
Rendering a SPA on a client device consumes CPU time, which definitely uses energy proportional to the number of client devices.
Assume the server uses less clock cycles to render than the client--e.g., because of optimized software, hot caches, or tuned hardware.
Therefore rendering on the server should always be more energy efficient than on the client.
- Noticed excessive JavaScript contributes to poor web performance - Things cause JS to break, which breaks other interactivity, often I end up using incognito
During lockdown, I struggled ordering groceries because 20 seconds of JavaScript execution on the main thread made my "delivery slot" expire!
Similar to heydonworks.com stating "Please disable JavaScript to view this site", I'm glad Hotwire is encouraging folks to think about things a little differently.
server side rendering does it all on the server and spits out html(legacy cgi style)
between these two: static html template downloaded from the server, then use ajax to update json in the html pages, which is the old boring way but it might still be the best middle ground?
Unless I need make a desktop complex GUI program where SPA could be a reasonable choice, I will just do the html/ajax old way, not fully geared towards to server or client side rendering, life is much easier.
For performance, server-side rendering is just bad. It won't scale to high volume traffic, cost too much money and is complicated to maintain. Hosting a static HTML files is more performant than that.
For simplicity, the current protocol relies on so much "magics" to give the impression of simplicity. I think that's just an illusion of simplicity.
The comparison is only between server rendered HTML vs backend API + some frontend rendering locally (which is not as performant) and more importantly is a lot more complex to implement technically.
Wow, that's dedication!
> I'm just happy to see how much job security I have
I'm glad for you!
> none of you are smart enough ...
Now I feel bad about myself!
So it's effectively similar to just a normal HTML page, but without things like headers and sidebars etc. being retransmitted?
I guess I am old but I don't understand why this requires a multi-million dollar marketing effort and all of the other stuff they invented on top of it.
- Turbo (HotWire) https://github.com/hotwired/turbo - Stimulus https://github.com/hotwired/stimulus
It's just another attempt to put the square peg in a round hole.
The point is: "The web" is not, and never was, a framework for application development! It's the wrong tool. No matter how hard you try.
You want to build applications? Use tools that where build from the ground up to support application development.
On mobile people realized mostly by now that "native" is the way to go. Because native apps are superior along any dimension compared to "web-apps". The same is of course true on the desktop.
Mature and full featured technology to build "native" cross desktop applications exists since forever. Just have a look at great tools like IntelliJ IDEA or Bitwig Studio for example.
Hotwire on the other hand is just another try to misuse "the web" as an application development platform. It's closer to what the web actually is (namely HTML pages) but it's still wrong on the fundamental level (as it tries to build an app framework on top of something that was meant to be only a hyper-text system).
Let's see how long it'll take until people realize this truth - and we're really full circle.
You want to build applications? Use whatever freakin tool or platform your users will adopt. Don't be constrained by pointless prescriptivism.
An example what I mean: One can use a stone to put nails into a wall. But a hammer is clearly the better tool for that task.
Wikipedia is a great example of a perfect web site: simply presented content linked together in a way that encourages exploration
People keep hijacking this experience to make it "better" or more like an "app" but that detracts from what makes the web so magical
I'm not arguing against "interactive documents". I'm arguing that "the web" is not for full blown applications.
I guess there might be space for something like Steam, but for business apps, but I just don't see it. The argument "This isn't what the web was made for" is kind of a cowpath argument. The web is being used to (among other things) browse applications. Whether or not that's what anyone planned is irrelevant. That's what's happening right now.
I think it's fair to suggest paths forward that both accommodate users and also bring sanity, but tagging every attempt at progressing applications-in-browser as "Square peg, round hole, need native app" just totally dismisses most of the users these applications are trying to capture.
If QT was going to become ___the tool___ for desktop dev, it would've done it by now.
The rest is just: "But with a big enough hammer we get the square peg into the round hole, so what's wrong with that? People are doing that the whole time. Seems fine".
edit I am speaking from the experience of trying to build a desktop app. I think people suggesting "Just build a desktop app" have no idea the amount of feedback that gets received to the tune of "Why do I have to download an app". It's staggering.
Maybe the problem is that it's too good: people and organizations end up producing "web applications" instead of "web sites" just because the technology is so readily available and so widespread.
If there's one thing to complain about, it's that sites don't gracefully degrade when JS is disabled. I don't care that your browser game doesn't work without JS, but I do care quite a bit that I can't read blogs, news websites, etc.
Modern browsers are completely crazy bloat-ware. Bigger by lines of code than most operating systems! Things like the JVM become small and lightweight compared to a modern browser.
And still, it's not a "great application runtime" - as people still not even found out how to use it "properly" as one (as again: that's the point of the article we're discussing).
That people everywhere do irrational stuff all the time is also no prove that anything of that stuff makes any sense at all. Things don't become smart only because there are more people out there doing the same thing. Actually the mass isn't doing the smartes things at all usually. So that's imho a quite bad benchmark for anything anyway. ;-)
I think I will go with htmx.
If you want to know more: https://github.com/guettli/html-over-the-wire
It is appropriate for some applications and not for others. That's just my view.
Could you expand a bit on what makes it appropriate or not for different applications?
<div id='counter'>42</div>
is not so many more bytes than...
{ counter: 42 }
also - no massive up front JS bundles to contend with
Just looked and Turbo is 135kb. I rewrote this website (http://40.115.126.159/) with my own JS framework and it comes at 15kb, that's 9x smaller Turbo...
I think they actually mention adding Stimulus controllers in the demo video for those usecases.
s/complimentary/complementary
You could just include it in your existing PHP app if you wanted to.
So Edge 16+, Safari 12.1+, FF 57+?
It seems like DHH is just trying to make relevant tooling without writing Javascript, which I guess is fair, but given all of the advancements in all of the other tech, this really just does not seem like a good idea to me.
As in sssr as in semi server side rendered
I can see this becoming a big problem on their ecosystem if it starts to scale it'll start to be very costly.
You probably wouldn't use this for a drawing app. But if you've got something where you're showing/updating database data, this model is likely fine.
The backend here _is_ your frontend.
This supports my argument that there is tight coupling.By comparison of a similar design, golang.org is twice the size and only takes .3 seconds longer. So what exactly are we comparing?
The js bundle your browser downloaded right there is the entire bundle for the whole email app.
What size is it?
Not trying to stray too far from my original point, loading a small page with not alot going on should be fast. I'm not knocking Hey.com, I am just not going to pass out accolades for making a properly usable site!
Time will tell --I'm not so bullish on Hotwire-- but one has to admire figures the likes of DHH that can almost single handedly change the status quo of the industry.
Less boilerplate. More reuse. Consolidation of app state to the server.
Feel free to post your code from a decade ago so that we can do a bake-off and compare implementations side-by-side.
It's lightweight on the frontend and a pleasure to develop for since forms are entirely coded on the backend with components. On rare exceptions more complex pages have some sprinkled lodash.js.
They have around 400 CRUD pages with complex business validations. Up to 1.5k concurrent users. At that point MySQL starts to sweat a bit and p95 increases above 200ms. All running on 2 machines: a nginx+phpfpm and a MariaDB.
The instant no-compilation feedback loop of edit-save-refresh is orgasmic. That system opened my eyes to a lot of preconceptions and buzzwords I once held sacred.
This seems cool, but the progress that HEY has made since launch isn't very impressive if that's the flagship example.
HEY's search UX, which uses these capabilities, has been abysmal since the day it launched. It's a much better experience if you disable JavaScript/Hotwire and fall back to the server-side-rendering instead of the hybrid mess they push down. I'm very disappointed that this hasn't been improved. (I sent feedback about this while they were still in their invite-only phase.)
We were also promised custom domain support by the end of the year, and we don't have a timeline or even pricing yet. (That's obviously backend and unrelated to this announcement.) I don't want to go back to Google, but the lack of improvement isn't giving me a lot of confidence as a HEY customer, so I'm considering alternatives.
The amount of inbound email I get has dropped immensely due to the screener and my inbox ("imbox") is so much easier to manage with Hey, IMO.
Basecamp / DHH generally speaking hate deadlines / roadmap etc. They are ready when they are ready.
Although I do agree a little update would be nice.