Hacker News new | ask | show | jobs
by astrodust 3437 days ago
In the last few months I've built a brand new Node + Express application, and I've built a brand new Rails 5.x one.

ES6 has taken the edge off of some of the more obnoxious parts of JavaScript, but it still has a long way to go to catch up to Ruby, and Express is a cheap imitation of Rails.

It takes me over a day to get an Express application up and running. There's dozens of dependencies to wrangle into place. There's hundreds of lines of code to sketch in even the most basic of applications. So many directories to create, so many new files you have to basically build by hand. There's Gulpfiles to configure. There's a lot of work to integrate Passport. It's a lot of work to get as far as "Hello, world".

Meanwhile rails new and some Gemfile dependencies get you almost all the way there within an hour. Then you're making database migrations and laying in CSS and layouts.

I love both Node and Ruby for different reasons, but the out-of-the-box experience for Express is total garbage. You can't even parse a cookie without installing a module for that.

Node is way easier to create real-time services, like a Socket.io server in JavaScript is way less fuss than Ruby+EventMachine. It absolutely kills it when writing thin JSON APIs, and in terms of performance it's ridiculous. There's nothing preventing Node from having a Rails-like easy start for web applications but the attitude of the community where making decisions for people and having sane defaults is apparently against the rules.

2 comments

> It takes me over a day to get an Express application up and running.

I feel so much better after seeing this sentiment here. I've tried to dip my toe into the node.js world repeatedly only to feel like I'm trudging through setup for hours.

Of course I may have incorrect memories of how difficult/easy it was to set up my first rails app however long ago.

I should also add it "only" takes me a day because I can crib from a half dozen other Express projects I've created in the past and cherry-pick cut-and-paste parts that I like.

As one example my web app Gulpfile has evolved significantly from the first iteration and it would take multiple days to recreate all of that from scratch.

The Rails Asset Pipeline might be obnoxiously rigid, but at least it works without having to tear your hair out.

Forgive me, but what apps do you work on that have such a complex and lengthy gulpfile?
Nothing exotic but even a routine web application can have 150-250 lines of Gulp directives. Zero of this is provided for you.

Each chunk is fairly small, but they add up. You want linting, auto-restart on changes, tests, your various asset chains to compile things correctly, etc.

Ok, I see your point. I, too, hate writing boilerplate code. But I did three things to resolve this: I built a `config.js` file, which contains the paths to resource files in a more compact format, and is sourced into the gulpfile. I then replaced long path strings with easier to read code.

I also threw my standard gulpfile into a git repo, so if I need it, it's there.

Lastly, I built a yeoman generator. Now, not only is my gulpfile standardized, but I have the rest of my skeleton application built in a matter of minutes. All my favorite libraries/npm modules, custom scss files, basic routing to the standard pages of a simple site, are all built out for me to my preferences while I make a cup of coffee. You can even provide yourself command line flags to determine whether or not to include tests, which preprocessors for html or css you prefer, etc. Really a worthwhile investment.

Write once, utilize many times.

Tools like Yeoman can help here, but they're also relatively obscure and there's a lot of yak shaving involved in getting them working correctly.

In a sense complaining about this the Node world is like asking fish how they can stand being wet all the time. It's just part of the terrain.

I'm not saying what Node is doing is fundamentally wrong, but that this almost absurd aversion to making decisions for users is sometimes a bad thing.

For example, I'd love to be able to declare dependencies for an NPM module that are open-eneded, like "any one of A, B, or C will do", but like it is with Ruby, Python, etc. you must declare all or none.

I'm not trying to restrict choice, just cover the base condition of when you don't care of providing a sane default.

To a degree Rails has this: The first thing I do in a new project is jettison all the garbage I don't want (see you later turbolinks) and drop in all the things I do want. It's actually just a few lines to manipulate, so I can hardly complain.

In the Node world there's a lot of hand-holding required to get even the most basic application up and running. I can see this getting cut down dramatically if you had things like "npm install express +extras" where there was some way of saying "plus whatever other stuff you think is a good idea", or even an "express-fully-loaded" version of the package that comes with a bunch of stuff out of the box.

