Leaving JSPs in the dust: moving LinkedIn to dust.js client-side templates
engineering.linkedin.com
engineering.linkedin.com
If anyone from Linkedin is reading - any chance of getting this evaluation posted somewhere? Would be useful even if it's just a "tech x factor" matrix without commentary.
Any change you are going to discuss in more detail how to use the js templates on client and server side?
It felt natural as a programmer to develop the backend as a "library" that was "called" by the client side.
Immmmmense productivity. All pages require auth and shouldn't be indexed, so I don't worry about excluding search engines etc.
I'm relieved to see their staff know what they're doing, and even curl http://www.linkedin.com/in/example still yields content. An alarming fraction of devs and toolsets out there would have screwed this up so badly that their resources would be cut off from reuse by the rest of the web, trapped behind an unstable single-site API.
See also my answer to this question about single-page apps on Quora: http://www.quora.com/What-exactly-is-a-single-page-applicati...
This makes me question how much the project will be supported in the future - but I suppose having a large company like LinkedIn invested in the technology is a good sign.
It's interesting that LinkedIn chose dust.js as it doesn't get much attention compared to some of the other JS template languages (e.g. Mustache & Handlebars.js).
I used FreeMarker on a previous project, it's pretty cool ( http://freemarker.sourceforge.net/ ). There is also mustache.java ( https://github.com/spullara/mustache.java ). I heard about Velocity and StringTemplate, but never tried them out... I guess Groovy Server Pages could also be considered if one's company is open to Grails...
Anything else I should be aware of?
As far as limited, I looked at Django strictly for it's vaunted templating prowess and didn't see anything that isn't easily reproducible in JSP. There could be some magic there but I missed it.
For verbosity, sure, fn:toLowerCase(string) is technically more verbose than string|lower, but marginally so.
You mention an example where JSP fares best; there are a lot of examples that don't come out looking too great though, such as time/date/decimal conversion, the obnoxious syntax for if/else, etc. A lot of Django's other filters just don't exist in JSP.
But that aside, there are larger scale issues -- composition of templates via blocks in Django/Jinja, which is a lot easier and more flexible than Apache tiles; the lack of auto-escaping in JSP; and the forced XML syntax, even at the expense of valid HTML (see what it does to script includes or empty divs, without a <!-- --> in between).
Is this how Amazon - who reputedly has everything as services - renders its webpages as well ?
(Not that I suppose LinkedIn are too worried about search engine discoverability of a lot of their "dynamic, login required" content, but I'll bet they're _not_ using this technique on all those highly optimised pages full of people's names - like the 4th Google hit for my name: http://au.linkedin.com/in/iaindchalmers )
https://twitter.com/#!/mattcutts/status/131425949597179904
There's also some speculation that googlebot actually runs Chrome and can render anything that Chrome does:
BUT - If I have a client relying on SEO/organic ranking for their money right now, there's no way I'd be suggesting they move to a "html template with javascript loaded content" style site - not until I've seen a few other similar/competitor sites ranking well with those techniques.
As well I enjoyed the article, I have not used dust.js yet so it was interesting to see how it works. Dojo has a good templating model and I tend to prefer it over some of the other offerings, it is good to see that others are getting into the space. Though I do prefer Dojo's widget based templating over standard tiles type templateing, I find that it makes the code more compartmentalized and reusable. More of a black box, where code and template can just be added to a page and it works.
Having applied the same approach as LinkedIn on past projects and jobs (e.g. BN.com), there is definitely a lot to be gained if done right, and web workers, when available, ease some of the issues with rendering large templates and/or large datasets.
If you're building a mobile site, and want to target low-end Android devices (our "crappiest-phone-test-device" was a Huawei U8180), you really don't get a lot in the way of JSON parsing or DOM manipulation performance.
I wonder what (if anything) LinkedIn are doing for mobile?
It doesn't address the problem we bumped into though. When a page needs a significant amount of content updated, sending that as structured JSON to a low powered Android device (or sometimes even an iPhone2 or a non S 3G) and then parsing that JSON and updatng the DOM was _way_ slower than sending back HTML and just replacing an elements innerHtml. For small tasks (like the personalisation {'name':'John'} example) we could make the JSON approach work, but updating a ~25row 4column list? Not on the cheap Android devices...
Are you perhaps constructing the nodes on the document, instead of doing them off the tree and then inserting/replacing them all at once?