Live data from Hacker News

Isomorphic JavaScript: The Future of Web Apps

nerds.airbnb.com

61–70 of 123 posts

Re: Isomorphic JavaScript: The Future of Web Apps

#61
post #56

Wasn't this the idea with GWT so many years ago? In GWT's case, it was Java on both sides. I don't believe that it solves the problem and I don't believe Javascript on both sides will solve the problem. This is a classic "impedance mismatch" like O/R mapping. At the end of the day, there may be no good, i.e. simple, solution. It is inherently difficult and messy.

GWT is not Java on both sides. Its Java on the server, Javascript on the client. The Java client side code compiles to Javascript...the abstraction is way greater than what OP is presenting. (JS & JS) GWT is/was a terrible amount of overhead baggage, but had some brilliant event systems and DOM tricks for its day.

> GWT is not Java on both sides. Its Java on the server, Javascript on the client. The Java client side code compiles to Javascript..

And the Java server code compiles to JVM bytecode. Languages often compile to some other form to run, and the fact that the compilation target is different for different parts doesn't change that the programming language is the same.

Re: Isomorphic JavaScript: The Future of Web Apps

#62

You keep using that word. I do not think it means what you think it means. Using precisely defined mathematical words in contexts where they only make sense vaguely to a layperson ruins their original usage. Make up a new word. Repurpose a shitty English word. But leave our damn maths words alone. Old man quarterto shakes his fist at you! Get off my smooth, compact lawn!

I can't disagree more. From thefreedictionary.com:

  (Mathematics) A one-to-one correspondence between the elements of two sets such 
  that the result of an operation on elements of one set corresponds to the result
  of the analogous operation on their images in the other set.
This seems exactly like what the author is describing. Colloquial English does not have an objective standard -- it is a constantly evolving language. I certainly agree with this term's usage unless a better one is suggested.

Re: Isomorphic JavaScript: The Future of Web Apps

#64
At the Meteor meetup last week, David Greenspan outlined an interesting approach to how Meteor UI separates the "template-parsing" logic from the "rendering" logic with an intermediate representation (in Javascript) of the steps you need to take to produce that HTML. Check out the video (relevant slide is at 16:47, but the entire talk is awesome):

http://www.meteor.com/blog/2013/11/06/david-greenspan-at-dev...

The cool thing is, other template languages (like Handlebars, Jade, etc.) can compile to this intermediate representation, which then gets rendered on any updates.

If the front-end community could agree on a protocol for how to represent these steps in, say, JSON, then we could be on our way to a world where you could use any rendering engine with any template library, on the client or the server.

That is, if the community could agree on a representation :)

Re: Isomorphic JavaScript: The Future of Web Apps

#65
post #19

You keep using that word. I do not think it means what you think it means. Using precisely defined mathematical words in contexts where they only make sense vaguely to a layperson ruins their original usage. Make up a new word. Repurpose a shitty English word. But leave our damn maths words alone. Old man quarterto shakes his fist at you! Get off my smooth, compact lawn!

Whoa old man quarterto, who said the word ever belonged to math people in the first place? I could argue that math people have a bad habit of squeezing English words into strange contexts that corrupt the original meaning. Take "manifold" for instance, or "curl", or even something as harmless as "mode". They all meant perfectly fine things until the math people claimed them as their own. According to M-W "isomorphic"…

A lot of mathematics intersects with programming. There is a clear notion of isomorphism in programming and computer science. The pedestrian web dev is not aware of it.

Imagine a graph theory researcher calling a program which handles graphs a web app. Isn't that confusing?

Re: Isomorphic JavaScript: The Future of Web Apps

#66

I like the basic idea, but my hope is that we can go the other direction and bring more interesting languages to the client side. I know this is done to some extent using JS or Asm.js as a compile target with a whole bunch of existing projects. But it would be great to see this really move forward. It seems like CoffeeScript did this rather successfully, and with source maps, the debugging story is getting better too…

Consider Clojure - an interesting language indeed, and the browser variant (ClojureScript) is gaining lots of interest.

Re: Isomorphic JavaScript: The Future of Web Apps

#67
Funny thing, had related talk today with my co-worker...

