Sinatra: прошлое, будущее и настоящее

1,866 views
1,771 views

Published on

онстантин часто выступает на конференциях с рассказами на совершенно разные и очень полезные Ruby-темы, но мы рады, что нам удалось сохранить изначальную тему выступления — Константин будет рассказывать именно о Sinatra: о истории, текущем состоянии и будущем фреймворка.

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,866
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
9
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Sinatra: прошлое, будущее и настоящее

  1. 1. SinatraPast, Present and Future Konstantin Haase
  2. 2. Hi!Im Konstantin. I write code.
  3. 3. Back in the internet, Im akaed as@konstantinhaase on Titter rkh on GitHub khaase on IRC rkh.im on DNS
  4. 4. "The big lesson in life, baby, is never be scared of anyone or anything." Frank Sinatra
  5. 5. "Outlines are great, quotes are terrible."Ben Orenstein (Speaking For Hackers)
  6. 6. Outline The Past The Present The Future
  7. 7. Lets pretend you dont know a thing... ... about Sinatra ... about Rails ... about Rack
  8. 8. The PastOr: "How We Do HTTP"
  9. 9. 1993CGI
  10. 10. #!/usr/bin/env perlprint "Content-type: text/htmln";if ($ENV{"REQUEST_METHOD"} != "HEAD") { print "n<h1>Hello Perl!</h1>n"}
  11. 11. No structure (Hello, inline SQL!)Enormous performance overheadNo asynchronous/streaming API Perl? Seriously?
  12. 12. December 21, 1995Ruby 0.95
  13. 13. #!/usr/bin/env rubyputs "Content-Type: text/html"if ENV["REQUEST_METHOD"] != "HEAD" puts "", "<h1>Hello Ruby!</h1>"end
  14. 14. Servlets
  15. 15. require webrickclass Simple < WEBrick::HTTPServlet def do_GET(req, res) res.status = 200 res[Content-Type] = "text/html" res.body = "<h1>Hello Ruby!</h1>" endend
  16. 16. Not web server independentNo asynchronous/streaming API Limited eco system
  17. 17. July 2004Ruby On Rails
  18. 18. OhMyGod!
  19. 19. Convention Over Configuration Do Not Repeat Yourself Model - View - Controler Testing The eco system, oh my!
  20. 20. Did not play well with others Framework, not a libraryNo asynchronous/streaming API
  21. 21. Summer 2005I discover Ruby! Woohoo!
  22. 22. December 13, 2005 Rails 1.0
  23. 23. March 2007Rack 0.1
  24. 24. proc do |env| [200, {"Content-Type" => "text/html"}, ["<h1>Hello Ruby!</h1>"]]end
  25. 25. The simplest thing possible Zero dependency applicationsGreat middleware/router infrastrucutre Server independent applications Easy testing
  26. 26. Near unusable directly Rails didnt use itNo asynchronous/streaming API
  27. 27. September 9, 2007Sinatra 0.0.1
  28. 28. get(/) { body "Hello World!" }post(/) { erb :posted }
  29. 29. Simple and clean DSL for writing Rack application. Library, not framework Plays well with anything Rack No hidden magic
  30. 30. Pollutes Object Uses instance_eval (slow)No asynchronous/streaming API One application per process
  31. 31. October 7, 2007Sinatra 0.1.0
  32. 32. October 8, 2007Sinatra 0.1.5
  33. 33. before { puts "starting" }get(/) { "Hello World!" }delete(/) { haml :deleted }after { puts "done" }
  34. 34. November 21, 2007rm -Rf sinatra
  35. 35. April 12, 2008Sinatra 0.2.0 (Complete Rewrite)
  36. 36. before { halt 404 if path !~ /css/ }error(404) { "page not found" }get /:name.css, :agent => /Firefox/ do sass :firefoxend
  37. 37. April 14, 2008rm -Rf sinatra
  38. 38. September 8, 2008Sinatra 0.3.0
  39. 39. use Rack::Lintconfigure { enable :lock }get(/*.css) { sass :style }__END__@@ stylebody color: red
  40. 40. # config.ruuse SomeMiddlewaremap(/a) { run Sinatra::Application }map(/b) { run Merb::Application }
  41. 41. December 13, 2008rm -Rf sinatra
  42. 42. January 18, 2009Sinatra 0.9.0
  43. 43. class MyApp < Sinatra::Base get /js(on)?/, :provides => "json" do pass unless params[:pwd] == "foo" "Hello World".to_json end get "*" do "wrong password, probably" endend
  44. 44. No more instance_eval for routesMore than one application per process
  45. 45. March 23, 2010 Sinatra 1.0Major Refactorings since 0.9.0
  46. 46. Tilt has been extractedA ton of new helper methods Semantic Versioning
  47. 47. April - September 2010Maintainance crisis
  48. 48. October 24, 2010 1.1.0
  49. 49. before agent: /Firefox/ do headers[X-Is-Firefox] = "yes"endget(/) { markdown "# Hello World!" }
  50. 50. March 3, 2011 1.2.0Major Refactoring
  51. 51. Live release at Ruby Use Group Berlin Better extension API Better security Long term support
  52. 52. September 30, 2011 1.3.0
  53. 53. Live release at RubyConf in New Orleans Better HTTP compatibility Better security (rack-protection) Stream/asynchronous API, finally!
  54. 54. get / do stream do |out| out << "Its gonna be legen -n" sleep 0.5 out << " (wait for it) n" sleep 1 out << "- dary!n" endend
  55. 55. connections = []get / do stream(:keep_open) do |out| connections << out endendpost / do connections.each do |out| out << params[:message] end "message sent"end
  56. 56. The Present
  57. 57. Whos using it? Travis CI, Integrity, CI Joe Picky, Resque, Gollum Heroku, Github, Engine YardSongbird, University of Lausanne, StanfordApple, LinkedIn, British Government, BBC ...
  58. 58. It inspired a lot of other projects!Ruby: Almost Sinatra, Astaire, Cuba, Padrino (based on Sinatra), Pakyow, Renee PHP: Fat-Free, Fitzgerald, Glue, klein, Laravel, Limonade, MiMViC, Silex, Slim JavaScript: Express, Picard, Roundabout, SammyCoffeeScript: Zappa Python: Bottle, Denied, Flask, itty, Juno Erlang: Fresh, Spooky Groovy: Graffiti, Ratpack Scala: Scalatra, BlueEyes .NET: Martin, Nancy, Nina Perl: Dancer, Mojolicious Java: Spark, Napalm, Htmleasy Haskell: Bird, Loli Fancy: Sinatra.fy Bash: Astley, sh.inatra C: Bogart F#: Frank Lua: Mercury, Orbit Mirah: Shatner Objective-C: RCRouter Vala: Valatra Smalltalk: RatPack Thats 52 projects in 20 languages.
  59. 59. The Future
  60. 60. 2012Sinatra 1.4.0
  61. 61. No longer pollute Object
  62. 62. # Sinatra since 0.9.0include Sinatra::Delegator10.send(:get, /) do "this works, but it shouldnt"end
  63. 63. def foo 42endfoo # => 42"hi there".foo # => 42
  64. 64. self # => maindef self.foo 42endfoo # => 42"hi there".foo # NoMethodError
  65. 65. class << self include Sinatra::Delegatorend10.send(:get, /) do "Now this raises a NoMethodError"end
  66. 66. extend Sinatra::Delegator10.send(:get, /) do "Now this raises a NoMethodError"end
  67. 67. some daySinatra 2.0
  68. 68. Use successor of Rack (code name Ponies) rm -Rf sinatra?
  69. 69. Thanks!github.com / rkh / presentations

×