
RailwayJS - olalonde
http://railwayjs.com/
======
nwienert
This seems very similar to Rails in structure and features, with the obvious
upsides and downsides of Javascript and Node brought along. For me, the first
Node framework to really catch my eye was Meteor. The live-updating, hot-code-
pushing features seemed to really take advantage of the speed of V8, but I was
put off by the total lack of MVC structure and other niceties of Rails (that
are in Railway).

I'm still on the fence with Node and have yet to give it a real try. I think
what will finally get me to jump in is something between the two. The
sensibilities and structure of Rails with the great realtime features in
Meteor. Just sayin.

EDIT: This does look fantastic by the way, a great contribution to the
community.

~~~
stuffihavemade
Take a look at Derby (which is similar to Meteor) as well
(<http://derbyjs.com/>).

------
michael_miller
Neat project! To echo what everyone else is saying, thanks for putting this
out there.

I am curious as to what most HNers think of doing server side development in
JS. It's obviously the flavor of the month, but I have yet to see the appeal.
JS is certainly not a bad language, but it seems a lot more tedious than, say,
ruby. The nesting of callbacks, the lack of built in OO infrastructure (given
that most of us are trained with class based inheritance), the many quirks
associated with making the language accessible to nonprogrammers. Am I missing
something? Is there a really good reason to use JS on the server?

~~~
rockyj
The main reason Node.js is gaining popularity is because it is blazing fast,
scales very well due to its IO + event driven architecture and it has the best
support for websockets (see socket.io).

On the flip side, code can be hard to maintain and you need to be more
disciplined so that you can read the code later otherwise it becomes a
callback spaghetti. Doing everything through callbacks also requires a mental
shift.

Like with everything in life, there are pros and cons and tradeoffs. So choose
wisely :).

~~~
jaequery
node.js isn't really that fast for traditional apps, but if you were to
compare, it's pretty much on levels of nginx and it's actually slower serving
static files. only in few cases node.js shows its power, i.e; real-time
apps/games. i wouldn't build any full-blown websites in node.js. only a
certain piece on the site i'd do it in node, like a widget or something.

~~~
louischatriot
Yep, you shouldn't be using node to serve static files anyway. This is
something a reverse proxy such as nginx should do. Node can then be used to
serve either as a pure API (serving json with express is the easiest way) for
a webapp or render the webpages.

~~~
wamatt
_nginx_ is not a bad choice, but would instead recommend _node-http-proxy_ for
most projects (including production).

It's fast, easy to setup (npm install), and relatively hardened, while still
keeping everything JS.

As for static assets, those should probably be served from a CDN anyway, if
one is concerned with performance.

~~~
louischatriot
I agree about the CDN, even though for us performance is not so critical we
need to use a CDN (yet). I didn't know node-http-proxy but it sounds
interesting I'll check it out.

------
jameswyse
RailwayJS is cool, I used it for a long time, though I now use Locomotive as
the latest git version is very good. It doesn't offer as many features but is
clean and gets out your way.

~~~
johnx123-up
Please give little more information why <http://locomotivejs.org/> is better
than RailwayJS. Very much interested to know the reasons.

~~~
jameswyse
I like locomotive because it stays out my way and allows me to work the way I
want to. It's basically just Express 3 with an MVC layout, nicer routing, some
nice helpers and a very clean and logical directory layout. It's how I would
organise a new Express application if I was coding it from scratch!

I really like the idea of locomotive's 'initializers' directory - Any files
you put in here are loaded at boot, in order. I use files in here to set up
things like configuration, databases, logging, etc. With railwayjs these all
ended up in the environment files which was hard to maintain.

The one thing I really didn't like in RailwayJS was the convention of putting
all your database models inside one file (schema.js), I had to over-ride the
built in ORM (JugglingDB) at the time because it was lacking features and
define a customSchema() function to use mongoose, and this file ended up being
really large and a bit of a mess. I tried separating things in to individual
model files but I couldn't get it working without messing with RailwayJS code.

Probably a lot of the problems I had are now resolved as this was a few months
ago, but I'm sticking with Locomotive from now on :)

------
zafriedman
First off, let me state that I in no way wish to diminish the accomplishments
of the authors of RailwayJS in making these comments. I think they've built an
inevitable framework given that Rails was (and likely still is) the most
popular open source web framework (at least as far as the HN/startup crowd
goes) and of course why not give developers the same abstractions they have
with their old favorite when a new thing comes along. But here's a
constructive observation:

