Rails Snippets - 11/29

Holy Shmoly, Ruby 1.9 smokes Python away

Initial performance numbers would seem to indicate that Ruby 1.9 (due by Christmas) will be lots faster.

Quoted-Printable: My .irbrc

If you spend a lot of time in IRB (most of us probably do), it’s worth taking the time to learn how to customize it. This is a good start.

Faker

Nice clean library to generate fake data. The home page says it’s a port of Perl’s Data::Faker library, which I’d never even heard of.


Book Review: Beginning Ruby: From Novice to Professional

I think Beginning Ruby: From Novice to Professional is a better first Ruby book than the venerable Pickaxe.

The previous statement is almost heresy in the Ruby community. Don’t get me wrong, you should own the Pickaxe. It’s a great book and certainly lives up to it’s description as “the definitive reference to Ruby”. However it’s much more of a reference book than an introduction to the language. And it’s huge - 864 pages. This is not a book you can just throw in your bag and carry around with you. It’s a book you would keep at your desk perhaps, dog-eared and coffee stained. In this role, it is ideal. As an introduction to the language, however, it leaves something to be desired.

Beginning Ruby, on the other hand, is an excellent (and I would argue more approachable) introduction to the Ruby language, written by one of it’s more notable users. Peter Cooper is well known, in both the Ruby and Rails community. He runs the Ruby-centered blog Ruby Inside, and has developed a number of applications in Rails, including the Snippets code repository, which was subsequently sold to DZone. Peter also has done a fair amount of writing over the years for a variety of sites.

The book is broken up into three primary sections, plus a handful of appendices:

  • Part 1: Foundations and Scaffolding - This is an introduction to the Ruby language. Starting with installation, and going through the basic structure of the language and it’s elements: strings, containers, and the like. There is a chapter on building basic Ruby programs that puts all of these concepts together. One nice bonus was a chapter on the Ruby ecosystem, which covers the various websites, irc channels, and other resources for Ruby developers.

  • Part 2: The Core of Ruby - This section covers the meat and potatoes of Ruby. It covers classes, modules, libraries, debugging and testing, databases, and advanced features. This is all tied together with a nice example application that implements a text-parsing bot. I liked that this application included unit tests, but it would have been nice if the testing was done test-first. This is a personal preference, but I think it’s a best practice and would like to see it demonstrated more in books like this.

  • Part 3: Ruby Online - As you would expect, this section includes some coverage on Rails. Its not exhaustive, and isn’t intended to replace a full-blown book on Rails. It does offer a thorough overview though. That’s not the sole focus of this section, however. Ample coverage is given to FTP, HTTP, and email, as well as raw TCP sockets and other networking type things. There is also a good chapter in here called “Useful Ruby Libraries and Gems”. The chapter itself is a bit misplaced as it has very little to do with the internet, but it is a very useful overview of a lot of the third party gems that you can install. I found myself using this section regularly on a recent project.

In addition to these sections, there are three appendices. The third appendix, called “Useful Resources” contains pointers to a lot of online resources which would likely be unknown to someone new to Ruby. I didn’t find much in there I hadn’t seen already, but I’ve been using Ruby for a little while. The first two appendices are a primer and reference for Ruby. These are both very good, and would be useful as references for a new developer (or someone who doesn’t have the entire ruby syntax committed to memory yet, like me).

Weighing in at over 600 pages, this is a comprehensive book. At the same time, it’s quite a bit smaller than the Pickaxe, which makes it much more portable (there’s also a PDF version available for $10 if you’ve purchased the dead-tree edition, for the ultimate in portability).

As with the last book I reviewed, this one appears to have been well technical reviewed. I didn’t notice any errors. I also enjoyed Peter’s writing style, which is concise but not dry.

In summary, if you want to learn Ruby, Beginning Ruby: From Novice to Professional is the book to buy.

Disclaimer: I received a free copy of this book from the publisher in exchange for a review. There were no conditions other than that, but in the interest of full disclosure, now you know.


Monday Question: Who Are You and Why Are You Here

Monday Questions is a recurring series on Approaching Normal. For more questions like this, please visit the archives

Feedburner tells me that I now have over 100 subscribers to my RSS feed. That of course doesn’t include the people who read this via Planet Ruby on Rails. In honor of this milestone, today’s question is: Who are you, and why are you here?. I’d like you to introduce yourself, and tell me why you come here.

Post your answers in the comments below.


MacBook Pro After One Week

So I’ve had the MacBook Pro for a full week now. Here’s my assessment.

  • I don’t at all regret the decision to get the refurbished model. I saved $400 and the unit appears to be flawless. That said, the Wireless Mighty Mouse I bought with it was D.O.A.

  • This thing is really, really fast.

  • Apple customer service is awesome. So the Mighty Mouse was dead. I called Apple’s tech support and explained the situation. The lady I spoked with didn’t ask any questions, she just immediately shipped a new one. No annoying “have you tried changing the batteries” type of questions - just an apology for the inconvenience and a new mouse on it’s way. This is what customer service should be like.

  • Leopard is really nice. Visually it’s beautiful, and functionally there’s a lot to love. This is my first experience with OS X so I can’t compare it to the previous versions.

  • I like the 3-D Dock. This has been panned by a lot of bloggers, but I think it looks really good. That said…

  • I hid the dock after the first day. With Spotlight, I don’t really need it. Because….

  • Spotlight is really, really fast and makes a very good application launcher. Hit Command-Space, and type the first few letters of the app you want to launch, e.g. ’ter’ to launch Terminal, ‘adi’ to launch Adium, etc. See the image below for an example of what I’m talking about

