Live data from Hacker News

RailwayJS

railwayjs.com

41–50 of 50 posts

Re: RailwayJS

#41
post #40
post #36

Earlier quoted context omitted.

Yeah, it's not like it's impossible with Ruby, but especially compared to a system like Erlang - to my way of thinking - it can start to look a bit clunky when you try and get lots of pieces talking to one another if, say, most of the rest of the application is in Rails. Or at least that's my impression, maybe I'm wrong?

I daresay you seem to have wrong impression. Having Rails app for typical web stuff and Eventmachine (em-synchrony) + faye stuff for realtime things work pretty well in actual usage. I can wrap DB calls, memcache/redis, SMTP connections etc inside my event loop and can achieve near same performance as a Node app. The alternative of using node.js for everything sounds good but I am not really sure, how good node and i…

Let me put it a different way:

I receive some kind of request in a Rails controller. I need to send, as a consequence, a notification via the web socket. How does it get from point A to point B? In Erlang, it's all likely to be quite contained and fast, and not involve writing anything to external queueing software, and to boot, it's all going to happen in the same unix process, rather than having one process that's the Rails server, and another that's the eventmachine server.

I don't know Node.js and how you'd handle sending messages from point A to point B, but I'd be interested in hearing some opinions.

Re: RailwayJS

#42
post #30

Earlier quoted context omitted.

First class functions != Functional programming language

I'm not saying JS is a pure functional language. It's a fact that you can create functional abstractions in JavaScript. Just like you can in Python and Ruby.

> It's a fact that you can create functional abstractions in JavaScript.

This is basically just restating "Javascript has first-class functions."

While first-class functions are nice, it's only the barest tip of the iceberg when it comes to what's needed for true functional programming. When you add more and stronger assumptions to your functions and types - referential transparency, static typing, immutable data structures - you get more and more back in functional expressive power and the tools that make it possible: memoization, concurrency, tail recursion, lazy evaluation, pattern matching, and so on.

The less assumptions you allow in the language, the more these powerful functional techniques and abstractions simply won't be possible. You still stand to gain from a modular, functional style, but you will have to go back to working around the inherently imperative language in most cases.

Re: RailwayJS

#43
post #33

Earlier quoted context omitted.

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.

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.

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.

Re: RailwayJS

#44
post #39
post #20

Earlier quoted context omitted.

Perhaps I'm missing something but how is this a matter of opinion? If one wanted to avoid callbacks, which were the OC's original issue with node, one would break up the callback spaghetti into distinct, possibly prototyped objects, and glue them together with node's events. How is that any more difficult to maintain than, say, Python classes? If anything, I personally like the ability to choose the coding style with…

In a language like Ruby or Python by using Fibers or Co-Routines(Greenlets), one can get benefit of non-blocking IO at the same time avoiding code spaghetti. Gevent in python for example is pretty popular and similar is the case with Em-synchony in Ruby. I have used callback objects but really that is not even close to what one can achieve with Fibers or Greenlets.

Can you give an example? Thanks!

Re: RailwayJS

#45
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.

Re: RailwayJS

#46
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.

Re: RailwayJS

#47
post #46

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.

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?

Re: RailwayJS

#48
post #8

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 t…

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 shif…

As silly as it sounds, one of my favorite aspects of Node is how ridiculously portable and modular it is. NPM makes everything a breeze, and (thanks to support from Microsoft) it actually allows easy development on Windows. I realize plenty of languages have their own package managers, but NPM is fantastic. The callback aspect definitely requires more discipline, but I'm glad that I've learned it.

Re: RailwayJS

#49

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.

Please give little more information why http://locomotivejs.org/ is better than RailwayJS. Very much interested to know the reasons.

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 :)

Post reply on HN