Node.js isn't a framework. AND it's not a programming language. Node is
ostensibly a set of libraries and a runtime environment. I've been to a few
Node meetups over the past few years, and inevitably people (not just newbies
btw) will ask "what will be the Rails for Node?" But I think making this
analogy is wrong. It's wrong for two main reasons, the first of which is that
it implicitly compares Node.js to Ruby, which is a category mistake. More
importantly though I'd argue, it's wrong because making the Rails for Node
analogy deprives the developer (you!) of the opportunity to allow an emergent
programming paradigm to change the way you think about programming! So how
should Node do that? My fantasy for how Node.js will evolve in the next few
years is that it will be a series of node packages which can be easily dropped
in and out of my programs. I believe that the goal of the third-party node
package development community should be to encourage this modularity, because
I think it is the right abstraction for what Node.js actually is, and not
necessarily what some people might wish it was. It's easy enough to set up
EventMachine in Rails and then you can use your familiar stack, but I'd
encourage anyone looking to use Node.js to fully embrace it and use it as an
opportunity to explore new workflows, and not just try to fit your old stack
into an event loop.

------
wamatt
RailwayJS looks interesting, but wondering why they don't appear to support
pushState routing with # fallback, out the box.

hashbangs URLs are so 2010. :p

------
kumar_navneet
Nice work. Will increase adoption of nodejs within Rails community a lot more.
Bookmarked, I would give this a spin coming weekend.

------
taude
Serious question: what's the point of all these Node.JS frameworks trying to
mimic existing web framework functionality? Once you start adding synchronous
database access, don't you lose more of the advantages of NodeJS anyway? Seems
like all these frameworks appearing are trying to solve a problem already
solved.

~~~
taude
I've read some of the comments below and it seems there's some form of
consensus that Node shines for the websocket.io portion of the web stack. So
likely real use cases for NodeJS will using it in conjunction with your
regular website?

------
nodesocket
Nicely done. Appreciate the beautiful and detailed documentation.

------
derdesign
Protos is awesome... <http://derdesign.github.com/protos/>

------
davedx
There's a glaring typo: "try in you browser"

~~~
1602
LOL. Fixed :)

------
rockyj
Wow! Mind = Blown! Thanks for doing this and giving it away for free.

~~~
1602
You are welcome. Working on more mind-blown stuff for railway 2.0 right now.

~~~
olalonde
Hey, I'm currently evaluating a number of Node.js web frameworks for a project
I'm working on (I'll eventually publish the results on my blog). So far, I
have reviewed: RailwayJS, Locomotive[0], Tower.js[1], GeddyJS[2], Derby[3] and
Meteor[4]. It would be really great if you could give me your opinion on how
RailwayJS compares to those (especially Tower.js, GeddyJS and Locomotive as
they seem to be competing directly).

[0] <http://locomotivejs.org/>

[1] <http://towerjs.org/>

[2] <http://geddyjs.org/>

[3] <http://derbyjs.com/>

[4] <http://meteor.com/>

... more Node.js web frameworks:
[https://github.com/joyent/node/wiki/modules#wiki-web-
framewo...](https://github.com/joyent/node/wiki/modules#wiki-web-frameworks-
full)

~~~
1602
Well, I'm not impartial, so I wouldn't talk about pros and cons of RailwayJS
in comparison to Geddy and Tower. I think "the framework" concept is wrong
now, everyone should think in modular manner, both framework users and
creators, because it allows to build really decent software. Rock solid
frameworks are full of lie, slow and monsterous. So, my goal in railway - keep
it modular and thin. After 1.5 years Railway is not Rails-like :) It just
follows best part of it's ideology. But every new stuff I'm planning to add to
framework will be added as modules.

For example now I'm working on "RIO" (railwayjs + socket.io) module, which
will unobtrousively add socket.io capabilities to framework. It also solves
auth and user-to-user communication problems.

Another big way to go - client side. We have some information about
application structure that could be used in client-side, and duplication
through backbone on client-side is awful idea, why not just give and
transarent API for it. And this is separate module too, not bundled in
railway.

So, this is a biggest difference in my opinion, anything other we implementing
are basically the same.

~~~
olalonde
> I think "the framework" concept is wrong now, everyone should think in
> modular manner

Definitely agree and that's why I am still undecided whether I want to use
vanilla Express or a high level framework. RailwayJS is my top choice right
now as it is built on top of Express and seems pretty modular. Tower also
seems good but I dislike the fact that it is written in CoffeeScript.

------
narendranag
Mind = Blown.

