Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Padrino Framework 0.11 and 1.0

daddye
January 24, 2013

Padrino Framework 0.11 and 1.0

A small walkthrough about Padrino and then what's coming in 0.11 and 1.0 version.

daddye

January 24, 2013
Tweet

Other Decks in Programming

Transcript

  1. A big thanks to our sponsor Triggit enables advertisers and

    agencies to Build, Run, Measure, and Optimize retargeting-driven display campaigns from a single platform
  2. Agenda • Why Padrino? • A quick tour • Upcoming

    release 0.11 • The future: v1.0 • Contributions • Questions?
  3. • Simple to use • Simple to hack • Developer

    freedom • Coding should be fun In contrast to other frameworks we keep very few layers between you and the core... All thanks to Sinatra! Philosophy
  4. Built on top of Sinatra with tons of goodies: •

    Agnostic (10 orms, 6 js, 4 tpl engines, etc...) • Generators (padrino g, padrino plugin, etc...) • Multiple applications support • Advanced Routing System • Helpers (form, tags, etc...) • Admin interface • Mailers ...and much more Sinatra on the rocks
  5. WITHOUT SPECIAL OPTIMIZATIONS ON BOTH SIDES benchmark @ http://git.io/khf8dA PADRINO

    IS 4 TIMES FASTER THAN RAILS WITHOUT SPECIAL OPTIMIZATIONS ON BOTH SIDES benchmark @ http://git.io/khf8dA
  6. A community is crucial for a framework's growth. • #padrino

    on irc.freenode.net > 50 users every day • Github with highly active core devs solving issues • Stackoverflow questions 'padrino' tag • Google group lots of knowledge in here :) • Guides & Tutorial our very own always growing docs • A lot of Gems Sinatra/Rack compliant and more The community
  7. require 'padrino-core' class MyApp < Padrino::Application get '/' do 'hello

    world' end get :foo, map: '/foo/bar' do 'a named route!' end end A simple app Look Ma! I see my routes! :)
  8. Defining controllers MyApp.controllers :posts do get :index do 'get in

    /posts' end get :foo do 'get in /posts/foo' end end
  9. get :index, provides: [:html, :json] do case content_type when :html

    render '/my-page' when :json render json: Post.all end end Using content types No magic, just Ruby!
  10. class App1 < Padrino::Application get '/' do slim 'h1 hello

    from app 1' end end class App2 < Padrino::Application get '/' do haml '%h1 hello from app 2' end end Padrino.mount(App1).to('/app1') Padrino.mount(App2).to('/').host(/app2.*/) Padrino.run! Multiple applications
  11. require 'slim' class MyApp < Padrino::Application layout :mine get '/foo'

    do slim 'h1 hello world' end get :index do # looks for view bar.slim # and layout mine.slim render 'bar' end end Rendering views less conventions, more clarity
  12. # from a controller or a view: email to: '[email protected]',

    from: '[email protected]', subject: 'Foo!', body: 'Bar! :)' # and from a... model? The same! MyApp.email to: '[email protected]', from: '[email protected]', subject: 'Foo!', body: 'Bar model! :)' # Somebody said templates? Sure! MyApp.mailer :notify do email :exception do |exception| from 'The Exceptionator <[email protected]>' to '[email protected]' subject exception.message body exception.backtrace.join("\n") # or # render 'whatever_haml_slim_or_plain' end end MyApp.deliver :notify, :exception, exception Padrino's Postal Office Simple. Clear. Padrino Style
  13. $ padrino g admin $ padrino g admin_page Post (or

    any model) BOOM! You're in business baby ;) Padrino's Admin If you need an easy way to view, search and modify your data (as most apps do)...
  14. Mythbuster! "Padrino is great for small, nano (single file) applications

    but not for big projects." Remember! Multiple Applications! BUSTED!
  15. In the real world that means... ...having different apps to

    handle: • your site • your blog • your product gallery • your backend interface with Padrino's Admin and share your models for free!
  16. In the real world that means... ...crafting your own e-commerce

    site: • special admin interface (app 1), • eCommerce front-end (app 2), • eCommerce API (app 3), • marketing blog (app 4), • ...
  17. Directory structure (multi-app) E.g. three apps, one project: 1. Admin

    2. Blog 3. Projects They can share same models They share an admin panel They can share a session
  18. • Use Twitter Bootstrap • Ajaxified Filtering • Advanced Search

    • Supports Ohm Persistence Revamped Admin Panel
  19. • Reduce Padrino load time by 20% • Lazy load

    Padrino mailer and many modules • Refactored to reduce app memory footprint • Faster, smarter development reloader Performance Enhancements
  20. Breadcrumb Helpers Form Group Helpers New & Improved Helpers -

    form_for @post do = f.check_box_group :color, :collection => @colors, :fields => [:name, : id] = f.radio_button_group :color, :options => ['red', 'green', 'blue'] @breadcrumbs = breadcrumbs.new @breadcrumbs.set_home "/HomeFoo", "Foo Home" @breadcrumbs.add :foo, "/foo", "Foo Link" breadcrumbs @breadcrumbs
  21. • Upgrade to latest Sinatra 1.3.3 • Add Puma server

    support • Improved, Prettier Logging • Mongoid 3.x support • Namespaced & Gem-ified Apps • Multiple global configuration blocks Now Supported
  22. • Improved support for JRuby • Fixes fragment caching support

    • Fixes controller layout rendering • Cleanup documentation • Fixes Padrino plugin runner issues • And much more... Bug Fixes Galore
  23. It's been almost two years since we started planning for

    1.0. Lots of things have been on our minds since: • Reactor pattern ? • Actors/Celluloid ? • Concurrency? • JRuby ? • Rubinius ? • MRuby ? What took us so long?
  24. Ruby isn't the fastest language, we all know that, but

    the amount of resources used for a medium sized Rails app is unacceptable: More than 2 gb of ram to serve less than 100 req/s Scaling often means "buy more RAM" :( Better resource management
  25. While Padrino does better, we're still far behind. node.js serves

    ~ 3500 req/s single thread and on one process! using express.js (Sinatra inspired framework) Better resource management (2)
  26. This isn't a benchmark competition. However, one thing is clear:

    We should try and better use our resources. RUBY IS NOT THAT SLOW. Better resource management (3)
  27. node.rb [rack + thin] If we try to mimic node.js

    in ruby with: • Threads (MRI) • Chunked responses Full Sources @ http://git.io/FN3ndQ
  28. $ ab -c 10 -n 3000 http://127.0.0.1:3000/ Requests per second:

    3192.45 [#/sec] (mean) node.rb [rack + thin] on MRI 1.9.3 WHAT??? :)
  29. Could be threaded by default with: • Eventmachine (where the

    server supports it). • An internal node-esque mechanism. Especially on JRuby and Rubinius. Sinatra already supports streaming on em servers Solutions!
  30. Development reloading isn't simple particularly if you are testing thread

    safety. In v1.0, we will give you: • Fast Fork Reloader (with preforking), • Full drip support for JRuby • and we're still planning more... A brand new reloader
  31. In Padrino v1.0 everything will be modular. That means that

    you can use our rendering system -whenever it make sense- in a model or a lib. The same goes for routing and mailers. Decoupled and Modular Module me
  32. Modularized routes module Route1 include Padrino::Routes get '/route1' do 'route1'

    end end module Route2 include Padrino::Routes get '/route2' do 'route2' end end module Route3 include Route1 include Route2 get '/route3' do 'route3' end end Padrino.new do include Route3 get :index do 'hello world' end run! end
  33. Modularized templates module Templater1 include Padrino::Templates template(:hello) { 'h1 hello

    world' } def self.page_template slim :page end end class Templater2 # Inherit templates include Templater1 def self.page_custom slim :hello, layout: false end end
  34. Modularized mailers module Notifier include Padrino::Mailer email :registration do |account|

    from '[email protected]' to account.email subject 'Welcome!' render :registration end end
  35. Padrino apps will support being packaged and loaded from gems.

    Padrino 1.0 will provide: • Mount separate apps using Bundler • Reload support in development • Test yet run each in isolated gems. Modularized apps and gems
  36. We love the work done by @joshbuddy with http_router but

    we are planning a rewrite towards 1.0 to simplify routing syntax: • Named routes • Namespaced Routes (aka controllers) • Advanced routing Routing: Do More with Less
  37. Simplified routes Simpler to remember routing syntax The new routing

    system will be more explicit than before so you should always provide a path. Maybe a bit annoying but definitely easier to read! get :index do end now should be: get :index, '/' do end better explained: edit :me, :with => :id do end now should be: edit :me, '/me/:id/edit' do end
  38. Most of the work nowadays is done by a smart

    UI living client-side built on Javascript and our Ruby apps tend to be merely APIs interface. We also want to help you with this... Less conventions, more expressiveness Easy peasy APIs
  39. or Easily generate an API's documentation! Easy peasy APIs example

    get :foo, '/foo' do 'hello foo' end desc 'My route description is optional' path '/bar' get :bar do 'welcome to the bar' end
  40. Namespaced routes namespace :user_products, '/user/:user_id/products' do get :index, '/:id' do

    "Hello user id: #{params[:user_id]}" end end # url(:user_products, :index, @product, @user)
  41. • Complete data-driven approach. Awesome UX • Simplify authorization for

    roles • Sorting, filtering and paging support • Pluggable authentication. Our built-in solution will be replaced with basic HTTP auth and an API will be created to easily plug solutions like padrino-warden Padrino Admin
  42. • Continue to improve HTML5 support • Better support for

    websockets • Better asset pipeline management • Better support for JS libraries and frameworks such as Backbone, Ember, Angular, Spine, Batman, etc. • Hot code push of your JS and CSS on development mode! ;) • Easy and reliable deployments More awesomeness
  43. • Be simple • Be clean • Be elegant you

    can be our next contributor! or hopefully learn from our code! Modularized apps and gems
  44. Big thanks to... • Darío (dariocravero). New Padrino core team

    member, helping us get towards 0.11 • Igor (ujifgc). New Padrino contributor, sending out countless pull requests. • Tom Parandyk (tomatuxtemple). Awesome work on the new branding and soon a new website. • Carlo (waydotnet). Rewriting the Padrino admin powered by Bootstrap. • Matthias Guenther (matthias-guenther). For putting up our very own Open Source Book!!
  45. And to the core team! • Arthur. (achiu) • Davide.

    (DAddYE) • Florian. (skade) • Nathan. (nesquena) • Darío. (dariocravero)
  46. ~ 3000 REQ/S @ ~ 100 MB RAM on a

    modern (unix-like) machine using only one process BE TINY. BE FAST. BE A PADRINO.