开发者

What's the difference between a Rack app and a Sinatra app?

What adv开发者_开发问答antages do I have with a Rack app over a sinatra app?

thanks


I think the asker wants the merits of keeping it to just Rack.

Considering Sinatra is already an extremely thin & minimalistic veneer for typical web applications, my short answer will be: when your needs are atypical and/or spartan

when you don't even need...

  • layout/ templating - you enjoy writing out raw string http content
  • cookies and sessions - no memory, everything is one-shot default
  • methods - your app abuses the URL and HTTP VERB in crazy ass ways
  • to be modern - you have nostalgia with CGI/perl scripts in the 90s
  • any structure - your app returns time of day in text. per se.

I use Sinatra because I believe this is the lowest footprint you can really focus on business function of my apps, without dealing with web server nitty-gritties (Rails conversely is monoli-thick!) and still have an intuitive MVC-like project structure

You gain really little except code lines, and a smarmy twinkle in your eye when impressing geeks honest.

p.s.: I maintain a nice skeleton for my own needs at http://github.com/codepants/yasumi


Rack, a modular Ruby webserver interface Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.

Rack is a bare-bones middleware and therefore a bit more lightweight but doesn't help you that much when building complex applications.

Sinatra is a Domain Specific Language (DSL) for quickly creating web-applications in Ruby.

It keeps a minimal feature set, leaving the developer to use the tools that best suit them and their application.

Sinatra is a small "framework" on top of Rack providing you with nifty methods to get up running quickly. It's not that lightweight as Rack but still as light as a cloud in the sky.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