Why ruby and rails

1,089 views
1,022 views

Published on

Reuven Lerner's first talk from Open Ruby Day, at Hi-Tech College in Herzliya, Israel, on June 27th 2010. An overview of what makes Rails a powerful framework for Web development -- what attracted Reuven to it, what are the components that most speak to him, and why others should consider Rails for their Web applications.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,089
On SlideShare
0
From Embeds
0
Number of Embeds
24
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide





























  • Why ruby and rails

    1. 1. Why Ruby? Why Rails? Reuven M. Lerner reuven@lerner.co.il Hi-Tech College June 27th, 2010
    2. 2. Welcome!
    3. 3. Remember Perl? • Strings • Networks • Databases • Very fast coding • (Relatively) fast execution • CPAN!
    4. 4. Perl had a big problem
    5. 5. So what? • Unreadable code = unmaintainable code • Unmaintainable code = eventual disaster
    6. 6. Web apps are complex • HTML • CSS • JavaScript • SQL • Ruby (or another language)
    7. 7. Web apps are complex The really hard part: • HTML Getting these technologies • CSS to work together, smoothly • JavaScript • SQL • Ruby (or another language)
    8. 8. Rails to the rescue! • Smooths the edges between these parts • Reduces the pain in writing apps • Encourages you to write maintainable code • Allows you to focus on your domain
    9. 9. It’s all about the data • Philip Greenspun • The data model is key • Provided a model (ACS) • Rails says: Create one!
    10. 10. ActiveRecord • Makes it easy to work with databases • Zero lines of code, for starters! • Lets you write a DSL (domain-specific language) that describes your data • Validations, callbacks, scopes
    11. 11. Other data stores • MongoDB • Memcached • Redis • Cassandra • Amazon S3 • You name it...
    12. 12. RESTful resources • Standard HTTP interface to actions • GET, POST, PUT, DELETE the way they were supposed to be used • Built into Rails, works automatically • Gives you lots automatically
    13. 13. Separation • MVC + H • Models, views, controllers + helpers • Push code to the model • Conventions — but they work • Read someone else’s code without crying • Read your own code without crying!
    14. 14. Environments • development, testing, production • Create your own (e.g., “staging”) • Each can load different libraries • Each has its own log levels
    15. 15. Console >> p = Person.find(1) => #<Person id: 1, email_address: "reuven@lerner.co.il", first_name: "reuven", last_name: "lerner", password: "foo", administrator: true, created_at: "2009-07-08 12:50:42", updated_at: "2010-06-10 10:51:04", avatar_file_name: "Reuven_headshot.jpg", avatar_content_type: "image/ jpeg", avatar_file_size: 1248486, avatar_updated_at: "2010-06-06 19:22:00"> >> p.update_attributes(:administrator => true) => true >> p.nodes.length => 6
    16. 16. Filters • Execute code before or after any controller actions before_filter :require_login, :only => [:edit, :update, :logout, :tags] • Authentication • Common variable settings • Logging
    17. 17. Rake • Sort of like “make” — but in Ruby • Tasks have access to objects • Automate all sorts of tasks • Migrating data • Creating sitemaps
    18. 18. Ever read this?
    19. 19. Software ICs • Reusable code libraries • Multiple libraries that adhere to a spec • Download and install • First suggested in 1986! • Cox put these ideas into practice • Ever hear of Objective-C?
    20. 20. Gems • Reusable libraries of Ruby code • As little as a constant • As big as a complete CMS • Download, install, and use! • Open source — free to use and change
    21. 21. How popular?
    22. 22. How popular?
    23. 23. Some gems • Paperclip (attachments) • Devise (authentication) • MongoMapper (MongoDB access) • will_paginate (pagination)
    24. 24. Plugins • Want or need to change Rails itself? • Write a plugin! • Or use one of the many out there • (some of which now come as gems)
    25. 25. Some plugins • acts_as_tree (hierarchical models) • html_test (check validity of views) • annotate_models (add column lists)
    26. 26. My brain is too small! • Yes, there’s a lot to learn • Most of it can wait a little bit • Start with what you know • Improve yourself and your code over time
    27. 27. Wait, isn’t Ruby slow? • Yes. For now. • JRuby, Gemstone, Ruby 1.9/2.0 • Is execution speed your biggest worry? • Development speed • Reliability • Maintainability
    28. 28. So, why Rails? • Common Web development tasks are easy • You write less code • The code that you do write is better • You can maintain your code more easily • Less pain dealing with many Web issues
    29. 29. Finally, because it’s fun “I tried to make people enjoy programming and concentrate on the fun and creative part of programming when they use Ruby.” — Matz
    30. 30. Join us! • Israel.rb (Google group) • Ruby, Rails courses right here! • Call me: 054-496-8405 • E-mail me: reuven@lerner.co.il • Interrupt me: reuvenlerner (Skype/AIM)

    ×