All in all, I’m extremely happy with it.


Book Review: Practical Rails Social Networking Sites

Summary

Rails Social Networking Sites walks you through the process of building a Web 2.0 social networking site (something like MySpace), called Rails Coders that includes the features you would expect in that sort of site:

  • User signup and management (based on restful_authentication)
  • Content management
  • Blogging (with web services)
  • Markup languages like Textile and Liquid
  • Mashups using Google Maps and Flickr
  • photo management (attachment_fu and RMagick)
  • Tagging

This book is not, of course, about building social networking sites, though that does serve as the exercise in the book. It’s about going beyond the basics with Ruby on Rails, and building something useful.

Rails Social Networking Sites is targeted at developers who have some experience with developing Rails applications. That said, you don’t need much. If you have read one of the other books on Rails or developed a couple of play applications, you’ll be fine.

Pros

There’s a lot to like about this book. It’s well written, and covers a broad range of useful topics. Here’s the things I really liked:

  • It covers useful topics in the context of a real-world application. Most of the Rails books out there (at least the ones I own or have looked through) cover the basics of Rails, and maybe a few additional plugins. Anyone building a real-world application will need to scour the internet for help with the other plugins available to do things like handle file uploads, user authentication, and the like. While this book doesn’t cover everything you could possible want to do, it covers a lot.

  • There is a very big emphasis on testing. It’s not TDD (see my note in the cons below), but in every chapter you will be shown how to build something, and then how to test what you built.

  • It’s current. The application is built in a RESTful style, and there is frequent mention of the changes/deprecations coming in the Rails 2.0 release.

Cons

There’s really very little wrong with this book. It appears to have been technical reviewed thoroughly, and as a result I didn’t find any glaring technical errors. That said, there are a few things about the book that I took some issue with:

  • The book frequently references blog posts as resources. This seems like a bad practice to me, as these urls tend to have a short lifespan. It’s very likely that many of these urls will be dead links within a year or so. To be fair, this is a book covering a rapidly moving technology, and it’s likely to be largely out of date in 18-24 months. Therefore, this may not be much of an issue. Still, it might be a better idea to link to the book’s website instead.

  • While the book does give ample coverage to testing (more than most books), it would have been nice if the testing was done Test First, rather than bolted on after the fact.

All in all, these are really minor points.

Conclusion

Overall, I really liked this book, and I believe it will be very useful to anyone developing with Ruby on Rails. Whether you’re on your first application or you’ve been developing for a while, you will find useful information in Rails Social Networking Sites.

Disclaimer: I received a free copy of this book from the publisher in exchange for a review. There were no conditions other than that, but in the interest of full disclosure, now you know.


Monday Question: What Technologies Are You Exploring?

Monday Questions is a recurring series on Approaching Normal. For more questions like this, please visit the archives

This is a follow up to last week’s question How do you decide what technologies to explore?
Today I want to know What technologies are you exploring?

I’ll go first. Aside from Ruby and Rails, Erlang and CouchDB are the things that I’m currently spending time looking into.

Post your answers in the comments below.


Rails Snippets - 11/13

RESTFul OpenID Authentication

A plugin to do OpenID authentication in Rails, in a RESTful way.

Off the Rails - An alternative Rails stack

Competition is good. Merb and the like provide that competition to Rails. This article runs through an alternative to the Rails stack. It’s always good to keep an eye on what else is out there.

Rands in Repose: The Nerd Handbook

Ok, this is a bonus link. Not at all Rails related, but relevent to you if you’re reading this. Rands nails the Nerd. I mean, really nails it.


Monday Question: How Do You Choose What Technologies to Explore?

Monday Questions is a recurring series on Approaching Normal. For more questions like this, please visit the archives

Technology moves at such a rapid pace that there is constantly something new that is tempting me to explore it. I find it very difficult to pick and choose which things to devote time to learning. So today’s question is: How do you choose what technologies to learn more about, and which to ignore?

Put your answers in the comments below.


I Bought a MacBook Pro

As a follow on to last week’s post, I ended up buying a 17" MacBook Pro this week. I went with a refurbished model (which saved me $400), and skipped the high resolution display. It should be here on Wednesday.

It’s my first Mac, and I’ve wanted one for ages, so I’m excited to get it.


Rails Snippets - 11/7

Troubleshooting Ruby Processes: Leveraging System Tools when the Usual Ruby Tricks Stop Working

A new book from O’Reilly on troubleshooting Ruby (and Rails) apps. From the overview:

This short cut introduces key system diagnostic tools to Ruby developers creating and deploying web applications. When programmers develop a Ruby application they commonly experience complex problems which require some understanding of the underlying operating system to be solved. Difficult to diagnose, these problems can make the difference between a project’s failure or success. This short cut demonstrates how to leverage system tools available on Mac OS X, Linux, Solaris, BSD or any other Unix flavor. You will learn how to leverage the raw power of tools such as lsof, strace or gdb to resolve problems that are difficult to diagnose with the standard Ruby development tools. You will also find concrete examples that illustrate how these tools solve real-life problems in Ruby development. This expertise will prove especially relevant during the deployment phase of your application. In this way, should your production Mongrel cluster freeze and stop serving HTTP requests, it will not take you 2 days to figure out why!

Sitepoint: Preparing for Rails 2.0

A nice, if a bit short, article on some of the changes that are coming in Rails 2.0. This is focused on what you will need to change in your application.

Creating a Ruby Weblog in 10 Minutes

This is a beginner tutorial, specific to using Netbeans 6.0. I’ve not played much with the Rails support in Netbeans, but it looks impressive so far.