What does HackerNews think of journey?

A router for rails

Language: Ruby

A lot of people here are right, the right way is with an NFA. I just want to add that the solution is not even hard, you can do it with string concatenation and capture groups using regexps. Regexps are NFAs, and are highly optimized C code in just about every JS engine.

If I have the routes /foo/bar and /foo/bar/(\d+) I can generate the regexp ((^\/foo\/bar$)|(^\/foo\/bar\/\d+$))

I'm not at all surprised, the quality of software in node is pretty low, I've seen numerous issues in node libs being just as boneheaded. I swear, the fact that the express devs overlooked a key optimization is crazy. Rails, by way of example, uses the Journey engine to solve this problem (https://github.com/rails/journey)

Hi,

The code referred to in that presentation is the rails router, journey - https://github.com/rails/journey

router.lua is much simpler than that. Journey can parse complex regular expressions like `/(app|application)/(:id)+/foo` while router.lua can only handle parameter interpolations (like `/app/:app_id/foo`). We found out that handling parameters was enough for us.

That said, the strategy we use is pretty similar: we parse the routes and transform them into a tree, which then allows us to match urls faster. It's just that our string parsing and tree construction are much, much simpler than Journey's.

> you map resources to URL's it's confusing if you are inept.

Inept? Kids these days. Forking my code then calling me inept. It's precious is what it is.

But you're moving the goal-posts. You said read the source. Since you're clearly unfamiliar with it, here's a couple handy links to the Routing code I mentioned.

https://github.com/rails/rails/blob/master/actionpack/lib/ac...

https://github.com/rails/journey

> it's complete voodoo to make side effects of editing a file default

You seem to be under the impression Rails doesn't have any facilities to reload files after modification.