LJ Archive

At the Forge

Book Roundup

Reuven M. Lerner

Issue #175, November 2008

Read a good book about Web development lately? Reuven has and is happy to share his latest favorites with you.

Remember the Web? You know, that combination of Internet technologies that will make paper obsolete? Well, it's true that many newspaper and magazine publishers are hurting, and that many people (including me) now read things on-line that we previously read on paper. And, for Web developers in particular, the Web provides a treasure trove of information, ranging from blogs and articles to forums and IRC channels.

Based on the flurry of content that is available on-line, and the reported death of print media, you might think that the number and quality of Web-related books also has declined in recent years. From what I can tell, however, the opposite is true. I continue to see a large number of high-quality books from a number of different publishers, on topics that are relevant and interesting. Even better, I have found many of these books to be useful in my day-to-day work, giving me perspective on technologies I already knew and teaching me many things that I hadn't previously known.

This month, I describe a few of the books that have most recently crossed my desk, which I have found to be the most helpful and interesting. This is an admittedly skewed sample. During the past few years, most of my work has been with Ruby on Rails, PostgreSQL and JavaScript, and also on looking at how to make Web sites more explicitly “social”, with a large number of interactions among the participants.

Ruby on Rails

I have been working with Ruby on Rails for several years now and continue to see it as a breath of fresh air. After years in which I had to work directly with a database, writing explicit SQL queries, it's a delight to be able to think about things at the object level, rather than at the row-and-column level. Admittedly, some performance issues exist with Rails, but when you want to create a Web application quickly and easily, nothing else comes close. (Actually, that's not exactly true. If I hadn't been smitten by Rails, I probably would be using Django today. And, there are several Rails-like application frameworks out there, including CakePHP and Catalyst, both of which have their fans.)

The now-classic, standard text for beginning Rails programmers is the second edition of Agile Web Development with Ruby on Rails, written by Dave Thomas and David Heinemeier Hansson, and published by the Pragmatic Programmers (ISBN 978-0977616633). This edition is due to be superseded by a third edition by the time you read this column, so some of my comments might not be relevant anymore. But, I generally have had mixed feelings about the first and second editions of this book. On the one hand, it successfully got me excited about Rails and provided me with a useful introduction back when I was first starting with it. At the same time, I kept searching for an introductory book with a slightly different style that I could recommend to beginning Rails developers.

One particularly strong introductory Rails book is Simply Rails 2, by Patrick Lenz (ISBN 978-0980455205). This book introduces a large number of key Rails features, including the MVC architecture, associations, testing, Ajax, some elements of Prototype and script.aculo.us, and even debugging with tools, such as ruby-debug. Because Lenz aims to cover less ground in his book, he manages to make a more effective tutorial than Agile Web Development with Ruby on Rails. Frequently interspersed code samples, screenshots and diagrams make this a particularly accessible book.

Once you have finished with Simply Rails 2, you will need a reference guide that describes the Rails architecture in greater depth, with a more comprehensive list of features. Obie Fernandez's book, The Rails Way (ISBN 978-0321445612), is an excellent, detailed and thick resource, although I think it mentions (and emphasizes) routes and RESTful architecture a bit early for many newcomers. That's probably fine, given that this book is not meant to be a tutorial, but rather a reference and advanced guide. So, although I strongly recommend this book and use it several times a week as a reference for my own work, it doesn't do the trick as an introduction or tutorial.

Good complements to The Rails Way, and to one another, are three similarly named books from two different publishers: Rails Cookbook, by Rob Orsini (ISBN 978-0596527310); Rails Recipes, by Chad Fowler (ISBN 978-0977616602); and Advanced Rails Recipes, by Mike Clark (ISBN 978-0978739225). Each of these books follows the now-standard format of having many short chapters, each addressing a common problem developers might encounter. Each of these books contains multiple recipes that have given me ideas, and even when I haven't used the recipe directly, I have found them to be useful food for thought. I'm also not sure whether the third book is truly as advanced as its title would indicate.

Finally, the book Deploying Rails Applications, by Ezra Zygmuntowicz, Bruce Tate and Clinton Begin (ISBN 978-0978739201), has a great deal of practical advice about taking a Rails application and making it available to the general public. The authors guide you through using version control (with Subversion), configuring one or more production servers, deploying with Capistrano and identifying bottlenecks. The book assumes you are using MySQL, which means people who use PostgreSQL (like me) can ignore some of the advice. There also is a chapter on Windows deployment that I expect most readers of this column can ignore.

The authors assume you want to deploy your application with a combination of Mongrel (for dynamic, Ruby-generated content) and nginx (for static content), while ignoring such possibilities as Phusion (aka mod_rails), an Apache module that some sites have been using with great success. Then again, Zygmuntowicz is the founder of Engine Yard, a Rails hosting company that has been enjoying great success, so it might be wise to follow his lead. Regardless of the specific implementation choices the authors suggest, this book helps put each aspect of Rails deployment into perspective, and it's good reading for people who plan to make their applications public.

JavaScript and CSS

It used to be that a Web developer could get away with working only on the server side, allowing designers to handle everything from JavaScript to CSS. But, as Web applications have become more dynamic and have incorporated more Ajax, it has become increasingly important for all developers to understand and master these technologies.

For all of the buzz around JavaScript, seasoned Web developers know that it is a flawed language, partly in its design and partly in its implementation. One of the best-known JavaScript gurus, Douglas Crockford, recently wrote a short (but excellent) book, JavaScript: The Good Parts (ISBN 978-0596517748). My understanding of JavaScript has been helped a great deal by Crockford's previous writing and lectures, and the book has helped me to appreciate this language more. JavaScript: The Good Parts has helped me understand why I have been so frustrated by JavaScript in the past—beyond issues of browser compatibility. By ignoring the bad parts of JavaScript, the frustration level drops considerably.

