Airbnb’s Server-Driven UI System
medium.com
medium.com
I too am a big promoter of that a lot of "apps" can be done with web technologies.
Early on I was interested in PhoneGap/cordova ecosystem and one interesting quote that floated around was that users don't care what the technology is, as long as it is fast.
My gut feeling is performance on native applications is "easier" whereas us web developers are butchering a glorified document to behave like an interactive application.
Regardless, I still find the web a lot of fun. Which is why I build simple apps: https://morsecode.tools/
Is your silent switch on?
Unfortunately, at the moment, I can only test on the iOS Simulator.
The amount of silliness that companies go through to avoid writing native, well-performing apps on basically 3 platforms for relatively simple applications is quite impressive.
airbnb is really the stereotypical example of an application that most people will not download a native version of because nobody likes downloading a native version of an application that they only need to run right now for a couple minutes.
Unfortunately, Airbnb would rather geek out on a silly framework that accomplishes little more than avoiding the implementation of 2 relatively simple native apps and making it harder for new developers to come online.
You’d think Airbnb folks would be in a better position than either of us to know about those usage patterns.
Sarcasm aside, I have used the Starbucks PWA and it's counterparty mobile app. PWA felt snappier and had better load times.
So I don't buy the thought that the web is somehow inferior. It just has Apple working against it because it threatens the app store model.
That aside, I'm excited for Capicitor 3 and what it will mean at the native runtime level for creating web native experiences.
That day is over.
Having a great PWA is now the default behavior for any half-technical company.
Have worked on several reasonably complex sites that maintained 60fps on mobile web.
So basically exactly the same as the average app then? There's more than one way to make an ugly, slow, and glitchy experience.
hasn't really invented webpages because the apps could still be vetted through an app store.
Their solution seems somewhat specific to their needs. Sections and screens aren’t the right abstractions for many other kinds of apps.
May still be right for them since for big companies percentage improvements are worthwhile doing and maintaining.
My opinion is that the web will never be the optimal user experience, although it offers enormous benefits in ubiquity and ease of access. That doesn't mean we shouldn't try to improve the ux of the web up the limits of security, but native solutions will always have a UX edge.
The web is optimal for things that native apps can never match, but ux is not one of those things.
On slow networks (mobile) it is really frequently bad due to the large number of URL's (mostly trackers) that must be loaded. Some web pages require many MB's just to display a simple page. In theory this approach could be faster because you could multiplex data over a limited number of TCP connections, so you can avoid the latency that is caused by setting up a lot of new connections. But they don't seem to use this approach.
You would basically end up implementing the exact same thing anyway - after all, Airbnb's implementation also targets web.
Airbnb wants, and has, a fairly interaction-rich interface, especially with Search/Filters, and then the rest of the booking flow, which means there's a lot you need to render on the frontend in Javascript.
That makes sense if:
- you have many clients
- that change very often
- but with a kind of change that is fairly consistent
- and you have the engineering horsepower to maintain your own in-house abstraction layer
I wonder if someone suggested jumping the shark altogether, and shipping the whole app as a single s-exp, and make you client a lisp interpreter with a custom logo... (But maybe app stores thrown on that ?)
(I appreciate that they did actually allow it this time, but it does seem against their own rules)
I once wanted my SPA to render html directly by fetching the html from my trusted backend and shoving its response directly into a react component using dangerouslySetInnerHTML. One dev told me, "wait, you are opening door for XSS!"
The best example I can think of would be a streaming media service that ships an app for hundreds of different TVs, STBs, dongles, NASes, mobile devices etc etc that all front basically the same service.
> shipping the whole app as a single s-exp
Be careful what you wish for. You may reinvent Lotus Notes by mistake.
There are also a bunch of other problems, off the top of my head:
- difficulty caching resulting in bad performance
- bad performance because you end up unnecesarily reloading entire screens just in case one small piece of UI changed
- difficulty taking advantage of unique platform features
- difficulty handling animations or smooth transitions
- client engineers lose understanding of the business data model, and motivation since all the action is in the backend.
- hard tracing bugs across frontend to backend
- doing UI in gql schemas is awful. sdui+gql are opposite goals, sdui wants dumber clients gql wants smarter clients. When would a client ever decide not to request a gql schema field? Which is another thing, you have to request these giant schema represantation of the UI which is bad for performance, youre basically sending your entire UI layout and receiving it back filled with data.
- complexity, difficulty hiring, not being able to use the latest best practices and architectures
- consistency across platforms is bad as a fundemental goal, users don't care since they typically use one platform. Consistency across mobile and web is actually bad UX in many cases.This kinda defeats the purpose of a SPA - a SPA lets you have instant page transitions through client-side rendering, but now you can't do that without a bunch of complicated prefetching because you need the server to tell you what the next page is.
> When would a client ever decide not to request a gql schema field? Which is another thing, you have to request these giant schema represantation of the UI which is bad for performance
I think the first part of your sentence solves the second - if the client is always requesting the same set of fields, you can probably give the query a name and pass that to the API instead of the actual giant schema.
Overall I think this sort of pattern is still valuable because shipping around fragments of HTML to update an existing document sucks, especially if multiple branches of the DOM are changing. And it won't work on mobile.
Also at the end of the day, this "server driven" UI is still a lifeless JSON blob that needs to be converted into HTML through giant JS blobs on the client. It seems really convoluted to download a description of the UI, convert it to React components, and then let React convert that to HTML. The new React Server Components project is intriguing, since it lets server-side React code render updates directly to the React runtime running in the client.
"Can we use MySQL for the rental listings? I mean there are only so many apartments in the world" "Nooooooo.....We need to design our own storage system that can run on all Cloud vendors and then design our own database on top of it, and a new generic caching system that beats Redis by 1% on this particular job"
Exactly the result of overpaying overqualified people to do something basic and they end up over-engineering everything to make themselves look good.
When you are a company that needs to maintain multiple clients across platforms (web, android, ios, and so on) it is very hard to be good at 3 things at the same time: application performance, development velocity and cross-platform consistency. Every solution that currently exists sacrifices some of the points to improve others. For example: If you make a web app across platforms, then you sacrifice performance on mobile; If you use native apps everywhere, you sacrifice development velocity and cross-platform consistency.
You might be wondering: isn't something like React Native or Flutter solve all those issues? Yes, on the surface it's a great fit. For only slight sacrifice in performance you get everything. That is why Airbnb have tried React Native initially, but decided to abandon it in the end due to technical and organizational issues (read mote here [1]).
This is their new attempt at getting good trade-offs here. You get full performance because you are doing everything natively. You get solid cross-platform consistency and high development velocity, because you are making changes in one place. Bravo Airbnb!
[1] https://medium.com/airbnb-engineering/sunsetting-react-nativ...
I don't know the answer, but I can most definitely say that the experience I have on their platform has always been solid.
But it is not radically different than using booking.com ten years ago as a user.
Maybe faster, maybe better looking, but the experience of renting a hotel/apartment hasn't really changed much.
It's good when your requirements are fairly stable, each view falls into a well known category. Meaning - it's great for an app that's basically a catalogue, but less so for apps with more complex user interactions.
you know what they say... "All problems in computer science can be solved by another level of indirection" , in reality those levels can be leaky and cause debugging problems.
I do this and suddenly I cut a TON of issues, performance problems and make all the logic on Rust. Now I also contemplating doing similar for my mobile targets.
Is using web ok? Totally, absolutely, false.
Specially in android. WebView in android is SLOOOOOOOOOWWWWWW (not you $1000 android, the androids people actually use). All my users hate this when we move to web view replacing a native app. (same thing on iOS fly even low-end/older version).
Crazy.
It worked surprisingly well. The thing that impressed me the most was the amount of documentation which even included tutorials on how to make new UI elements, Screens, etc.
Can I be 'that' d*k on the internet and asked.
-Why not use Svelte + Bootstrap (with a nice Pink Theme ?) and work via CSS to get the "similar (not identical) experience across most used devices ?
Move on to other problems ?
I feel if we were all blacksmiths in 15th century and were asked to shoe a horse. Using today's "UI-mania" (a divine mania maybe ?) would be akin to:
0) Yes sir I can shoe your horse. Will take some time because:
1) I'm first going to make my own metal. Right ? Cause it will be the "best-metal" ever !
2) but you know getting those iron-ore sand is tedious, I'm going to spend a 'little bit' of time to just optimise the mining-process of the sand.
3) Hmm this basic steel (or iron) is no good. To really get that horse going I'm quickly going to come up with a better alloy one that is dynamic, self-healing and glows green when orcs are near.
4) Finally got all the pieces... Bring that horse he is about to get NikeAirpumps for horses.
5) Damnn these nails are not perfect or optimal.. I really should spend some time and come up with a better nail... hmm maybe I can investigate geological-processes and grow my own mountain so the shape of the ore is already nail-like... Yup that sounds good.
6) 1000000 Sun cycles later: Sir please bring the horse around back, we are ready to shoe the horse now.
7) Sir ? You there ?
But I'm pretty sure "there was a time" when AirBnb was "just a website" and somehow still manages to grow to the behemoth it is today.
nowadays if you want a high performance html pushed to the frontend for an MVP, I'd recommend phoenix's liveview. its easy to use and works out of the box really well. You'll get a lot of users before you need to think about scale.
Doing something like generating an HTML body and pushing it out to clients, parsing them on mobile and using web components in the browser and then doing the same could also be interesting.
I believe eventually there will be popular open source solutions for this kind of thing that handle a wider variety of use cases. I haven't done a ton of looking into it, but this kind of use case might be possible with React Native and React's Server Components (https://reactjs.org/blog/2020/12/21/data-fetching-with-react...) in the future.
Also, at one of the messaging companies we developed an XML-based DSL for messenger-embedded 3rd party app development. It was inspired by Mozilla XUL, and was similar to modern chatbots with UI and WeChat's mini-apps.
--
[1] an individual applet-like component in a portal UI
There are very few organizations that can spend the kind of resources necessary to try this kind of thing. However it turns out, it will be interesting.
This is a good idea since it raises the abstraction from ui frameworks that work differently on each platform, to a common DSL everyone now uses.
The absence of any mention of UI tooling to make it easy to view, edit, diff and do all the project management stuff with these DSL files makes me very nervous, since that's the problem they had in the first place - keeping track of whodunnit, wheretheydunnit, whentheydunnit and whytheydunnit :)
It seems like they did a cool programmer thing, while not addressing the management problem that started this whole thing in the first place.
---
As a larger point, these rich VC backed companies seem to hire people who are capable, but then they get tasked with 'create some CRUD for us' which is boring, so they end up over-engineering and trying to use 'crypto', or 'blockchain', or 'functional programming', or 'new language', or 'create new framework'.
I know the type because I did it when I worked for big money douchebags and uh, you just need to be working somewhere else, on something else instead :)
it'd be interesting to see if this would fly if you wanted to embed it into a Chrome v3 Extension: the anti- data-driven/dynamical forces there are very very strong these days!