If you've been looking for a good overview on Rails, look no further. This three-part series will help you understand this popular framework. It is excerpted from chapter one of the book Beginning Rails: From Novice to Professional, written by Jeffery Allan Hardy, Cloves Carneiro Jr. and Hampton Catlin (Apress, 2008; ISBN: 1590596862).
Introducing the Rails Framework - Rails Is Ruby (Page 4 of 4 )
There are a lot of programming languages out there. You’ve probably heard of many of them. C, C#, Lisp, Java, Smalltalk, PHP, and Python are popular choices. And then there are others you’ve probably never heard of: Haskel, IO, and maybe even Ruby. Like the others, Ruby is a programming language. You use it to write computer programs, including, but certainly not limited to, web applications.
Before Rails came along, not many people were writing web applications with Ruby. Other languages like PHP and ASP were the dominant players in the field, and a large part of the web is powered by them. The fact that Rails uses Ruby is significant because Ruby is considerably more powerful that either PHP or ASP in terms of its abilities as a programming language. This is largely another symptom of the web’s maturity. Now that it’s attracting a larger audience, more powerful languages and tools are falling into the fold.
Ruby is a key part of the success of Rails. Rails actually uses Ruby to create what’s called a domain-specific language, or a DSL. Here, the domain is that of web development, and when you’re working in Rails, it’s almost as though you’re writing in a language that was specifically designed to construct web applications—a language with its own set of rules and grammar. Rails does this so well that it’s sometimes easy to forget that you’re actually writing Ruby code. This is a testimony to Ruby’s power, and Rails takes full advantage of Ruby’s expressiveness to create a truly beautiful environment.
For many developers, Rails is their introduction to Ruby, a language whose following before Rails was admittedly small at best, at least in the west. While Ruby had been steadily coming to the attention of programmers outside Japan, the Rails framework is what brought Ruby to the mainstream.
Invented by Yukihiro Matsumoto in 1994, it’s a wonder Ruby remained shrouded in obscurity for as long as it did. As far as programming languages go, Ruby is among the most beautiful. Interpreted and object-oriented, elegant and expressive, Ruby is truly a joy to work with. A large part of Rails’s grace owes to Ruby and to the culture and aesthetics that permeate the Ruby community. As you begin to work with the framework, you’ll quickly learn that Ruby, like Rails, is rich with idioms and conventions, all of which make for an enjoyable, productive programming environment.
In summary, Ruby can be described as follows:
An interpreted, object-oriented scripting language
Elegant, concise syntax
Powerful metaprogramming features
Well suited as a host language for creating DSLs
Appendix A of this book includes a complete Ruby primer. If you want to get a feel for what Ruby looks like now, go ahead and skip to that appendix and take a look. Don’t worry if Ruby seems a little unconventional at first. You’ll find it quite readable, even if you’re not a programmer. It’s safe to follow along in this book learning it as you go, referencing the appendix when you need clarification. If you’re looking for a more in-depth guide, Peter Cooper has written a fabulous book titled Beginning Ruby: From Novice to Professional (Apress, 2007). You’ll also find the Ruby community more than helpful in your pursuit of the language. Be sure to visithttp://ruby-lang.orgfor a wealth of Ruby-related resources.
Please check back tomorrow for the continuation of this article.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.