Even if you take Crockford's advice into consideration, you almost certainly will want to choose a JavaScript library, such as Prototype, jQuery, YUI or Dojo. I have explored some of these libraries in this column over the past few years, with a heavy emphasis on Prototype, because it is included with the Rails framework. However, there are many good things to say about the others—and in many cases, you might have no say over which library you use. For example, I have started to do some work with the open-source Moodle system for on-line learning, which uses YUI as its toolkit. Similarly, the Django framework for Web development now includes the Dojo toolkit, so you should expect to work with Dojo if you do any Django development.

Although I have been very impressed with Yahoo's YUI toolkit, my default JavaScript library remains Prototype, in no small part because of its close relationship with Ruby on Rails. (The Prototype developers are part of the Rails core team, and development between the two is synchronized.) The Web site for Prototype (prototypejs.org) has excellent documentation and even a downloadable PDF version of the API. But, this wasn't sufficient for some introductory classes that I recently gave about Prototype programming, so I have been on the lookout for a high-quality tutorial.

Thus, I was pleased to discover Practical Prototype and script.aculo.us, by Andrew Dupont (ISBN 978-1590599198), which is one of the best programming books I have read in the last few months. It introduces Prototype (and its companion GUI toolkit, script.aculo.us) with on-target, practical and illuminating examples—along with a sense of humor I found refreshing, without getting in the way.

Modern Web pages are styled with cascading stylesheets (CSS), a technology that is quite simple to understand in theory, but it can become complicated when it comes to execution. One book that seems to offer a gentle introduction to CSS is The CSS Anthology, by Rachel Andrew (ISBN 978-0975841983). This book is a cross between a tutorial and a cookbook, allowing you to learn CSS in the context of bite-sized lessons and ideas.

Once you have understood the basics of JavaScript and CSS, and what they can do for your dynamic Web sites, you might want to look at Dynamic HTML: The Definitive Reference, by Danny Goodman (ISBN 978-0596527402). This book looks at the DOM—the document object model browsers use to work with HTML—and explains how you can modify its appearance, as well as manipulate its elements, using a combination of JavaScript and CSS. This book doesn't use any JavaScript library, so some of the JavaScript code might seem long and unwieldy if you are used to the brevity of Prototype. But, for sheer comprehensiveness, nothing beats this book.

The similarly comprehensive latest edition of David Flanagan's JavaScript: The Definitive Guide (ISBN 978-0596101992) is useful when you want to better understand what JavaScript is doing or how an object is defined. Douglas Crockford has noted that this is the only JavaScript book that actually gets the details right. That might be true, but it doesn't change the fact that the text can be quite dense. Don't try to learn JavaScript from this book, but you should have it around afterward, either to refresh your memory or to gain a clearer understanding of how things work.

Finally, I have found The Ultimate CSS Reference, by Tommy Olsson and Paul O'Brien (ISBN 978-0-980285857), to be a useful list of CSS selectors, properties and values. Especially useful is the table indicating the degree to which each browser complies with the CSS standard for each property. The information in this book is available elsewhere, but it is particularly handy if I am not connected to the Internet (which, I'm ashamed to admit, is sometimes the case), or if I just want to skim through a number of related items. My main complaint with this book is its lack of an index, and although I realize you can read and search much of it on-line, adding 5–10 pages of index would have changed this from a good book into an excellent one.

Social Networking

Facebook, LinkedIn and other social-networking sites are all the rage, and I even have looked at some aspects of these sites in this column.

If you're interested in creating your own social-networking site, two books might be of interest to you. The first, RailsSpace, written by Michael Hartl and Aurelius Prochazka (ISBN 978-0321480798), describes how to create a simple social site with users, friends and Ajax-based blogs. The source code to RailsSpace has been made available, so you can use the code to build your own, real-world site, rather than merely go through the tutorials. Even better, one of the authors (Hartl) has founded an open-source project called Insoshi (www.insoshi.com), which offers a downloadable framework for creating social networking sites.

A second book on the subject, Practical Rails Social Networking Sites, by Alan Bradburne (ISBN 978-1590598412), is a bit more ambitious in the projects it aims to do, showing examples not only of users and friendship links, but also of e-mail, discussion forums, a photo gallery, user-created themes and a mobile interface. The code from this book is used to power the RailsCoders site (www.railscoders.net), and it similarly can be downloaded and used to power a real-world site.

No matter what toolkit you use, or whether you decide to create a social site on your own, you should consider the wider implications of what you are doing. Designing for the Social Web, by Joshua Porter (ISBN 978-0321534927), is one of the most interesting books I've read on the subject to date, and it's full of practical advice on how people participate in a site. A slightly less practical, but no less interesting book is Clay Shirky's Here Comes Everybody (ISBN 978-1594201530). His analysis of the social Web, and how groups are now collaborating before they fully know each other and define themselves, is full of interesting anecdotes, but also cautionary tales about what the designers of such sites should consider when deploying.

Conclusion

Perhaps the printing press is going the way of the dodo bird. But for the time being, there are plenty of books that I find not only useful and interesting, but also essential as I go about my daily life as a developer and consultant. If you have read a particularly interesting and useful book you think I should know about, please send me e-mail. I am always happy to learn about new, high-quality books, and if it turns out to be particularly useful, I'll be happy to share it with other readers of this column.

Reuven M. Lerner, a longtime Web/database developer and consultant, is a PhD candidate in learning sciences at Northwestern University, studying on-line learning communities. He recently returned (with his wife and three children) to their home in Modi'in, Israel, after four years in the Chicago area.

LJ Archive