Rich client side web apps gone too far (2014)
chase-seibert.github.io
chase-seibert.github.io
A VAST majority of websites on the web serve CONTENT. Why is JavaScript needed to serve content is really beyond me. You don't need to make your blog look and feel more webapp-y. It's a blog post. I want to read content. I don't use other features on your blog. Please just serve me the content and don't try to SPA that shit. Heck, I'd be willing to bet 99% of websites out there don't need to store session information to begin with - a static website would have served as well.
And most interactions on any website are not worthy of making it webapp-y anyway. Most websites with interactions will do well with minimal interactions anyway. Not every website needs to be real time. The existence of a listening loop in a lot of websites has caused my MacBook to crash more than I can care to count.
OK, sure, webapps like Asana and Gmail have good reasons to use and push the use of JavaScript forwards, but I really don't see why websites like AirBNB would require JavaScript. It's a bloody classifieds website. Out of the top 10 most visited websites I use, I can see only 3-4 of them really needing a fancy JS frontend. The others can get by with much much better UX if the JS in the frontend were kept to bare minimum.
Does JavaScript enhance the experience to the non-power users? I am not sure. Is not seeing the white flash when a page loads really that necessary to improving UX? I've definitely heard way too many complaints about JavaScript assisted scrolling amongst the non-tech acquaintences I have. I also have definitely heard complaints about bloated webapps that cause the entire computer to slow down.
The sad thing is with our modern browser technologies, we can be doing so much more, but webdevs tend to chase the fashionable, leading to generally poorer experience.
What's worse is our addiction to fashionable JavaScript things have caused us to design hacks on top of hacks on top of hacks. When will this madness end?
edit: fun stuff - according to htop, my Firefox, which has one tab open reading a blogspot page, is using about 12% of my memory. Amazing.
Here is a recent talk where they explain how they solved some tricky UX problem by using a "modern" JS framework such as React.js
http://www.infoq.com/presentations/airbnb-resolution-center
In this other talk they also explain how (and why) they evolved from vanilla Rails (i.e. more static HTML) + jQuery, to Backbone, and finally to isomorphic React.js
1. The vast majority of content I consume is, in fact, not static content, the only exceptions being HN and my bank statements. For almost everything else, I much prefer the interactive experience made possible by an SPA. This includes anything with a map (Yelp, Airbnb, Redfin), charts (google analytics), autocomplete (stack overflow) or chatting (google hangouts).
2. All SPAs are not the same - for every 10 second-load monstrosity (gmail), you have someone sending the markup from the server on the first load (airbnb)
With the explosion of mobile apps, people have a certain level of expectation in terms of UX, and a static site won't always meet those expectations.
I've also used flux with Ractive.js, which in some ways is perhaps an easier introduction into the flux/react approach. Might want to check that out.
I find it hard to describe how incredibly simpler everything is now that I don't use BB anymore. With some of the stuff that 'just works' in my current setup I can't even begin to think of a clean way to do in Backbone.
As for mvc, I would say react+reflux is more like mvvm than mvc. I don't miss anything from backbone and can't imagine going back, good riddance.
From the article:
"Javascript used to be a tool that you used as sparingly as possible, sprinkling just the barest hint of dynamic behavior where it was absolutely necessary. Now it's common to start a new project and assume that 50% or more of the code will be Javascript."
I know I've been asked to cool it on the pimping, but this is exactly what intercooler.js is designed for: you don't need to write much javascript for the dynamic behavior you want 99% of the time.
JavaScript is a clusterfuck. More Javascript is not the answer.
Your comment reads like a reflexive defense of JavaScript since "javascript sucks" wasn't even the point of the essay.
All languages have warts, and some are much worse than others. I actually think JavaScript's warts are fairly minor compared to C's or Python's, for example, and PHP is in a different league.
In fact, there are almost no other programming languages with JavaScript's basic features: Unicode support out of the box, proper lexical scoping with first-class function closures, high-performance garbage collection, and easy manipulation of strings, arrays, and dictionaries, for example. Python comes pretty close, with slightly wonky scoping and Unicode bolted on, but then JavaScript also has another Python doesn't, which is a spec with multiple first-class implementations, and not to mention a committee that is plotting a great path forwards into the future with fully backwards-compatible upgrades to the language.
utf16 support, which isn't the same thing: https://mathiasbynens.be/notes/javascript-unicode
easy manipulation of strings, arrays, and dictionaries
JS objects aren't dictionaries; all keys are coerced to strings, they lack basic operations like getting a list of keys or values, and iterating over keys can bite you if you forget hasOwnProperty.
Python comes pretty close, with slightly wonky scoping and Unicode bolted on
And equality operators that aren't utterly insane, a usable standard library, local rather than global scope by default, classes, namespaces, modules...
ES6 does look a like a large improvement. Mainly because it fixes misfeatures and adds capabilities that better languages dealt with years ago.
I'll definitely agree that javascript has room for improvement, but i'm not sure by what objective standard you're measuring its design chops. If you consider the goal of JS to be an incredibly flexible, light language with powerful runtime dynamicism and a strong focus on client-only needs, I'd say it's fairly well-designed. If you're holding it up against python as a server scripting language, it probably doesn't quite measure up. and if you're holding it up against all other languages and measuring by some 'general-purpose utility' ruler, that's a pretty pointless exercise - as I said in my original comment, languages are designed to solve specific problems, and JS is no exception.
So, fat-rich-messy clients will be the norm and BAAS providers will get richer selling services that take away the headache of running a server. Too bad JS is the only option to program them clients.
Honest question, is this really possible? I write webapps and Javascript + Jquery makes a lot of stuff easy, hooking into button clicks, getting text from an input box and sending AJAX requests back to my server.
Does anyone have an example of a web application with no Javascript? My next project will most likely use Golang as the server side, and I'm having a really hard time imagining how to send AJAX requests back to the server on user events (such as the user typing into a box in a real time search application) without using Javascript.
Apparently I've missed a whole area of web development if this is all possible with no Javascript. Isn't this like saying your Windows game should be fully functional without a graphics card?
I mean, on most web applications, they are that, applications. Maybe I just don't know enough, but I feel like I need a programming language in the browser to create the client side of the application, how do I fire off AJAX events when a user types something without Javascript?
I'm honestly trying to learn more here, I need examples of web apps with no Javascript, I need a book or something. Just being told I can replicate my application in html and css isn't helping.
So in your example - no, you would not send AJAX requests back to the server in a real-time search application. It would not be "real time" at all. But you would still be able to search, and get back results. Then you add JS, and you can search as you type.
Relatively few sites do it like this these days - in general, anything that's a SPA that talks to JSON won't work at all with JS disabled. It takes a good understanding of your tools and of your users to prioritize like this, as well as a good dose of humility. But it also often results in better usability and UX design overall, because you know which features are really key and which are "nice to haves", and you don't compromise key features for extras.
Yes, loads of things work without JS. You can use Wikipedia, even to edit articles, with JS disabled – it's all simple HTML forms. JS just makes the experience smoother (adding buttons to help with WikiText formatting, etc).
Most content and shopping websites work fine without JS. You asked how do you fire off AJAX requests without JS? You don't. You just design your app so it basically works as a set of HTML pages connected by hyperlinks and form submissions. Then you add JS to enhance things.
> Apparently I've missed a whole area of web development if this is all possible with no Javascript.
Yes you have. When I started (~12 years ago), JS was only used for little whizzy effects here and there, not much else. Then JS started becoming more viable due to prototype and jQuery, but it was always the most flakey part of web development, and we learned to use it cautiously as an optional layer of enhancement. You couldn't rely on it always working. It was a way to 'differentiate' your site, not a serious building block.
Now, everything has changed, JS is everywhere and we tend to call things 'apps' more than 'sites'. I spend 70% of my day writing JS. I'm not sure if I agree with the JS-bashing sentiment of the article. But I do think it's still good practice to design your app so it delivers your core content/functionality without JS. Most stuff (blogs, e-commerce, forums, etc) can be built like this. (Admittedly some things like p2p streaming apps just can't.) Then you can use JS to enhance things, like enhancing your basic search form with as-you-type suggestions. This approach makes your codebase more structurally sound and less entangled, and makes your app more resilient.
Well, sure.. of course it is possible, just a lot more work because the divide between having logic on the client and no logic on the client is quite big thus you often end up needing to solve problems in two ways (and these differences can permeate various layers of the app) and then commit to maintaining both.
"such as the user typing into a box in a real time search application"
Well you could always just not support real-time search if JavaScript is not enabled. The argument that JavaScript should be optional for all sites sort of pre-assumes that the experience when running sans JavaScript will be different, but you'll be able to get the same things done. In this one specific situation the difference being that you won't get any search feedback until you actually submit the form, old-school web style.
You can't. But do you really need to? Couldn't your webpage work without suggestions popping up as query is typed into the input box? Your webpage should not stop working if you can't validate user input client side, etc... .
See:
I find stack designed this way actually much saner.
Ideally, you want to have the best format for every platform you are targeting. The phone can have its app but the web should have a website that works like a website, not like a clone of a smartphone app.
You could also turn your argument around. Say you have a website and now you want to make a smartphone app. You wouldn't want to write an app that renders HTML and CSS that's served by a server, right?
I get that it seems sane to make an app out of your website when you already have an app for phones. But you must recognize that the web is really something else than a native program. And if you want to do it right, you need to treat every platform individually.
Logically, a rest API is a layer that is one level "before" html/css, since it only deals with data, and not rendering ( html needs data, not the other way around). Since web and native use different rendering technologies, the logical conclusion is to keep the common part of the stack at the data level, and not one level above it.
It is. However, since the API is already designed to be used securely by a client, it'll be a lot less work to make the browser be the client of the API.
The pet theory is wrong, by the way, it was not mobile that led to the rise of rich clients. When I worked on AppJet and EtherPad in 2007-2008, the rich client wave was ahead of the mobile wave. Round-trip latency is significant when interacting with a UI, even if it is just 100-200ms. It was obvious that if you could deliver a desktop-quality app that worked on every platform and didn't need to be installed, that that was the future.
I think it's worth focusing on the actual harm of certain ways of writing rich apps (e.g. breaking navigation).
If we just had a bytecode and VM standard, along the lines of Java, we could all stop talking and go to hell in our own way.
I believe Guido (creator of Python) wrote a browser way back then, in Python. So naturally it had the capability of scripting the client-side via python.
In case someone is curious:
I can't imagine it will actually happen for a few reasons, chief among them being browser vendor politics and the lingering taste of the failure of Java applets... but it would be nice.
But single-page apps completely break that. It then becomes some sort of hit/miss issue of whether or not that specific implementation of a single-page app's dynamic URL will behave nicely. Will it post, will it alter something, will it complain and just send me back to the main page? I don't know, and the URL doesn't necessarily tell me that.
Ironically, this is how I came across this post. I was trying to find valid/genuine criticism of single-page apps.
Many SPAs use the history API[1] to make a URL for everything -- Backbone, Angular[2] and such support this for example. React.js apps typically use some kind of router component that supports this (or they can use Backbone's Router).
Javascript is not the killer platform. I got it. Can we stop complaining?
Also: 10+ years of experience - does not understand `this` ha.
Gmail was launched in April 2004, not "years before". A nit, I know. I can summarize this article as "Javascript sucks".
That was true for a long time, but the world has moved on since 2003. ES5 strict mode fixed some of the issues. ES6 fixes a lot more. Since then many frameworks and tools have been developed as coping mechanisms. Closure Compiler, CoffeeScript, GWT, TypeScript, Flow, etc.
I'd actually say that client side Javascript hasn't gone far enough. There is much to do to improve the Web platform itself, and relying excessively on server rendered markup that gracefully degrades is not going to convince people to stop writing native code, if anything, it'll make it far worse, as network radio latency makes relying on server round trips for UI transitions bad on even the best mobile networks, and extremely bad in developing world wireless environments.
1. JavaScript has numerous design flaws, mainly wrt giving developers many very large guns with which even experienced devs can easily shoot themselves in the foot.
2. Languages and frameworks targeting the server-side of the web are suited very well -- better than JavaScript, historically -- to creating dynamic HTML.
3. Complex UI interactions typical of single-page applications are inherently difficult to do well.
I am not sure why the first two commenters seem to dismiss his entire essay because he uses scoping issues as an example, but that's pretty unfair & close-minded.
2. I don't know what to say about this. Maybe historically, yeah. But nowadays? You can build your API with any language or framework, and have nodejs running an isomorphic app. This means you can do server-side rendering and then delegate to the client once it loads. This provides the best possible experience. And you avoid code duplication, since you can run the almost the exact same code on the server and client. (You'll usually have to do some minor tweaks, which I'd consider reasonable.)
3. From what I've seen, complex UI interaction are difficult to do well regardless of your environment. (This is also why I've been really excited about react+flux, since it provides a much better experience when developing applications.)
> But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well.[1]
Anyway, we probably agree on this topic but are dickering over something tangential (whether JavaScript sucks). I'm a big React+Flux fan as well. I never enjoyed front-end development, and really I avoided it, until React came around.
Yeah that's what I meant by #3. Independent of runtime, language or implementation-specific particulars. It's... gooey.
There's just no choice. The stakeholders have decided suddenly JS is the new way to write apps, these type of people won't know how to code if you put a gun to their heads, even worse are developers refusing to use conventional tools like PHP or Python or Ruby for writing server backends.
I've never forced JS or SPA on someone that had no place for it but unfortunately they are willing to pay more to have it rewritten in JS.