I really like Gulp and when configured it gives you an amazing amount of control over your build process. Although the Rails Asset Pipeline system works as a pretty good default out-of-the-box they really should steal some ideas from Gulp on configurability for those occasions where you want to change the default behaviour.

Vinyl.fs (https://github.com/gulpjs/vinyl-fs) is an amazing thing that the Ruby world desperately needs.

Rails is omakase. Node is a grocery and a kitchen supply store. Approaching either as if it's the other is a sure recipe for regret.
Node is like walking into a Home Depot when you want a house. Technically you can build one out of the bits they can provide, but it's a ton of work.

The thing is Node could offer the Rails out-of-the-box experience through a package that provided sane defaults. There's nothing preventing people from doing this but cultural resistance.

People do this, Node isn't a framework.

Walmart labs has contributed some great out-of-the-box, with hapi.js and now http://www.electrode.io/

I'm not saying Node is or should be a framework, but that Node itself lacks frameworks that do what Rails does.

Those are good examples of steering in the right direction, but it's still a long way off.

If you want to build a house, go to Home Depot. If you want to buy one and move in, go to a real estate agent. Standing in the middle of Home Depot complaining about how no one there seems to want to talk about about plats or points doesn't seem like a very worthwhile use of time.

There are a large number of projects offering a Rails-style OOTB experience in Node. None of them is blessed as the Node framework. This is because there is no one to do the blessing. Node's developer culture being one you find unsatisfactory is not an example of "resistance". It is an example of difference. And if you do not find the Node style to provide you comfort, there is absolutely no requirement anywhere that you partake of it.

> There are a great number of projects offering a Rails-style OOTB experience in Node.

Which would these be? Even the best tend to fall far short of the full Rails experience.

> And if you do not find the Node style to provide you comfort, there is absolutely no requirement anywhere that you partake of it.

Translation: "If you don't like it, fuck off."

That's not how the Node community has treated me as long as I've been a part of it. The people I've interacted with are often very welcoming, encouraging and responsible. I'm talking about cultural conventions, not individual attitudes.

The difference is that the Node world is used to things taking time to put together. The Rails world finds this to be unbelievably fussy. Python people from the Django realm are in the middle.

To promote a new way of doing things, like Rails did, is an effort way beyond my singular capability. It will require a lot of like-minded individuals to go "You know, maybe we could make something that wraps around Express and gives you a Rails-like experience for those that want it." and then work towards making that happen.

> Translation: "If you don't like it, fuck off."

If you like, but that's not what I'm saying. What I'm saying is instead that you're not going to find value in Node the same way you do in Rails, and complaining that Node is not Rails will not change that in the slightest. Neither will approaching Node as though the first thing to do is make sure your project tree contains every piece of functionality your app might ever conceivably need. Gulp, for example, is extremely powerful, but also has an enormous complexity cost. NPM is a task runner, too, and shell scripts can be fine for a surprisingly long while. I'm not sure what led you to think you need Gulp to get to "Hello, World". But part of using Node effectively is understanding that you are, in the end, responsible for the choices of tooling you make. If Gulp seems like more work than necessary to solve a simple problem, it probably is! Think about using something simpler instead. No one will force a choice on you, either in favor of Gulp or against it. The other side of that is that no one will make a choice for you, either. That's on you. If you'd rather it not be, this may not be the toolset for you.

Although, again, there are a lot of seeds and starters. I don't use them myself much, because I already have a battle-hardened stack that's simpler than most of them anyway, but I hear very good things of Sails. I wouldn't expect it to replicate Rails in full, but what I've heard suggests it will get you closer than most. Even here, though, you have to choose; there are no BDFLs and no One Right Way.

I'm not here to suggest a One Right Way, either. I do think the Node style is better in a few ways, not least of which is that, in exchange for paying a higher setup cost up front, you become less likely to run into teething troubles later on, especially in the realms of scaling and keeping the codebase up to date where I've observed Rails very frequently to have major problems. On the other hand, it can be considerably easier to start with Rails, especially if you're unfamiliar with it, and not strongly or at all supported by people who are - precisely because it relieves its user of the responsibility of making choices that user may not yet be prepared or equipped to make.

But all of that is an opinion that I'm having, and opinions certainly do differ. That doesn't gravel me. What does gravel me is seeing someone complain at considerable length about one style because it isn't exactly the same as another. That seems unlikely to produce any especially worthwhile result, either for the one who does it or for his interlocutors.

I'm not complaining that Node isn't Ruby, or that Express isn't Rails. What I'm saying is that there's an opportunity in the Node space to create something as fast, friendly, and forgiving as Rails is.

The "translation" there is how comments like that are perceived. "Put up or shut up" is not a good way to build community. Yes, obviously we have options, but the amount of commitment it takes to go with some of them is a lot higher, and in many cases needlessly so.

> I'm not sure what led you to think you need Gulp to get to "Hello, World".

If you have a non-trivial plan for what your application is going to do and you're intending to iteratively deploy it then you really do need an asset handling plan. Gulp does a great job of this if you spend the time to configure it correctly. With ~200 lines of configuration I get minification, compression, asset hashing, linting, auto-starting, and more. In some important areas that's ahead of Rails, especially in terms of control.

I'm talking about cultural concerns here, about the experience of someone new trying to build a Node application and needing to cobble this all together themselves. It took me about six months of iterative work to come up with a reasonable environment to build Node + Express apps. It took me two weeks to get settled into Rails back in 2005, and I've walked people through the same process with every version since Rails 1 and it's rarely more than a few days of coaching. This friction is something that's a serious problem and no amount of hand-waving dismissal of "that's just how Node is" will change that.

If you want to bring new people into your platform, into your culture, into your community you should make a better effort to lay out how things can or could be done. It shouldn't involve foraging through blog posts, Stack Overflow answers, and pestering co-workers for snippets of code, assembling a veritable quilt out of them that you pass on to others like some sacred heirloom.

For example, I'm consistently impressed with the quality of the documentation Node projects have, even humble ones with obviously limited appeal. The Ruby world is filled with crusty, opaque code with half-assed documentation that's often wildly out of sync with the shipping version, even for foundational components like Rake, Rack, or Rubygems.

If Node had a softer start for those that wanted it, respecting the culture of being able to pick and choose on a very granular level, I'm sure people would be more productive, use it on more projects, and contribute more back into the community. This is a lost opportunity.

I've known several of the main devs behind gulp for some time... and tbh, I switched away from gulp to direct scripts some time ago. If I can run it straight in npm, I'll do that... if I need more, I'll favor running a script in a directory for that purpose. glob, shelljs and mz give you a lot of what you might need. And it's often less code than gulp scripts might be.

An example[1] work in progress boilerplate I've been heading towards as time permits, will probably have it flushed out by the end of next month, including migrating to the latest webpack.

Of course a lot of the reason for options, is there are so many... server rendering, react v angular, angular 1 or 2+, bootstrap or foundation or ??? In the end, it's great in some was and not so much in others. I, like you prefer to have the choice/control.

Frameworks like rails are great at getting you 85-90% of the way to done... but that other 10-15% is so painful, you're often better off with DIY in the long run.

https://github.com/tracker1/react-redux-materialui-boilerpla...

There are a lot of configurators that give you a house... yoeman, create-react-app etc. The difference comes down to what kind of house you want.

Your best bet is to search for Foo boilerplate, where foo is what you want to work with, and start from one of many thousands of starting points.

I think the resistance is generators take time and persistent upkeep, while a boilerplate can exist as it is and upgraded intermittently.

In the end, I'd rather work with a lego bulk pack, than the prescriptive kits.

Adonis might be Rails-enough for you. https://adonisjs.com/
node has sails (http://sailsjs.com/) which i believe is rails-inspired. haven't used it though.