News for hackers. Stuff that matters.
Re:Pakyow 0.8: New Router, Updated View Syntax, and Smarter ... by VeejayRampay on Tuesday March 04, 2014 @12:47PM (#7341736)
I've seen somewhere on the site that Pakyow is "up to 40 some percent faster than Sinatra". What makes Pakyow faster than Sinatra under the hood?
Re:Pakyow 0.8: New Router, Updated View Syntax, and Smarter ... by bryanp on Tuesday March 04, 2014 @01:02PM (#7341849)
I can't speak too intelligently about how Sinatra is architected, but here's a bit about how Pakyow handles routing.

A route is just a regex and set of functions (blocks, procs, whatever). When a request comes in, the following things happen:

1. An AppContext instance is created that contains the request's state 2. Route is matched (narrowed by method then match on path) 3. Each function is evaluated within the context

Hooks, etc aren't special things and are just functions at a particular location in the set. This set is built at startup, so there's no object creation to fulfill a request (except the Request/Response/AppContext objects). The routing bits of pakyow (pakyow-core) are very close to the Rack metal.

Aside from routing, nearly everything in Pakyow is middleware. This makes it easy to completely remove (not just disable) components like static file handling, logging, etc.

Hope that helps!