138 points · by bpierre · 10y ago · 144 comments
Everything else should be a traditional static web site with "decorative" JS, or "progressive enhancement".
Not only feasible, it's extremely easy to do these days with things like React (+Redux). We're about to launch a fairly large project for an Australian broadcaster using this approach and it's been incredibly simple to do.
And there's nothing ~magic~ that React does to make this possible - it would be quite trivial to 'roll your own' framework for this. Best of all, you could start with doing it just server-side and then roll out the JS to 'the other side' later on.
http://rackt.org/redux/docs/recipes/ServerRendering.html
On server request, render the first snapshot of a React app into pure HTML and send it out, and then that HTML snapshot uses a script tag to get the actual JS file of the react app.
I think it's important to start recognizing that there's two distinct types of web "applications" starting to emerge: the more traditional kind of "application" that is actually more like a web site, and the newer kind of application that is more like an actual application (desktop/mobile).
Edit: Just read the new guidelines, and they are now considering serving up different content for the crawler as being "against the rules". So that probably cements the idea that you shouldn't allow Google to crawl anything that's mostly content-free and just an "app".
That is called "cloaking", and Google has said this for a very, very long time. At least 10 years.
So too many possible failure points, and for these reasons it will timeout many times, resulting in increased crawl errors, apart from page load time degradation. I learned this the hard way, and had to revert to server side generation of crawlable pages. And now looking at something like react/redux to achieve what I originally wanted (which is basically again server side generation, but while maintaining the quality of the served pages).
That said, the apps do need to remain accessible to those with screen readers, vision issues, motor impairments, and cognitive issues. They need to be accessible to those with slow or spotty connections. But search engine optimization is about content sites, not necessarily apps.
Static pages are perfect for those cases, and I am thrilled to see more people coming around to that.
So how's it going in JS land, are you guys still reimplementing Windows 3.1's message passing loop and hailing it as a revolution ? :^)
Or maybe you're still busy pulling in literally 10+MBs of code on top of a 100+MB browser to fix the shortcomings of what is a terrible language ?
Or maybe you're busy trying to get performances that matches what a 68060 could do thirty years ago. Oh right, browser vendors had to agree on WASM to get OK performance. So basically, not Javascript.
But hey, I guess it's crossplatform. Kind of.
But promised, once transpilers are good enough, once I can use a good, strongly staticly typed language, once the APIs are stable and the tooling becomes tolerable, I'll join the SPA side.
But meeting the needs of customers is what I get paid to do. And customers don't want server-side rendered stuff. They hate losing their place when they add a row of data.
So what are ya gonna do?
See, I hate JS. I think it's terrible. If there were any other choices out there, I don't even think it would still be a thing if there were any other options.
But it's a requirement of a modern web developer to know how to do it well. And I'm a web developer. So I'm going to be good at it. At least as good as I can be given the tools I use and constraints I have.
Typescript is a plenty good enough, statically typed language that transpiles to whatever flavor of JS/ES you need, including ES3 if for some reason you are stuck supporting IE < 8. Typescript has a good ecosystem of tooling (try Typescript in Visual Studio Code, for instance).
As for API stability, it largely depends on the SPA Framework you want to try. Yes, the problem is that there are so many to choose from and some of them do wonky things like reimplement the old GUI message passing loops and call it progress.
If you want my biased opinions on SPA frameworks: These days I use CycleJS when I get the choice, as it is simple, gets out the way, and built on top of RxJS for true reactive programming. It's simplicity provides a very small API overall and thus a considerable amount of stability for said API because of its smaller surface area. If you need something a bit more time tested with the broadest classic browser support, I think Durandal (Knockout-based) is a stable, well worn SPA framework. Having used Durandal in the past I admit that Aurelia, it's successor, is likely to have a similar stability, as it matures.
TL;DR: The transpilers are good enough if you give them a shot. Typescript is a great statically typed language for the web. SPA APIs are crap shoot, but there are good options out there, especially if you stray just a tad out of the way of the hype trains.
I do agree about the browser UI performance though - why I can't scroll a page without the tearing effect in 2016 on an 8 core machine with 16GB of RAM is beyond me ...
I've posted this before, but check out this link:
http://www.elevatesoft.com:8081/maxgridtest/maxgridtest.html
That app was created with our web development product (check the site if you want to know more), and has the following characteristics:
Two files, one HTML loader and one monolithic JS app, so latency during loading is minimal. The HTML loader is ~189K and the JS app is ~462K, and includes the entire runtime and UI layer, and a lot of the control/component library. Both the HTML and JS are aggressively compressed/obfuscated by a compiler, and the coding is done in a statically-typed, OO/procedural language with RTTI and other nice things. The UI was designed using a WYSIWYG designer with two-way tools (code-behind).
So, there are products/tools out there that will do something along the lines of what you want. And the existing JS engines are very good in terms of performance, so all that developers like us need to do is some quick compilation to JS and we're all set.
However, I do agree with you on two points:
1) JS, by itself, just isn't structured enough for large-scale applications.
2) The push towards libraries and away from frameworks was misguided because JS, by itself, doesn't have the means to allow for this approach to be successful. Instead, what we have now is every single small library reproducing the same functionality over and over again. Case in point: I was looking at writing an external interface (tells our compiler how to type-check external JS code) to ChartJS this week (great little library), and started looking at the code. 80-90% of the "common" code in the library was code that was already present, in some form, in our UI/runtime layer, and that was around 70K right there. Multiply this by the number of small libraries, and you end up with a lot of duplication of functionality that is, essentially, dead weight. I don't know if it's 10MB of dead weight, but it's pretty significant.
The vast majority of applications don't need to be searchable, the website that shows off the app does.
> Most web apps I work with daily have highly sophisticated in-browser interactions that are built with JavaScript and can only be built with JavaScript: Flickr, YouTube, Facebook, Twitter, GMail etc
The web apps that I use the most day-to-day are Trello, Slack and Gitter. IMHO, those are better examples of js bringing actual value to the table that progressive enhancement simply cannot.
With that being said, the issue of overusing SPA technology when it doesn't fit the need is definitely real.
Part of the issue comes from people wanting to pad their resumes w/ experience in "hot" technology, or people who do have a genuine interest in improving their skills, but are not very skilled in identifying the pros and cons of whatever "new hotness" or "best practice" they read on their favorite news aggregators. By extension these creates an industry for grunt work to maintain/refactor/rewrite everchanging codebases/frameworks. Coupled with the general tendency of people to favor new shrink-wrapped libraries over doing good ol' painstaking research, it's difficult to reverse that trend.
Never used them, are they important? What do they do? I've used all the ones cited as bad examples.
I do use Youtube/Facebook/Twitter etc as well, but I use them primarily for content consumption for entertainment, so my usage patterns of those services wouldn't be affected much if they were written without using javascript at all. In contrast, drag-n-drop and the ability for real-time collaboration are the killer feature of Trello (for me), and obviously there's no way web chat would ever work smoothly without js.
I'm wiling to bet C# is 10x better than the last time I used it. Except, I don't have a good excuse to use it again to see.
I think I can probably say that Javascript engines are an order of magnitude faster than they were 16 (!) years ago.
If I may make a generalisation, C#/Java devs are more likely to be "enterprise" developers and said enterprises were more likely to be the ones on IE <11. I know I fought damn hard to upgrade from IE8 just a couple of years ago. My webdev skills suffered as a consequence, too.
Microsoft moved pretty fast once they realised that IE needed to compete again - and Visual Studio evolved alongside it (mostly).
VS2015 is now a pretty good development environment for Javascript/Typescript and even includes some Grunt build support (although I haven't had a play with it yet).
Two orders of magnitude. I just checked, and on my laptop http://web.mit.edu/bzbarsky/www/mandelbrot-clean.html (the first JS thing I wrote where performance of the language itself seriously mattered) runs in about 30-60ms in modern browsers. On the same hardware, it runs in about 2200ms in Firefox 3, which is the last pre-JIT version of Firefox. Other benchmarks I've tried show similar improvements results. And that's only going back to 2008; the interpreter was a good bit slower another 8 years before that.
So was that a dig against jQuery?
>> People just don't appreciate how wonderful this language is.
Ever try adding a string and an integer in JavaScript?
I think developers who think JavaScript is great, love it because it's forgiving. Do what you want, the JavaScript siren says, it might work, it might not but at least you won't have an ugly all stop. I'll try to make it do something, anything, sings the siren.
No way I would disrespect jQuery in any way. I learnt a lot of JS by digging into jQuery code and from this book from its author "Secrets of the JavaScript Ninja" But I hate it when people who have done some simple basic programming and used jQuery think that they know JS
We're watching programming and design concepts which played out back with Windows 95 being hailed as "the future of programming". We're being told "worse is better" as Javascript is being used to turn our computers against their users by serving as a vector for malware, ads, and bots.
It's a mess, and it's going to take pushes from the far side of the pendulum's swing to bring it back to a sane place. If the pendulum was actually stalled too far towards "server side only", I'd agree that "server side only" articles would be too much - but we're not there.
> We can only improve the user experience with the front-end technologies we have.
No, we are more than capable of degrading the user experience with the front end technologies we have. There's a lot of proof of that on the web today. Delayed full page ads, pop-overs for every third word, hijacked scrollbars, malware installs...
Relax. You're talking about someone's opinion of a programming language.
That said, all of your comments come across as ignorant to me. I don't think you're ignorant, though. I think you know JavaScript really well and like it.
I personally found it unusable on the server until TypeScript became mature enough to use. Have you tried TypeScript or some other static-typed, better-defined language (Flow, Clojure, etc.)?
You may love JavaScript, but there's a good reason Facebook, Google, and Microsoft all find it to be unusable and have created compile-to-JavaScript languages so that their companies can be JavaScript-free someday.
I'm anthropomorphizing Javascript somewhat here, attributing the feelings of its community to the language itself. But from the point of view of someone whose first programming language was not Javascript, the trend is pretty apparent: We can run Javascript anywhere, so we will run it everywhere.
The only thing that's happening here is that a community has formed around an evolving language and is taking advantage of some great tooling and open source projects to do some interesting stuff. That community isn't formed exclusively of wet-behind-the-ears web developers. It's comprised of developers of all skills levels with experience in a multitude of platforms and languages, just like any other. These people chose JS because it works for them and their problem set. To suggest otherwise is condescending to say the least. Stop trying to paint the whole community with a single brush, you sound ridiculous. If JS isn't your bag fine, move on, but less of the JS shaming please.
They're building operating systems with it now.
See, NodeOS and Runtime.js.
The "Birth and death of Javascript" talk is beginning to look less like satire, and more like moderately accurate prediction.
I'll give you the passionate community point. I almost completely disagree with everything else.
JavaScript is a very immature platform.
JavaScript has probably the worst packaging ecosystem of any major programming language. The fine-grained packages, indirect dependencies, and frequently broken versioning cause endless problems in real world systems. Recent attempts to fix the package manager have unfortunately swapped one set of problems for another, while still leaving some of those fundamental weaknesses involving transitive dependencies and excessive trust of version numbering conventions unaddressed.
It does has rapidly evolving syntax and semantics, but at the expense of stability, portability and future-proofing. The only reason 99% of JS programmers use most of the new syntax and semantics is a combination of a transpilation tool written primarily by one (remarkable) person and a polyfill written primarily by one other (remarkable) person in their free time. Browser, tool and Node support for many of those new features is patchy, which is why that transpilation and polyfilling is necessary.
Tooling for JS is at least two decades behind the industry best-in-class. It's a dynamic language that now has such a huge mess of build tools associated with it that seasoned veterans of web development weep at the prospect. You can't reliably debug real world JS code in its natural form, even on the level of setting break points and examining local variables and call stacks, without jumping through all kinds of hoops, and in some browsers even then. Profiling also relies almost entirely on browser magic. There are lots of testing tools, but setting them up is often a chore and they have widely varying degrees of power and flexibility. We've only recently got a style checking tool that can actually cope with ES2015 reasonably well. Refactoring, auto-completion, documentation, navigation in your editor? What are those?
As for Node... I've seen experienced developers spend months trying to get basic stuff working in a cross-platform way with Node, and then seen other experienced developers do more in a week or even a day using C. Using Node is saying "I know, let's throw out a few decades of experience building reliable client-server systems and all the other tried and tested languages and tools and libraries we've developed over that time, and instead transfer all of those negative aspects of JS to the server side as well, even though unlike front-end developers we don't have to".
There is truly nothing about any of those that couldn't be done with a simple page refresh. Especially YouTube. Generally I find most of what JavaScript adds just irritating.
Our children won't believe we ever browsed the web in a graphical multitasking OS on 64mb of RAM and a single processor core. "Don't be silly, that wouldn't even be 1/6 enough to load Google Inbox!"
* Displaying the video
* Controlling the video (although with the browser's default controls)
* Being logged in
* Listing videos
* Voting
* Commenting
* Suggested videos
* Subscribing
Actually, I can't see a single thing that can't be done without Javascript. It has no complex notification system aside from annotations (and I'm not sure anyone enjoys annotations), nothing that isn't provided by browsers. But no javascript would require page refreshes, which makes for a worse UX. Eh, we survived refreshes before. Maybe browsers could even agree on a standard to refresh only part of the pages by querying the server themselves. Throw in five lines of JS to save to localStorage the current time on the video and restore it on reload.
> Maybe browsers could even agree on a standard to refresh only part of the pages by querying the server themselves.
Maybe browsers could also agree on implementing all needed applications in the browser. Then you just make <youtube> tag and you have implemented youtube.
But on the other hand, Youtube wouldn't have as many videos – specifically the content creators wouldn't have as much of an incentive to upload them – without the social features being there.
I wish. Either that, or `youtube-dl` became the official UI.
For example, should a blog rendered in the browser be treated as a web app? Or rendered principally as HTML and CSS before it's sent to the browser (rather than rendered in the browser using Javascript). Here's an example: over 300K of Javascript to render a plain text page: http://elm-lang.org/blog/new-adventures-for-elm
My impression is that some developers are beginning to treat anything rendered in the browser as a web app - even plain web pages with no dynamic elements.
Why do developers do this? Is it because it makes their life easier using a single tool or language for both dynamic and static content? Or is it because they want to learn a new framework that's popular or interesting? Whatever the reason, one has to ask if giving users a good and fast site experience comes anywhere into the equation.
Mostly this. As soon as you add a bit of dynamicism, it becomes easier to do everything in one language/workflow.
[1]: https://speakerdeck.com/henrikjoreteg/the-evolution-of-the-w...
[2]: https://joreteg.com/blog/viability-of-js-frameworks-on-mobil...
>We're convinced progressive enhancement remains an important aspect in pushing the boundaries of the web while still providing a robust experience for every user.
What?
EDIT:
>Your HTML is not more accessible or more semantic when it’s rendered on the server.
IDIOT DETECTOR TO FULL POWER. It is by definition more accessible if it doesn't require Javascript to render.
Good that GMail is created with GWT. So it doesn't even use JavaScript. Most people are so afraid of JavaScript that they create hella crazy abstractions (Angularjs [Google], ReactJS [Facebook]) and even then Microsoft and Google trying to avoid JavaScript more and more with Typescript or Dart, they transpile it. JavaScript maybe is valuable in the web, but not in it's current form. So much quirks that you either spend using a library or fixing browser incompabilites.
A lot of people here said that transpiling will be used a lot in the upcoming years, and I think that also. People will more and more. They want to use Python/Scala/Java/Whatever on both sides. Also it will reduce complexity by a lot.
Currently your typical webapp has, a server-side technology (even if you are using node), then you have a web frontend which uses at least npm, however mostly you end up with npm, bower, gulp/grunt, webpack and whatever.
> Client-server architectures instead of monoliths
What about small teams? They can't split their monolith since it will become unmanageable. So if they have two apps, frontend/backend it's still a mess to manage these projects with a small team.
> We need to stop excluding JavaScript apps from “the web as it was intended”. JavaScript apps are “of the web”, not just second-class citizens “on the web”.
In my eyes JavaScript should be used where it is needed, but not used in stuff which never should touch it. JavaScript is still a mess.
Inbox is built with GWT and Closure compiler together, as a hybrid app, with the UI done in Closure/JS, and the business logic done in Java so it can be shared with Android and iOS.
Over the past 2 years, the GWT team has been honing a new JsInterop spec that removes the majority of the impedance mismatch between Java and JS for hybrid apps, which will be part of the 2.8 release.
One of my favorite features is automatic Java8 lambda <=> JS function conversion. Any single method interface in Java, when marked with @JsFunction, can be passed to JS where it can be called as a regular JS function, likewise, any JS function can be passed back to any Java function accepting a single-method-interface, and it will pretend to implement the interface.
You can now write (GWT 2.8), code like $("ul > li").click(e -> Window.alert('You clicked me')) with only a few lines of code to interface with jQuery for example.
You can see a deeper dive here: https://drive.google.com/a/google.com/file/d/0BwVGJUurq6uVR1...
I have to disagree. Adding another layer of abstraction cannot reduce complexity, although it might make certain tasks easier. Consider assembly vs C as an example: C can make lots of programming tasks way easier, but the complexity of the system is not reduced.
With C, this becomes apparent when the program segfaults. A garbage-collected language or Rust can prevent segfaults using a subsystem to manage and/or enforce memory ownership, again making lots of tasks easier, while adding even more complexity.
In the case of transpile-to-JS languages, these can fix many of the shortcomings of JS and make lots of tasks easier, but they are a more complex system which can cause additional work if the generated code fails at run time, and the browser debugger brings up something completely different from your source code.
Your point that we will see more transpiled languages in the future makes sense.
You're right that it's not always less complex. Trying to trace an error through some of these systems is ridiculous. I miss the days of it just pointing to a line number.
Much as I dislike JavaScript, every other language uses frameworks or "abstractions" to be more efficient. Why the hell would I reimplement all that crap myself in Python when Flask or Django have done 90% of my app for me.
Angular and React are not abstractions of JavaScript the language. They are abstractions of the DOM API.
Highly sophisticated browser interactions? You mean adding a comment? Which you actually just did on Hacker news using zero javascript.
None of those sites need or require a lot of Javascript. In fact, when I use Gmail I have the standard html version set to default. It's much faster and time to inbox is faster.