• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Practical hapi: Hapi vs. Express?

Saloon Keeper
Posts: 7355
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're probably somewhat partial towards Hapi, having written books about it, but what do you think of the comparisons between Hapi and Express? What I took away from those is that Hapi works on a somewhat higher level of abstraction, at the cost of a somewhat lower performance in high load situations. What's your take on that?
Posts: 47
MySQL Database PHP Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

That's a good question.
When making a choice for learning a new language, I suggest a framework that has a good to grasp learning curve.

When making a choice for an application, the performance of a framework is definitely a factor. Hapi would pass the test if your queries are well structured. I haven't noted a great fall in performance per say. Sometimes, the nature of the apps that you want is also a factor. The apps that I have worked on using hapi, used customer queries of a max 50,000 at the same instance. And it was good enough as per our client's expectations.

Personally, I come from a JAVA background, and unless a framework has a guided approach to solving problems, I don't prefer it. I don't let developers in a large team use Express, because of the way they can handle the same thing in so many different ways.

Here's something that you might go through(even though an old post):

Note that Node.js is better in performance any day, but if you have to consider a framework at all, you'd consider the community behind it, the stability of its versions and the out of the box features provided by the framework. Choosing a framework in any language though is a matter of disucssion and requires context.

Happy Coding.
Ranch Hand
Posts: 95
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both Express and Hapi aim to be highly flexible, simple, and extensible. This similarity means that both have easy-to-use APIs, they're highly modular, and can support your application as it grows potentially very large.

The learning curve for these frameworks, since they are quite straightforward, is low, unlike a more opinionated framework like Meteor. If you are coming from using Express you should be able to quickly pick up Hapi, and vice versa.

There are, however, some philosophical differences between the two frameworks, which we'll describe throughout this article.

Hapi.js includes more "batteries" by default than Express does. For instance, when parsing payload from forms to via "POST" requests, with Express, you have to include the body-parser middleware. You then use that to parse the POST payload and use the data from the user. On the other hand, with Hapi, you need no middleware. The payload is parsed for you by the framework itself, and you can access the payload directly on the request object. Little conveniences like that are replete in Hapi.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic