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

Here's a case study: an open source project I made with node.js; https://github.com/node-bus/node-bus

It's a distributed pub-sub engine, so one client can publish an event, and the others on the server will receive it. Probably about half the code is shared between the server and client. That means less bugs and easier maintenance.

Technically there are tools that will convert, say, Haskell to Javascript so that you can have shared code between a client and server. In practice, I don't know anyone who does that. I'm sure for most it feels like a bit of a hack. So for practical purposes, the only way to share code between the client and server is by using javascript (or coffeescript) on the server-side as well. Node.js IMO is the best server-side javascript engine.



I looked through your shared/util.js and, while I don't want to take anything away from your project, it doesn't seem to me that there is much of a case for significant and useful code sharing in Node. When I think of code sharing, I expect something like Luna, from Asana http://asana.com/luna/

Instead, the examples of shared code in Node are always simple utility functions, validators and the like. While it helps not to have to rewrite those, it's not groundbreaking. Facilitating the sharing of state between client and server -- hopefully irrespective of the server-side language -- would be a much better goal, IMO.


have a look at dnode: https://github.com/substack/dnode bidirectional remote method invocation. Oh, and a complimentary robot free of charge: http://substack.net/browse/2010-11-08%2022:16:39 :-)


The code itself might not be significant, but the implications are. It defines standard interfaces for interacting with the library. Thus people can write plugins on top that work at both the client and server end.


The Google Web Toolkit (GWT) is a widely used Java-to-JavaScript compiler:

http://code.google.com/webtoolkit/


That's cool! I was doing something like that at KnowNow in 2000 and 2001 (eventually open-sourced as mod_pubsub), but it never took off.

I agree that JS-on-server is a nicer way to share code than compiling other languages into JS.




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

Search: