What is Larry Thinking? #14 => Ruby

July 9, 2008

In this edition…

About this Newsletter

So I really, really don’t know where the time goes! All of a sudden it’s been a month since my last newsletter. I did send out a Mac newsletter in May. You can still read it online. In this newsletter I’ve just got a random assortment of things to say, much of it on Ruby, and I’ll provide the last opportunity to get some free copies of translations of my books. As always, if you have any feedback or questions regarding these topics, please pass that along. And most people do eventually see their questions answered here, so if you have any, pass them along! In the next newsletter (hopefully), I’ll write up some stuff about the business of creating and running your own business. And, of course, thanks for your interest in what I have to say…

On the Web => Adobe AIR Chapter Available Online

Peachpit Press, has posted part of Chapter 2, “Creating an Application,” from the book “Adobe AIR (Adobe Integrated Runtime) with Ajax: Visual QuickStart Guide” on their Web site. The pages discuss some of the basic technologies and how they can be used together in an AIR application. The direct URL is http://www.peachpit.com/articles/article.aspx?p=1211888.

On the Web => Ruby is on the Rise

Here’s a quick article suggesting that Ruby’s popularity will quadruple in the next five years. The large increase is admittedly in part becase Ruby’s still being used by a relatively small population now. An interesting read, though.

On the Web => Ruby on Rails Screencasts

If you really want to be impressed with Ruby on Rails, check out these screencasts. In a matter of minutes, the developers are able to create really sophisticated Web sites using Ruby on Rails. Of course, it probably took them weeks to master Ruby on Rails and weeks to master their text editor (the popular TextMate on Mac OS X).

What is Larry Thinking => Five Seconds on Ruby

I’m currently writing my “Ruby: Visual QuickStart Guide” right now, so naturally that’s where my thoughts are. I plan on writing more and in more detail on the subject, but wanted to toss a couple of things out there for now. I first started using Ruby in early 2005, thanks to the popularity of Ruby on Rails (a reason many people turned to Ruby). Ruby on Rails is just a Web development framework that uses Ruby. It’s been successful because it does so much of the work for you (perhaps more so than other frameworks), including creating database tables. Lately there’s been some concern about the scalability of Ruby on Rails (RoR) sites, in part because of the downtimes Twitter has experienced as of late.

Ruby is a scripting language, like PHP, which means that all Ruby code is run through a Ruby executable (in other words, Ruby needs to be installed on the computer; you don’t create standalone applications as you would with C or C++). Ruby is open source and runs on most operating systems. In fact, Mac OS X comes with it installed.

Unlike PHP, Ruby is a pure object-oriented language. It’s arguably more OOP than most, including Java. I say this because nearly everything in Ruby is an object or can be treated like an object, including literal numbers and strings. For example, you can invoke the to_s (to string) method on any number: 2.to_s returns “2”. Ironically, even though you use objects exclusively in Ruby, it’s an easier, more manageable version of OOP, in my opinion. Access control is simplified compared to Java and C++. Inheritance is pretty straightforward. You don’t have the ability to overload or create abstract methods, so it’s maybe not as full featured as other OOP languages. Unlike PHP, you don’t have to place code within special tags and unlike Java, C, and C++, you don’t have to create a special function that gets called when the script is run. So much functionality is built into Ruby that most common things can be done very easily. In my first PHP book, I have an example that takes a string of words (or names), turns them into an array, sorts them in alphabetical order, then turns that back into a string. In Ruby, I can do all that in one line!

What really makes Ruby unique is its philosophy. The underlying belief is that programming should be fun. I don’t personally know about that, but programming shouldn’t be extremely frustrating, which it often is. There’s also a belief that things should work as you expect them to, which shouldn’t be as novel as it is. And there’s the thinking that the programmer’s time is more valuable than the computer’s so an emphasis is put on how quickly Ruby can be written, even if that means it doesn’t execute quite as quickly as it could Some of the conveniences, like not having to terminate lines with a semicolon, are nice, but take some getting used to after so many years of always using semicolons.

Those are just a few thoughts I have on Ruby. I’ll add some more detailed information, including some specific examples, later. The topic of “duck typing” is worth knowing about, along with Ruby’s ability to update existing class–including those built into Ruby–on the fly. Both features really separate Ruby from the alternatives.

Book Giveaway => Foreign Editions

You must be subscribed to the newsletter to qualify for the book giveaway.

My Book News

I’m still working on my “Ruby: Visual QuickStart Guide” for Peachpit Press. It’s due to come out early Fall (in the US). This date has been pushed back slightly. The book is also available for reading as I write it thanks to the Rough Cuts series. See http://safari.peachpit.com/9780321580658 for more information. As an interesting advantage, people that buy the hard copy of the book will also have access to an online version. Not only will readers therefore be able to read the book wherever they’re at (assuming they’re online) but it gives readers a great way to search through the book’s content.

Early this Fall, I’ll be finally doing the third edition of my “PHP for the World Wide Web: Visual QuickStart Guide”. It’ll be a relatively light update, with some corrections and information regarding PHP 6. More on this in future newsletters.