Ruby on Rails :: Welcome to the Twenty-First Century. You will like it here.
Herein, and hereinafter, I learn Ruby and Rails. They are elegant, they are beautiful, I am excited.
Ruby :: Overview
Ruby is a modern programming language. It is powerful and extensible like LISP and Python. It is forgiving and flexible like PHP, concise and coherent like Python. End your line with a semi-colon — or don’t. An ellipsis is three dots, but two is ok — we know what you mean. Need a variable? No need to declare it, no special symbol to mark it; just use it.
ruby = "A modern programming language which you will love."
ruby_adjectives = [ "modern", "powerful", "flexible", "concise" ]
ruby_adjectives << [ "clean", "elegant" ]
Ruby’s conventions reflect the collective common sense that programmers have developed through trying times. For examples, naming conventions just make sense: Little things — local, ephemeral variables and methods — use lowercase. Big things — modules, classes, constants — use uppercase. Lowercase names use underscores to split words, and uppercase names use camelcase words.
message_to_readers = "Please comment!"
DesiredCommentCount = 5
if (BlogPost.comment_count < DesiredCommentCount) print message_to_readers
Don’t just take my word for it that Ruby has so many redeeming qualities, try it out for yourself with this interactive tutorial.
If you’re too cheap to buy the canonical introductory Ruby text, I heartily endorse Why’s (Poignant) Guide to Ruby, a well-written and humorous guide which uses mnemonics brilliantly and effectively to not only introduce Ruby, but make it intuitive. Beginning programmers, especially, would do well to read it.
Rails :: Overview
Rails gives you a skeletal web application out of the box (the design of which incorporates many, many design principles learned the hard way over a span of decades) and tools to make working with it much, much easier. Rails is opinionated — it makes (good) infrastructure decisions for you, leaving you to think only of the application level — once you’re mastered Rails, that is! This is a prime example of abstraction, and is analogous to the divisions between layers in the TCP/IP stack and between kernel, drivers and programs. Asking a programmer to create the infrastructure, presentation, and functionality of a web application is a lot like asking for a kernel and a graphical user interface to go with the program they want.
It’s clear that only a select few programmers need to be under the hood creating infrastructure and tools — the rest should build application logic and user interfaces. Presentation is rightly placed in the hands of the specific programmer or designer, supported by countless templates and widgets. The application logic is up to you. Let Rails be your infrastructure, and you will have the pleasure of working with the Ruby programming language, a very well thought out Model-View-Controller (MVC) architectural pattern, and the revolutionary Prototype Javascript toolkit.
Model-View-Controller Pattern
Decouple data representation, application behavior, and presentation. Orthogonal design: it’s a good idea. The upshot is, when you change something you should be able to change it in one place — not here, there and everywhere. Rails keeps layouts in one place, data models in another, controller operations such as Create, Retrieve, Update and Delete (CRUD) elsewhere, and views still elsewhere (a library might have “author”, “book”, and “genre” views, which are just different ways of looking at the data).
Resources
Recommended reading. I’ve only included the good ones.
Dead Tree Books
- Must buy: Agile Web Development with Rails
- Language reference: Programming Ruby (2nd Ed.)
- If you still have questions: Ruby For Rails
Online References: Big
- Why the Lucky Stiff: Why’s (Poignant) Guide to Ruby - this well-written and entertaining guide to Ruby will suck you in. It’s not a bad place to start, especially for beginning programmers. Clever analogy and mnemonics really help make the lessons stick. And it’s a funny, rather exuberant poignancy featuring an inordinate number of cartoon foxes.
- Wikibook: Ruby Programming
- Sergio Pereira: Prototype Reference
- Microsoft: Javascript Reference
- The Art of Unix Programming: Orthogonal Design
Online References: Small
- Try Ruby (in your browser) - interactive online Ruby tutorial by Why
- Java Blueprints: MVC Diagram
- Jonathan Snook: Prototype Cheat Sheets
Additional Tools
Next up: I try to build a quick and dirty rails app. Hilarity ensues.