Ask HN: What is the "Ruby on Rails" of the Node world?

2 points by toughyear ↗ HN
I recently started using Rails for a project and it is such a breeze to get the basics setup quickly. DB, CRUD APIs, and everything. I am curious if there is anything similar to it for Node runtime.

8 comments

[ 0.23 ms ] story [ 16.2 ms ] thread
I believe Express is generally considered to be the rails equivalent for node, but I've been out of the node ecosystem for a few years now so my info may be out of date.
I had some pretty good experiences with Nestjs.
Because of differences in language design, it is exponentially harder to implement the Rails architecture in most other languages.

In particular, Ruby allows adding methods to any object (like Smalltalk). For example you can add methods to integers and write FizzBuzz where:

  3.fizzBuzz
outputs 'Fizz' and

  15.fizzBuzz
outputs 'FizzBuzz.'

Internally, Ruby on Rails uses this aspect of Ruby to modify the builtin MethodMissing method with whatever code needs to be added to make it behave the way you expect.

While it is theoretically possible to do the same thing in any Turing complete language, it is very difficult in most others. Including EcmaScript/Javascript/Node. This doesn't mean you can't have a very useful web framework in these other languages. They can even be highly opinionated. But that opinion can't be equivalent to the opinion underlying Rails.

Using Ruby on Rails is the best way to get the power of Ruby on Rails...if you can of course. Maybe your boss insists on Node, .Net, or Larvel. Good luck.

Statically typed languages have vastly improved since Ruby and Rails came on the scene. Your fizzBuzz example can be done in a type-safe way in a variety of languages: C#, Kotlin, Dart, Swift, Nim(?).
Nim indeed has UFCS. So you can get an i.fizzBuzz notation without any fussing about with "objects":

    proc fizzBuzz(i: int): string =
      if   i mod 15 == 0: "FizzBuzz"
      elif i mod  3 == 0: "Fizz"
      elif i mod  5 == 0: "Buzz"
      else: $i
    for i in 1..100: echo i.fizzBuzz
In Ruby:

  42.fizzBuzz
can return 'Fizz' because you can make 42 a method of the Integer object because Ruby is like Smalltalk. Most languages won't let you do that, and if they do, they make it difficult.

I'm not saying that's what you want to do. But Ruby on Rails uses that technique to modify the MethodMissing method of its objects. This makes it practical to implement the behaviors that make Ruby on Rails productive for many users.

Yes modifying objects might be a footgun. But if you want the architecture of Ruby on Rails, using another language might be a worse footgun. Or not, it's your code.

(comment deleted)