News for hackers. Stuff that matters.
Re:Missing the Point of Server-side Rendered JavaScript Apps by chrisdotcode on Thursday February 05, 2015 @02:01PM (#9005127)
EDIT: Lots of downvotes for saying that there are other ways to program apps besides doing everything on the client. Render content on the server, enhance content presentation on the client.

---

I don't get it. Is this 1996? Why are people just now 'discovering' that you don't need to throw JS at an application to have it completely usable?

> All modern websites, even server-rendered ones, need JavaScript. There is just a lot of dynamic stuff you need to do that can only be done in JavaScript.

Really? Look at Linode, Amazon, or even Google (including GMail, and probably others). All of which are big names that can and do work ENTIRELY without JavaScript.

> Client-side JavaScript applications are damn fast.

Another (AJAX) HTTP request + rendering the returned data on a tiny mobile phone is faster than one HTTP request for the entire webpage and having dedicated machinery pre-render the content for you? I don't think so. He does talk about this point later on, but which is it? Client-rendered JS apps are, or aren't fast?

---

JS Hipsters offloading rendering everything to the client for absolutely no reason is the 'everything-looks-like-a-nail' or the 'everyone surfs the web like I surf the web and has my specs' problem. Worst of all, in doing so, they completely neglect actual content. You don't know how many million-dollar VC-funded company webpages I've visited that don't even have a damn tagline visible on their landing page without JavaScript enabled. <h1>s with actual content inside of them are too complicated now?

The solution is very simple: render all the data on the server, and progressively enhance subsets of your app with JS, by overriding the defaults of the rendered page. It's literally like we're discovering DHTML all over again.

Re:Missing the Point of Server-side Rendered JavaScript Apps by mixonic on Thursday February 05, 2015 @02:24PM (#9005304)
Linode, Amazon, and Google all absolutely use JavaScript. Tom isn't saying that they use JavaScript on the server, he is suggesting that JavaScript is involved with their website despite using a different language on the server.

Look, saying "client-side JS apps are damn fast" is a vague statement.

What we are talking about here is the architecture of a client-side application in any language. If you can ship application code to a local runtime, then that application code will always be able to respond to user interaction faster than fetching the results of a UI interaction (like a click) from partway across the globe.

The benefits of Client-side JavaScript applications do not come directly from JavaScript. They come from the architecture you can build when treating the Browser as a runtime for applications.

Progressive enhancement (beyond very small apps) is a challenge to maintain, since UI state needs to be shared between a server runtime and client runtime. I don't think there is disagreement that a pure server-rendered app or a pure client-rendered application would be simpler.

And your comments about shitty execution of web pages and apps could apply to any shitty app. They have nothing to do with client-side JavaScript applications. I expect a better argument than "I once saw a webpage that sucked".

Re:Missing the Point of Server-side Rendered JavaScript Apps by chrisdotcode on Thursday February 05, 2015 @02:33PM (#9005363)
> Progressive enhancement (beyond very small apps) is a challenge to maintain, since UI state needs to be shared between a server runtime and client runtime.

It does? Why? The server is handling the data to be rendered either way, and as I say in response to another comment, rendering the data is as simple as:

    res.end(render(template, data))
> And your comments about shitty execution of web pages and apps could apply to any shitty app. They have nothing to do with client-side JavaScript applications. I expect a better argument than "I once saw a webpage that sucked".

The argument is "you are VC-funded, and taking a 1mil+ dollars to build the Next Big (S|P)aaS. You are spending tons of money on A/B testing, designers, mockups, UI specialists, and your page does not even load for the lowest common denominator - and easiest to manage (static HTML) users of the web?"

The web was built for content-first, not flash.

Re:Missing the Point of Server-side Rendered JavaScript Apps by iamstef on Thursday February 05, 2015 @02:39PM (#9005411)
My experiences may be biased, but most startups I work with have target audiences that do not include tin-foil hatted JavaScript disabling individuals.

To the contrary, for them investing any energy in servicing this minority would be a mistake.

I suspect their exists some subset of startups were this may be reversed. But they are absolutely in the minority.

Re:Missing the Point of Server-side Rendered JavaScript Apps by chrisdotcode on Thursday February 05, 2015 @03:01PM (#9005587)
But that's the thing. It's far easier to 'program' a static HTML than any other dynamic alternative.

What people seem to not understand is that the exact same template that they are using on the client renders exactly the same on the server.

Re:Missing the Point of Server-side Rendered JavaScript Apps by dsp1234 on Thursday February 05, 2015 @02:40PM (#9005418)
(including GMail, and probably others). All of which are big names that can and do work ENTIRELY without JavaScript.

Gmail has an html/css only interface that uses no javascript. I use it every day, and everything just works. Additionally, on my device it's much snappier even with full page refreshes. This rebuts the original assertion that "All modern websites, even server-rendered ones, need JavaScript.".

Re:Missing the Point of Server-side Rendered JavaScript Apps by dsrw on Thursday February 05, 2015 @03:45PM (#9005928)
This is an entirely different frontend that was added years after Gmail launched. The interface that most of us use absolutely won't function without JavaScript.

Adding a pure html view to a mature, profitable application to appeal to a niche audience probably makes sense. Building it that way from the start probably doesn't.

Re:Missing the Point of Server-side Rendered JavaScript Apps by ta_75000 on Thursday February 05, 2015 @02:12PM (#9005210)
> Why are people just now 'discovering' that you don't need to throw JS at an application to have it completely usable?

I think a new generation of developers for whom the web has always been, essentially, a rich and dynamic applications platform is 'rediscovering' that it's really just document markup with Turing completeness on the side.

Re:Missing the Point of Server-side Rendered JavaScript Apps by sanderjd on Thursday February 05, 2015 @03:50PM (#9005974)
You don't seem to have that many downvotes right now, but I downvoted you, not because you said there are other ways to program, or even because I disagree with you that we've swung the pendulum too far toward the client, but because your comment seems to willfully ignore everything the article says. Here is what I mean:

> JS Hipsters offloading rendering everything to the client for absolutely no reason

Whether you think the reasons given are good or not, it is inarguable that the article lays out man reasons, so coming back and simply claiming there is no reason is not in good faith.

What's interesting is that the solution described in the article is functionally equivalent to what you think the solution should be, but you still don't seem to like it, presumably because retains the advantages of an approach you dislike.

Re:Missing the Point of Server-side Rendered JavaScript Apps by ctide on Thursday February 05, 2015 @03:57PM (#9006032)
You're getting downvoted because you miss the point. You want the web to cater to you, and big companies with infinite resources will, but smaller companies just won't. The cost to support users such as you is just not worth it, you're too small of a segment. People are going to focus their design + resources on the 99% of users who have decided they want the web to work properly.

I mean, shit, lots of startups completely eschew IE support, and they're a way more significant portion of the market than the neckbeards who disable javascript.

Re:Missing the Point of Server-side Rendered JavaScript Apps by chrisdotcode on Thursday February 05, 2015 @05:10PM (#9006488)
> The cost to support users such as you is just not worth it, you're too small of a segment.

You don't understand. The web is content-based. Like motherfuckingwebsite.com [0] shows, you don't need dynamic content to present your message. If I need to download 1MB of JS to see your freaking tagline, then that's ridiculous.

[0] https://news.ycombinator.com/item?id=6791297

Re:Missing the Point of Server-side Rendered JavaScript Apps by jjbiotech on Thursday February 05, 2015 @02:23PM (#9005300)
> Another (AJAX) HTTP request + rendering the returned data on a tiny mobile phone is faster than one HTTP request for the entire webpage and having dedicated machinery pre-render the content for you? I don't think so. He does talk about this point later on, but which is it? Client-rendered JS apps are, or aren't fast?

Very large generalization, it depends on the specifics of an implementation. Plus this isn't as scaleable since you're consuming CPU cycles rendering views on the server.

> The solution is very simple: render all the data on the server, and progressively enhance subsets of your app with JS, by overriding the defaults of the rendered page. It's literally like we're discovering DHTML all over again.

So you're telling me to write a web app that consists of: A Server-side application, multiple page-specific JavaScript "widgets", and an API endpoint for AJAX communication. That doesn't sounds very fun or efficient for the programmer. It's is taking a step back in time in terms of developer happiness, and application complexity (and possibly efficiency but that's implementation specific). Also, what about saving UI state?? Good luck with that...

What sounds better to me is a single RESTful interface and a JS application that renders all of your views. It does have it's downsides (SEO + tin-foil hat people disabling JS), but it's a much more elegant solution.

Re:Missing the Point of Server-side Rendered JavaScript Apps by iamstef on Thursday February 05, 2015 @02:20PM (#9005268)
> Really? Look at Linode, Amazon, or even Google (including GMail, and probably others). All of which are big names that can and do work ENTIRELY without JavaScript.

I think we can all agree, maintaining two discrete code-bases is a sub-optimal experience. Especially for companies without the resource of the "big names" you point out.

> Another (AJAX) HTTP request + rendering the returned data on a tiny mobile phone is faster than one HTTP request for the entire webpage and having dedicated machinery pre-render the content for you? I don't think so. He does talk about this point later on, but which is it? Client-rendered JS apps are, or aren't fast?

Several reason why this experience results in a faster mobile experience.

- cached data serves extremely quickly ;) - pre-emptively loading data to prime the cache. - data is smaller then data + html. - the app remains usable during loading phases.

Additionally, separating the concerns of rendering and data loading, does afford more creative optimizations as the need arises.

Re:Missing the Point of Server-side Rendered JavaScript Apps by chrisdotcode on Thursday February 05, 2015 @02:25PM (#9005314)
As I've said,

> The solution is very simple: render all the data on the server, and progressively enhance subsets of your app with JS, by overriding the defaults of the rendered page. It's literally like we're discovering DHTML all over again.

Client.js, rendered on the client:

render(template, data)

Server.js, rendered on the server:

render(template, data)

---

They're exactly the same. You use a templating engine library for either JS, or your server language to process the same data. What client.js should do is change things dynamically, progressively.

Re:Missing the Point of Server-side Rendered JavaScript Apps by iamstef on Thursday February 05, 2015 @02:30PM (#9005344)
One hard part becomes synchronizing ephemeral UI state between client and server. Such as data not-yet saved, or various UI components that are toggled into some sensible state.

As the complexity increases, this problem explodes.

One can use local storage (when available), but unfortunately this isn't always available, or needed.

Another thing you can do is bounce state back & forth with requests. Unfortunately this becomes a synchronization nightmare.

It is extremely nice to allow ephemeral UI state to remain in the UI. Merely syncing non-ephermal state, and populating a client side pool of data that is quickly addressable, and thus "instant" from the perspective of the UI.

Mitigating the latency of mobile networks is key here, no latency due to data-locality is the only way. Short of Quantum entanglement Physics isn't on the side of server-side rendered experiences.

Re:Missing the Point of Server-side Rendered JavaScript Apps by chrisdotcode on Thursday February 05, 2015 @02:35PM (#9005372)
I agree. This is the progressive enhancement I've talked about earlier.

Present a long, full form for JS-less users, and present it all nice-ified for those with, and send it off for server processing when you're done.

Re:Missing the Point of Server-side Rendered JavaScript Apps by ac2u on Thursday February 05, 2015 @03:36PM (#9005850)
I think you're simplifying too much in order to make a point. And I've no doubt your point is valid in a lot of cases.

However, this idea of a template rendered on the server and then the same template on the client is often fraught with difficulties the more interactive your application gets.

It gets more complicated when you want to 'componetize' your javascript. A couple of years ago to do that I would have brought in something like backbone.

"I know!" I thought, "I'll switch my templating to mustache, which has a parser in both ruby and javascript. Then I'll have ruby render the page with mustache using a ruby hash. Subsquent AJAX updates then pull down JSON in the same shape and I'll have Backbone use that same mustache template to render it! That way I can send the HTML down from the server pre-rendered for speed and SEO and then progressively enhance!"

All great in theory, but then I had to build awareness into my components so that they could be instantiated without a pre-existing representation built by the server or attached to a pre-rendered version made in Ruby. (You don't want to only make a component that NEEDs a real DOM to be tested do you?)

So while I agree your advice is great for forms, I've found real world cases of highly interactive applications where it reaches its limits. And the proper progressive enhancement we need is only coming now thanks to efforts like this and isomorphic react applications.

Re:Missing the Point of Server-side Rendered JavaScript Apps by bsimpson on Thursday February 05, 2015 @02:34PM (#9005370)
That's…exactly what the article is advocating.
Re:Missing the Point of Server-side Rendered JavaScript Apps by chrisdotcode on Thursday February 05, 2015 @02:39PM (#9005408)
I'm not bashing the article - I'm referring to the mindset necessary for the fact that this article even needed to be created. Server-side rendering should have always been first-class.
Re:Missing the Point of Server-side Rendered JavaScript Apps by sanderjd on Thursday February 05, 2015 @04:18PM (#9006179)
What you're missing is the whole part of the article that talks about why many people migrated to that mindset. You are dismissing the problems out of hand, as unimportant and easy to work around, which is frustrating for the many of us who changed our mindsets in search of a better solution to those problems, which client-side-heavy apps absolutely are. But the better solution had trade-offs; it spoke to many real problems with the fully server-side rendered approach, but caused new problems. Now we're starting to find solutions to those new problems without giving up the entire approach. That's a good thing. Your comments don't seem to argue that it's a good thing, but rather that the whole endeavor has been folly, which, for many people, just isn't true!
Re:Missing the Point of Server-side Rendered JavaScript Apps by chrisdotcode on Thursday February 05, 2015 @05:05PM (#9006462)
The oft-touted claim is that client-side templating is easier, but they're the same, really. The server solution is literally using the same exact templating engine and code.

What people are conflating is "doing things in the client with JavaScript" and "rendering templates in JavaScript", which are two entirely different domains.

You can't access many cool features client-side without JavaScript, full stop. But rendering things on the client, and presenting an absolutely un-usable design without turning-completeness is not content-first design.

Re:Missing the Point of Server-side Rendered JavaScript Apps by azakai on Thursday February 05, 2015 @02:10PM (#9005195)
> GMail, and probably others [..] All of which are big names that can and do work ENTIRELY without JavaScript.

Gmail uses massive amounts of client-side JavaScript (perhaps compiled from a different language, of course).

Re:Missing the Point of Server-side Rendered JavaScript Apps by chrisdotcode on Thursday February 05, 2015 @02:12PM (#9005209)
There's an option for the basic HTML layout available if you have JS disabled.

That's the second-best approach. The first is using a JS-redirect to the flashy AJAX page, or just overriding all the default handlers necessary with JavaScript (remember, at this point, your content was already (supposed to be) properly rendered for you by the server).

Re:Missing the Point of Server-side Rendered JavaScript Apps by azakai on Thursday February 05, 2015 @02:39PM (#9005406)
Sure, there is an option for a no-JS version of Gmail, but the default definitely uses Gmail, because the user experience is much better - I think that's pretty clear.

I agree doing some work on the server can also make sense, and that the new pre-rendered JS is an extension of progressive rendering which is not a new technique. It's a new way of doing it, though.

Re:Missing the Point of Server-side Rendered JavaScript Apps by dredmorbius on Thursday February 05, 2015 @03:25PM (#9005767)
What you've failed to grasp, twice, is that these sites do have javascript-free versions. Which work.

Not that they don't also have JS-infested versions. Which also sometimes work.

Re:Missing the Point of Server-side Rendered JavaScript Apps by dsrw on Thursday February 05, 2015 @04:08PM (#9006106)
In most cases these are separate apps. "Just build it twice!" is necessary in some cases, but is far from idea.

Progressive enhancement is hard, at least for complex interfaces that need to maintain state. Hard enough that many sites, if they support disabling JS at all, do so by writing an entirely new frontend with a simplified feature set.

Ember + Fastboot provides many of the advantages of progressive enhancement, but is far more productive in many cases.