Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decide which framework to use for node? [closed]

Tags:

node.js

So we've been using node for quite a while now and I must say, with the growing community for node, people are developing lots of awesome modules and frameworks too. But as we are working on more and more projects, I get confused sometimes as to which framework to go for. So far we've used following frameworks:

  1. Express - One of my favorite frameworks for node and this was the first too when we started making apps in node.js.(I think this also was the first to gain so much popularity). We do have issues like callback hells but provided that the routing and the code organization is much more cleaner, we were pleased to use it.

  2. KoaJS - Another one from the TJ and team, and this is just awesome! Using ECS 6 when any of the browsers hardly support them. (Specially when it helps you remove the callback hells completely). We had some issues with https compliance with Koa and had to re-write the entire server using hapi and also the fact that it depends on the unstable version on node for now.

  3. Hapi - This is our most recent adoption and haven't done much with it, but the most fun part of this is the joi module that helps us validate requests(easily) even before they hit the actual server and also the automated docs generation.

  4. Synth - I haven't interacted much with it, but while reading the docs, I came across

Use services and dependency injection just like AngularJS but on the back-end!

which is awesome, but since it's in beta still, I'm not thinking of using it anytime soon.

So when trying to go for a framework for your app, Is there any specific set of features that one framework is good at and the others don't? Because honestly, we adopted most of the frameworks just with the intent of trying them out and apart from syntax differences (except Koa that uses ECS 6) and how they handle routes, I couldn't find much differences among them.

So my question is should we adopt any framework just by looking at it's popularity(which is what people generally do) or there is some checkpoints we need to consider while doing the same?

Any suggestions/help appreciated.

Edit

I wanted to add on that my intention for this question is to find out the key points to consider while opting for any of the node.js framework (rather than just depending on it's popularity or how many big names are using it). For the front-end we can easily tell because we already know or have been told the key features that would help development easier(the diff between angular & backbone can be an example) But for the node.js frameworks that isn't any way.

I would request others to consider my edits too.

like image 672
I_Debug_Everything Avatar asked Sep 07 '14 06:09

I_Debug_Everything


People also ask

Which Nodejs framework should I use?

Sails.js resembles the MVC architecture pattern from frameworks like Ruby on Rails and provides support for modernized, data-oriented development. It is compatible with all databases and flexible in integrating Javascript frameworks. Hence, it's the most suitable framework to build high-end customized applications.

Is KOA better than Express?

The key difference between Koa and Express is how they handle middleware. Express includes routing and templates in the application framework. Koa, on the other hand, requires modules for these features, therefore making it more modular or customizable.

For which application Nodejs is not well suited for?

Not Suitable for Heavy-Computing Apps Node. js doesn't support multi-threaded programming yet. It is able to serve way more complicated applications than Ruby, but it's not suitable for performing long-running calculations. Heavy computations block the incoming requests, which can lead to decrease of performance .


1 Answers

I'll try and keep this answer as non-opinionated as possible. Please edit and help me improve this. This is a important topic and should get a good answer.

Express.js

Pros

  • Express.js is the big guy, fairly old and incredibly popular.
  • Easy to use views
  • Very Lightweight

Cons

  • No fancy features

Koa.js

Pros

  • Lightweight
  • Koa is the maybe successor to Express
  • No callback hell, thanks to ES6 generators
  • Built by the same guy as Express

Cons

  • Fairly new, not super refined
  • Uses ECMAScript 6 features, meaning you need Node.js v0.11 (unstable)

Hapi

Pros

  • Many official modules, but not a ton of third-party ones
  • Developed by a large corporation that uses it for their own products

Cons

  • Built by Walmart
  • Different syntax for specifying routes than Koa or Express.
  • Itself and all the official modules have weird names

Synth

The first back-end framework specially designed for single-page web applications.

Pros

  • Designed for being the backend single-page websites, ala Angular.js
  • API First
  • Dependency Injection, familiar to those coming from Java
  • Designed to do a ton of the backend things, allowing you to work on the frontend

Cons

  • Dependency Injection, disliked by quite a lot of people because Java is the only reason it exists
  • Very new, currently in beta
  • Doesn't work well with more traditional websites

More Resources

  • TechEmpower Framework Benchmarks (limit to Node.js) Benchmarks of lots of web frameworks, currently only has raw Node.js, Express, and Hapi for Node.js.
like image 87
Zoey Mertes Avatar answered Oct 11 '22 14:10

Zoey Mertes