Save 37% off PRO during our Black Friday Sale! »

Padrino Framework 0.11 and 1.0

40b5a05e7dad8cbc9d886d8593d8ea02?s=47 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.



January 24, 2013


  1. None
  2. 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
  3. Agenda • Why Padrino? • A quick tour • Upcoming

    release 0.11 • The future: v1.0 • Contributions • Questions?

  5. • 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
  6. 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

  8. A community is crucial for a framework's growth. • #padrino

    on > 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

  10. 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! :)
  11. Defining controllers MyApp.controllers :posts do get :index do 'get in

    /posts' end get :foo do 'get in /posts/foo' end end
  12. 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!
  13. 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.*/)! Multiple applications
  14. 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
  15. # from a controller or a view: email to: '',

    from: '', subject: 'Foo!', body: 'Bar! :)' # and from a... model? The same! to: '', from: '', subject: 'Foo!', body: 'Bar model! :)' # Somebody said templates? Sure! MyApp.mailer :notify do email :exception do |exception| from 'The Exceptionator <>' to '' 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
  16. $ 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)...
  17. Padrino's Admin powered by Twitter Bootstrap 3.0

  18. Set your structure RAILS > 50 files PADRINO < 10

  19. Remember LIGHT != FAST LIGHT == SIMPLE


  21. by @anayden LESS CODE == (often) FASTER

  22. Mythbuster! "Padrino is great for small, nano (single file) applications

    but not for big projects." Remember! Multiple Applications! BUSTED!
  23. 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!
  24. 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), • ...
  25. 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
  26. UPCOMING RELEASE v0.11 coming soon

  27. • Use Twitter Bootstrap • Ajaxified Filtering • Advanced Search

    • Supports Ohm Persistence Revamped Admin Panel
  28. • 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
  29. 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.set_home "/HomeFoo", "Foo Home" @breadcrumbs.add :foo, "/foo", "Foo Link" breadcrumbs @breadcrumbs
  30. • 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
  31. • 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
  32. THE FUTURE: v1.0 Q3 2013


  34. 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?
  35. 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
  36. 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)
  37. 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)
  38. node.rb [rack + thin] If we try to mimic node.js

    in ruby with: • Threads (MRI) • Chunked responses Full Sources @
  39. $ ab -c 10 -n 3000 Requests per second:

    3192.45 [#/sec] (mean) node.rb [rack + thin] on MRI 1.9.3 WHAT??? :)
  40. 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!
  41. 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
  42. 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
  43. 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 do include Route3 get :index do 'hello world' end run! end
  44. 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
  45. Modularized mailers module Notifier include Padrino::Mailer email :registration do |account|

    from '' to subject 'Welcome!' render :registration end end
  46. 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
  47. 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
  48. 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
  49. 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
  50. 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
  51. 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)
  52. • 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
  53. • 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
  54. • Be simple • Be clean • Be elegant Modularized

    apps and gems
  55. • Be simple • Be clean • Be elegant you

    can be our next contributor! or hopefully learn from our code! Modularized apps and gems

  57. 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!!
  58. And to the core team! • Arthur. (achiu) • Davide.

    (DAddYE) • Florian. (skade) • Nathan. (nesquena) • Darío. (dariocravero)

  60. ~ 3000 REQ/S @ ~ 100 MB RAM on a

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