Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is it me or is this proposing, for the sake of symmetry, that you expose server-side implementation details on the client? Unless you have client-only and server-only versions of the models, I would think that's what you have to do. It seems like that's exactly what's happening when you have, in client-side code, a boolean called "server" that indicates whether it's running on the server or not.

Now, off the top of my head I can't think of a particular way that this could screw you. But I can't say that it looks like the Right Thing to do either.

I don't know how far the Asana team got with Luna, but I think their approach for a unified client-server model is much closer to how I'd want things to work: http://asana.com/luna/



that you expose server-side implementation details on the client?

This particular impl does it with javascript conditionals, but there's no reason the client must see code that it never executes anyways. The equivalent of an #ifdef (ideally buried under a framework rug) goes a long way here.

Moreover a function does not even need to resolve to the same code on the client and the server. For example a model-validation function could evaluate to the actual validation logic on the server (incl. DB lookups etc.) and to a mere ajax RPC (calling that function on the server) on the client.

I could very well see a smart node serverside-library that let's you write one js file and then transparently mangles it as necessary before sending it to the client. The trick is to keep the magic down to a sane amount (slippery slope!) so that the end-result remains always predictable.

Luna

Yes, it seems luna is basically taking this approach.

What I don't like about luna is that it's not javascript and that it's, for my taste, taking the abstraction too far. It claims:

  the client-side JavaScript, the server-side SQL, and everything in between
That's too much. Sure, for the developers it's comfortable to sidestep a whole cascade of hard problems simply by assuming control over everything ("My way or highway"). But this approach has not proven very successful in the javascript-world. We love small and pluggable components like jQuery or Backbone. The monoliths like Dojo or ExtJS tend to be too limiting on the My part of the way.


I agree with your comments about Luna. About the #ifdef proposal, I think a better solution might be that your server-side model object has a method like getSlaveObject() that gives you a version of the model that is acceptable to be seen on the client side.


Yes, you are probably right, my examples were just meant to deliver the rough idea, not fully shaped solutions.

Lots of room for experimentation and exploration in this space - exciting times ahead.


Thanks for that link. I hadn't seen that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: