News for hackers. Stuff that matters.
Re:Principles of Rich Web Applications by mwcampbell on Tuesday November 04, 2014 @08:04PM (#8560007)
Is there any web application framework, presumably encompassing both client-side and server-side code, that implements these principles? I'm guessing that Meteor comes closest.
Re:Principles of Rich Web Applications by rdtsc on Tuesday November 04, 2014 @10:19PM (#8560380)
N2O is another one.

https://github.com/5HT/n2o

It is really different and extreme -- in a good way. It supports both server side or client side rendering. It seems mobile performance and concurrency were the main goals in building it.

But it also takes things to another level, such as it establishes a Websocket connection after it loads the page then, lets you shuffle page data as a binary (!) payload over.

I've only played with it as I am not doing much web related stuff at the moment but it looks pretty cool.

Re:Principles of Rich Web Applications by nateps on Wednesday November 05, 2014 @01:51AM (#8560779)
DerbyJS (http://derbyjs.com/) is built specifically for these principles. I'm working on big updates to the documentation right now, but I can say that we have a great solution for Server HTML + Client DOM rendering, realtime data updates, and immediate optimistic updates on user interaction in the client.

By building on ShareJS, DerbyJS uses Operational Transformation for collaborative editing of data in realtime, which means that users can see data updated immediately in their browser even if other users can edit the same thing at the same time. This is the same approached used by Google Docs.

Re:Principles of Rich Web Applications by nateps on Wednesday November 05, 2014 @01:54AM (#8560786)
Also, here is a video from a very informal talk I gave on similar concepts last year at our office: https://www.youtube.com/watch?v=iTC5i63eOzc
Re:Principles of Rich Web Applications by chops on Tuesday November 04, 2014 @11:38PM (#8560534)
Nitrogen for Erlang (http://nitrogenproject.com/) does much of this. N2O, also mentioned in another post, is a variant of the Nitrogen approach.

Basically, you build your application frontend with pure Erlang terms to construct server-side templates, then make live changes to the interface over and websockets (as of the soon-to-be-released v2.3), ajax, or comet (if websockets are not available, or the websocket connection crashes, it'll establish reconnection or fallback to comet/ajax).

I recently did a talk at the Chicago Erlang Conference about it: https://www.youtube.com/watch?v=nlV4gm8SpVA

Re:Principles of Rich Web Applications by aliakhtar on Tuesday November 04, 2014 @08:18PM (#8560049)
GWT is quite close, it allows both client & server to be written in Java which is then compiled to Javascript. A lot of the criticism of SPAs here doesn't really apply to it, as all your css / javascript files, and even most of the images, are compiled into one html file, and only that file is loaded at page load. That reduces the number of http requests, and with gzipping and caching, your page loads up quite quickly.

All of the other things, including history management / back button, are built into GWT.

Re:Principles of Rich Web Applications by neolefty on Tuesday November 04, 2014 @08:34PM (#8560086)
By principle 1, "Server rendered pages are not optional", I think GWT is missing a big piece: it doesn't let you choose between server-side & client-side rendering -- instead it's designed to make client-side rendering easy.

Yes, GWT can be quick, but it still has to make those extra round trips to get data from the server. If it had an option to render the initial page wholesale on the server, it could get that first impression up faster.

In order to add that to GWT, you'd have to emulate the first few rounds of communication on the server --- incorporate a server-side DOM model & fake communication layer, either using the cross-compiled JS or Java. Maybe leverage the debugging tools?

Re:Principles of Rich Web Applications by cromwellian on Tuesday November 04, 2014 @10:34PM (#8560414)
GWT UiBinder doesn't permit server-side rendering, but other templating systems do (Google Flights for example uses GWTSOY, Google Inbox uses something we call JsLayout)

GWT has always supported minimizing the number of HTTP requests. For example, GWT RPC long supported pre-serializing the first couple of requests into the initial HTML, so that you don't need to do an AJAX request before you can render.

It's also one of the first, if not the first, framework to support automatic asset packaging, sprite-sheeting, etc (since 2009). This inlines all CSS, small images, and other resources into a single chunk, which can be downloaded in one HTTP request.

I am working on an architecture I call POA, Page Oriented Architecture, which combines the best of Web Components, React-JS style binding, and server-side rendering into a single framework for GWT.

Google already uses "patching" to deliver small pieces of JS, we call DeltaJS. So when you visit inbox.google.com, the server computes the diff between what you have in local storage, and what has been recently pushed, and sends down a patch that updates your cached copied. I'm looking at combining this with ServiceWorkers for GWT so that all GWT apps by default can leverage offline and delta-js application. Hopefully I'll have something to show by the GWT.create conference (gwtcreate.com), we'll see.

Re:Principles of Rich Web Applications by stephen on Wednesday November 05, 2014 @12:27AM (#8560625)
> JsLayout

I went looking for Inbox's template engine and came across:

https://code.google.com/p/google-jstemplate/wiki/HowToUseJsT...

The "jstcache" attribute looks the same. Although, looking at the code.google.com project's source, it doesn't look like any code/non-wiki changes since ~2008. So maybe a forgotten attempt at open sourcing the/precursor-to JsLayout?

POA sounds interesting; hopefully it'll have a great unit testing story too?

Re:Principles of Rich Web Applications by cromwellian on Wednesday November 05, 2014 @01:38AM (#8560755)
Yeah, that looks like an early version of it, I'll ask why we aren't developing it in the open anymore (it may have been because of rapid changes need by Inbox)

The central idea of Page Oriented Architecture is to return to the Web 1.0 era of "A URL for everything", where the application consists of a bunch of pages, and if desired, any page can be rendered server-side.

However, what really happens beside the scenes is GWT processes all the pages for the whole site, synthesizes an application, which each page between a GWT "splitpoint". So you have your cake and eat it too. An application that is developed a 'page at a time' with crawlable, indexable, server-side URLs for everything, while at the same time, you get a monolithically compiled, globally optimized, Single-Page-Application out of it.

There's an old set of slides here: https://docs.google.com/presentation/d/1JobclkctBvciYZ8CzHIo...

However, that's since been super-ceded by a system I'm working on that makes everything look like Polymer, only it's monolithically compiled and optimized, and using ReactJS style virtual DOM-diffing.

I want to combine this with DeltaJS techniques and ServiceWorker to produce offline-by-default high performance mobile web apps out of the box.

Re:Principles of Rich Web Applications by aliakhtar on Tuesday November 04, 2014 @10:46PM (#8560438)
> Google already uses "patching" to deliver small pieces of JS, we call DeltaJS. So when you visit inbox.google.com, the server computes the diff between what you have in local storage, and what has been recently pushed, and sends down a patch that updates your cached copied.

Does that mean that if a user has an app cached, but something changes within only a single split point in that app, then the user only has to re-download that split point, vs re-downloading the whole app again?

Re:Principles of Rich Web Applications by cromwellian on Tuesday November 04, 2014 @11:18PM (#8560494)
I'm not sure how that'll work yet. I don't maintain the DeltaJS infrastructure, I use just it, and as of now, Google Inbox doesn't use code splitting, however that is the focus of post-launch activities, reducing code size download, making startup faster, etc.
Re:Principles of Rich Web Applications by aliakhtar on Tuesday November 04, 2014 @09:13PM (#8560197)
Actually, with GWT you don't have to load your whole app on page load. You can divide your code, and only load the code needed to display a loading / splash page, on initial load. This way, there's only about ~100KB of code loaded initially, which brings up a splash screen very quickly, and then the next batch of code is fetched and displayed.

Also all of these files are cached once loaded, so they don't have to be loaded again until they are changed.

Re:Principles of Rich Web Applications by xtrumanx on Tuesday November 04, 2014 @09:55PM (#8560309)
A splash/loading page is a workaround to avoid the user seeing a blank/unusable page while your app loads.

The goal of server-side rendering is to show the user everything he supposed to see when a typical single-page-app loads, shows the a splash page, fetches the initial data and renders it on the page.

From your description, GWT does not offer that.

Re:Principles of Rich Web Applications by aliakhtar on Tuesday November 04, 2014 @10:30PM (#8560408)
Fair enough, but if you render the page on server, you will likely have to do some processing (e.g database/api calls) in order to get the data to display to them. The screen will be blank while all of this is going on.

If you go the splash / loading page route, users will immediately see the loading screen come up.

Plus, with the 'render on server' route, if users visit any other page, they will have to wait for a full page reload, whereas with an SAP, they will just see a loading icon for a second or three before the new page will come up.

Its a lot more responsive overall, and the pros outweigh the cons in my experience.

Re:Principles of Rich Web Applications by neolefty on Tuesday November 04, 2014 @11:26PM (#8560509)
The article is advocating for a framework that does both -- it renders the initial impression on the server (yes, including a few DB reads), snapshots it as an SPA, sends it to the browser, and then lets the user continue the interaction that began on the server.

It adds significant server complexity for what some would call a minimal improvement in setup time. The article is advocating it for exactly that: overcoming that (maybe minimal) setup time on the client, which includes a one or more server round trips.

In many cases, this will undoubtedly be premature optimization. But if the framework made it easy, then it might simplify your transaction model. You could unbundle transactions, knowing that you aren't paying a latency tax on them, at least on startup, since it's all happening on the server.

Re:Principles of Rich Web Applications by aliakhtar on Wednesday November 05, 2014 @02:16AM (#8560822)
I would rather have something show up for the user immediately, than have him see a blank screen while DB calls are going on at server. But, to each their own.
Re:Principles of Rich Web Applications by heliodor on Wednesday November 05, 2014 @07:47AM (#8561525)
My perception of how fast a page loads is that if you show me an 'app loading...' splash screen, it makes me feel your page is slow and bloated. I react better to a blank screen with the browser's progress bar moving. I suppose it's because it allows me to shift blame away from your webpage to the quality of my internet connection.
Re:Principles of Rich Web Applications by cbsmith on Tuesday November 04, 2014 @09:44PM (#8560284)
I'd say cheerp pretty much nails it. http://leaningtech.com/cheerp/
Re:Principles of Rich Web Applications by ogig on Tuesday November 04, 2014 @08:47PM (#8560126)
Meteor fails the server rendering principle, at the moment it serves an empty body and the client does all the rendering.

Server side rendering is on the roadmap tho.

Re:Principles of Rich Web Applications by arunoda on Tuesday November 04, 2014 @10:24PM (#8560391)
Re:Principles of Rich Web Applications by Svenstaro on Tuesday November 04, 2014 @09:59PM (#8560326)
[Wt](http://www.webtoolkit.eu/wt) seemlessly degrades from websockets over ajax with polling down to rendered HTML and it's extremely fast being made in C++. It also qualifies for many other things. Check it out.
Re:Principles of Rich Web Applications by reverius42 on Wednesday November 05, 2014 @03:09AM (#8560924)
React seems to do pretty well on this list (though I don't think it helps with hot code reloading, for instance). It allows for very clean server-side initial rendering (via nodejs) and subsequent client-side updates (with a stateless DOM).
Re:Principles of Rich Web Applications by Offler on Wednesday November 05, 2014 @08:18AM (#8561615)
He does mention React as being a library that hits some of the points, some of them are just your own personal UX/project decisions which a framework would have no say over.
Re:Principles of Rich Web Applications by morgante on Wednesday November 05, 2014 @02:49AM (#8560880)
Rendr from Airbnb is pretty close: https://github.com/rendrjs/rendr
Re:Principles of Rich Web Applications by jamesbrewer on Tuesday November 04, 2014 @09:13PM (#8560195)
This is not the right question to ask.

Instead of trying to find one tool that solves all of your problems, try understanding what your problems are. Once you have a list of problems, ask how you can solve each of those problems. When you have solutions, THEN you figure out which technologies are best for implementing those solutions.

Re:Principles of Rich Web Applications by sanderjd on Tuesday November 04, 2014 @09:24PM (#8560230)
The reason frameworks exist and are often very useful is that if a set of problems is common enough, it is more efficient to do your first few steps once and wrap the outcome up in commonly usable components. "Web application with good UX" is a very common set of problems, so it is sensible to wonder if the leg work has already been done.
Re:Principles of Rich Web Applications by acemarke on Tuesday November 04, 2014 @11:48PM (#8560557)
That's pretty much the argument I had to make on my current project. We've got an internal smart client app-in-a-browser that we built last year after throwing away a legacy system. Unfortunately, we were on a tight deadline, and most of the team had little serious JS experience. The client codebase just grew grew randomly, with no real architecture or design, and turned into a giant maze of nested jQuery callbacks and 2000-3000 line JS files. I'd suggested we look into some MVC frameworks before we started development, but then I wound up working on a separate task and no one had time to actually go research, select, and train everyone on a new framework. During the development process, one dev in particular was busy building his own little framework from scratch. Looking at it later, he was basically reinventing Backbone.View, including templating and saving a jQuery reference.

After we hit our initial development deadline, we had time to actually research Angular, Ember, and Backbone. We settled on Backbone on the grounds that we could refactor our codebase incrementally, and it seemed to fit our use case best. Unfortunately, this later led to clashes with the "write it myself" dev, as he didn't want to use any outside frameworks beyond jQuery.

Anyway, having used Backbone for the last year, it definitely has a lot of limitations, but it also provides a very definite set of well-tested pieces that clearly help solve common development use cases. So yeah, very much in agreement with you there. Why try to totally build something from scratch if someone else has already done it for you, and it's been battle-tested by other developers?

Re:Principles of Rich Web Applications by jamesbrewer on Wednesday November 05, 2014 @09:53AM (#8561960)
I agree, but I stand by my statement. Asking "What framework should I use?" is not a good sign. Using the process I outlined could easily answer this question.
Re:Principles of Rich Web Applications by sanderjd on Wednesday November 05, 2014 @02:47PM (#8563841)
If you start with "how common is my problem?" and the answer is "extremely", then it is reasonable for the next question to be "should I use a framework that solves this common problem?", and you should have very good reasons if you want to answer "no" to that. If you answer "yes", then you have quickly arrived at "what framework should I use?". I guess perhaps we agree that "what framework should I use?" should not be the first question, but I don't think it takes long to get there.

I personally prefer (and find it more fun and a better learning experience) to build things from scratch with no frameworks at all, but I don't think it's a very savvy business decision unless you're doing something very novel.