Anyway, so problem currently is that client devices are slow and HTTP requests are expensive/slow. If these were not issues - I guess rendering on a client would be just fine?

If above is correct, I do not see good reason for smallish websites/apps/whateverucallit fallback on server rendering, as it looks like every single year mobile devices getting faster and faster. And we have SPDY on a way to mainstream.

Do I want to wait 3 seconds to get HTML or wait 100ms to get bootstrap code and see pieces rendering as data comes in? Probably doesn't matter, since it will take roughly same 3 seconds to render it on client side.

Ultimately, perceived responsiveness of webapp depends a lot on particular implementation. If you wait for all data required for page to render - yes, it will be slow. If you render pieces of page as data comes in - user sees that something going on and this is good enough. Why it should matter where data will be converted to presentation, on server or on a client? It is still waiting. And if client is not happy with it? Buy beefier hardware!

Re: Isomorphic JavaScript: The Future of Web Apps

#68
post #44
post #42

Earlier quoted context omitted.

The server code is still Java, but our template language ( https://developers.google.com/closure/templates/ ) compiles to both JS and Java.

Why not render the templates in PhantomJs and have a user account that can push the rendered template back into the server cache. No need to duplicate the work of writing two backends. Or hell, just use Rhino and generate the reified pages on the server. Also, you can't patent this now.

The soy templates have a java (tofu) backend already (several years old).

The phantomjs idea is a shit idea and should go away. Phantom is fine and good for headless testing (hells we use it for quite a bit else) but seriously it is not a solution for a real load.

Re: Isomorphic JavaScript: The Future of Web Apps

#69
post #42

Earlier quoted context omitted.

(author) Cool! What's the JavaScript runtime on the server? Something JVM-based?

The server code is still Java, but our template language ( https://developers.google.com/closure/templates/ ) compiles to both JS and Java.

We use the full closure stack and tofu alongside the decoration phase works a treat.

Re: Isomorphic JavaScript: The Future of Web Apps

#70
"She's an iso" http://www.youtube.com/watch?v=y8nXRQQ0bjA

Mostly Django user attempting to ask from outside the Node/server-side js community for an explanation of why we're invoking "isomorphic" here: As far as what's going on, are we just saying that the js for rendering the page is equally capable of talking to the API and doing the DOM work while running on the server as it is when downloaded, interpreted, JIT'd etc before fetching the actual request content? Does this mostly eliminate an extra RTT to the API if the js/web application server experience relatively zero RTT due to network/physical proximity to the API server? Does this incidentally make SEO possible while having fat clients and server-side initialization all in one setting and with mostly one code base?

Assuming I'm on track, working backwards towards understanding the implementation as it relates to "isomorphic", if a program's output state is a valid input state to initialize the program (we're talking fat, stateful MVC clients after all) state, then all that's needed to re-create the entire execution state of the current program is to copy itself into the output in such a way that it will be run upon receipt (we link js files in the page). I'm going to take a wild guess that the output state of the client doesn't have the necessary template tags etc used when a cold page is rendered, server or client-side, so the server has to serialize some of the state and pump it into the copy of the program to make it as if the client we're sending is the client that rendered the page, keeping the client's internal representation consistent with the state of the page.

If this is true, we're taking a program that cannot be initialized from it's own output and modifying it to be a program that achieves the same effect. JS is modifying JS, and is therefore said to be "isomorphic?" It still sounds like a glorified way to describe a serialized execution state, one that happens to involve a program in a language outputting a valid program in the same language, but the purpose is to achieve the effect, as far as the developer is concerned, that the output is a valid input, albeit with an intermediate technique to make the abstraction hold water.

If I'm on track, then I have to say it's rather as if we have a fat client, output of one render, serialized client state (because the DOM is not sufficient to re-create the program state or else our client js has to initialize from one format that's programmer friendly and one that's program-friendly), and necessarily a third-leg responsible for injecting the client js and serialized state as js into the output.

Standing to see the mauve dusk of my life against the impending rain of spears and arrows, I must ask if we can not simply call the js necessary to achieve the equivalent state of running everything client side a "continuation" and call the entire technique "client continuation programming?" with it implicitly understood that creating the continuation involves a third piece of program? I'm prepared to die. I just want to know.

Post reply on HN