By Antonio Cangiano, Software Engineer & Technical Evangelist at IBM
Currently Browsing: Reviews

In-Depth Book Review: Practical Clojure

Practical Clojure
Title: Practical Clojure
Authors: Luke VanderHart and Stuart Sierra
True pp.: 198
Publisher: Apress
Published on: June 2010
ISBN-13: 978-1430272311
Rating: 6.5/10



Published in June 2010, Practical Clojure by Luke VanderHart and Stuart Sierra is the latest Clojure book to hit stores. Despite the Clojure 1.0 jar shown at the beginning of the book, this title tries to cover the current version of the language, including references to concepts that will be introduced by the upcoming 1.2 version.

The target audience of this book is programmers who are absolutely new to Clojure. It didn’t strike me as being particularly aimed at developers who are coming from the Java camp, or the Lisp camp; in this regard, the book is rather “background agnostic”, even though Lisp programmers will feel much more at home than Java programmers will, due to the nature of the language itself.

The authors of the book are clearly well versed in this new language (Sierra is part of Clojure/core, the equivalent of the A-Team in Clojureland) and their confidence with the concepts presented is demonstrated throughout the book. Their explanations tend to be clear and to the point. Longer discussions are occasionally included when required to introduce concepts that are novel to most programmers, like the Software Transactional Memory (STM), refs, atoms and agents.

The book starts out by presenting a short but well-argued case for why Clojure is a worthwhile language, and then focuses almost exclusively on the core of the language. I’m afraid they do so to the detriment of the ecosystem surrounding Clojure. The authors don’t talk about how to install Clojure, recommend editors and IDEs (albeit a few are casually mentioned), or how to use build tools like Ant, Maven or Leiningen.

clojure.contrib, a fundamental extension library, is barely mentioned and there is no coverage of other important libraries or emerging frameworks. For instance, perhaps expectedly, Compojure (a web framework) and Incanter (a statistical and graphical environment) are only mentioned as examples of DSLs, however examples of their usage are not provided. (I believe the authors mistakenly refer to Compojure as Enclojure, which is a different project).

Despite the narrow focus, Practical Clojure doesn’t shy away from complex subjects and manages to include a chapter on Java interoperability, parallel programming, metaprogramming, and performance considerations. It does so briefly however, favoring a cursory presentation of the fundamental concepts rather than in-depth coverage, which would provide the reader with the degree of confidence required to approach real world problems.

The core language is covered in a manner that acts as both a tutorial and a reference. Major concepts, data structures, and common functions are presented to the reader with an endless supply of tiny examples. It’s easy to fly through them, but typing along in the REPL will be a far more valuable exercise for readers who hope to retain the information presented.

This leads us to another shortcoming of this book, which is the lack of more structured and complex examples. When I define their examples as “tiny”, with very few exceptions, I really mean it. For the first few chapters of the book the examples don’t get much larger than calculating the square root of a number through Newton’s method or adding contacts to an address book. Most of the other examples do a good job of illustrating the point they are trying to make with one, two, or just a handful of lines of code.

This is an actual sample of the kind of examples you’ll find throughout the book to illustrate many core API functions:

user=> (reduce + [1 2 3 4 5])
15

Note that this approach is didactically valid, because it isolates the function to show exactly how it works. After dozens of these functions though, you may expect larger examples to show how to integrate the use of some of these functions and data structures you’ve learned about. Such examples are seldom included. Furthermore, the book lacks any exercise for the reader. Foundational books that fail to offer many articulated examples and that lack exercises, tend to make it hard for the reader to retain the information and get some hands-on practice.

I have lots of respect for short books that get to the point and avoid wasting the reader’s time. K&R is notoriously acclaimed thanks to its clear and concise nature. However, Clojure is not C, and I feel that the 198 pages fall a little short when it comes to introducing this wonderful language to new readers. There is more to Clojure than simply surveying the language itself, even though I suspect that certain readers may appreciate this extremely narrow focus.

Overall the book is well-edited, despite the presence of minor issues. Aside from a few typos (e.g., “becauseall” on page 79), readers may find the formatting to be slightly inconsistent at times. For example in chapter 5 when presenting sequences, after the map function has been introduced, the font for the subsequent functions is substantially decreased for no apparent reason. Readers may be misled into thinking that the functions presented afterwards are somehow different from the previous ones, when in fact they’re all defined in clojure.core. In Listing 6-3, at page 103, the authors present their first “complex” example (the address book) and they do so by using, among others, doseq. This macro was not introduced before that page nor is it really explained within the example.

From a physical standpoint, this book is a rather thin and wide paperback. A small font, coupled with small margins and a wide layout, imply that the readability of the book suffers a little. The paper itself is off-white, fairly thick and slightly textured, not as pleasant to the touch as other books by Apress or most other technical publishers, even though I recognize that this is a matter of taste (some people may actually love it because of these characteristics).

With two introductory Clojure books on the market, drawing comparisons is unavoidable. Stuart Halloway’s Programming Clojure is a slightly older book (published in May 2009), which grants Practical Clojure a distinct advantage. This is not to say that Programming Clojure is obsolete, on the contrary it’s still a valid choice, but it doesn’t illustrate some of the new features that are available today. For example, in chapter 13 Practical Clojure introduces protocols and datatypes that will be available in Clojure 1.2 for the first time. Given that Halloway’s book was published more than a year ago, there was no possible way he could have included such powerful abstractions at the time.

Despite being older and less methodical than Practical Clojure, Programming Clojure tends to offer more complex examples. In the introduction of Programming Clojure you’ll see examples which Practical Clojure fails to include until much later in the book. Practical Clojure, the subject of this review, may leave you wanting for more practical examples of how all the language features fit together. Whereas Programming Clojure may leave you longing for more consistent explanations of how each part of the language works on its own.

Practical Clojure and Programming Clojure are competitors in the marketplace, but it wouldn’t be a bad idea to get ahold of both, because they complement each other quite well, in my opinion. Having to pick just one, I would probably recommend Practical Clojure, given its more consistent and up to date presentation. The sizzle offered by Programming Clojure, can be found to a much greater degree in upcoming and less introductory books, such as The Joy of Clojure. In this sense, reading Practical Clojure first followed by The Joy of Clojure, would be a solid learning path (Clojure in Action is another worthy addition, but it doesn’t replace The Joy of Clojure, which is a real gem).

In conclusion, Practical Clojure is not the Clojure equivalent of the highly praised Practical Common Lisp, from the same publisher. Reading it cover to cover and typing all the snippets included within, will not give you enough knowledge to start writing complex, idiomatic Clojure programs out of the gate.

However, if you are learning Clojure today, I do recommend this book. It’s a clear, well thought-out, concise introduction to the language that will give you a solid foundation as you go on to learn more about Clojure and Lisp in general.


Ten recent programming books that will make you a better developer

Programming is the type of discipline that requires countless hours of dedication to reading and writing code, rather than purely theoretical learning from books. Yet programming books can be enlightening and provide guidance while one attempts to hone their craft in the pursuit of mastery.

In this post I’ll share a (necessarily incomplete) list of relatively new books that I believe will make most developers better programmers. By “new”, I mean books that have been released recently (within the past three years), that haven’t become classics yet or appeared in everyone else’s list of recommended programming books. Hence, you won’t find SICP, TAoCP, PFDS, etc.

Please note that each of them deserves (and probably will receive at some time) a lengthy review. Here I simply state in a brief manner why I think they are important.

1. Introduction to Algorithms, Third Edition

Introduction to Algorithms ImageOK, this is cheating a little. “Introduction to Algorithms” is both a classic and a book on everyone’s list. However, I opted to include it because not everyone knows that it was recently (September 2009) released in its third edition. The book received a major upgrade to the existing content and exercises, as well as including new, modern algorithms. Any programmer working through this book, or revisiting it, will learn valuable, foundational knowledge.

2. The Annotated Turing

The Annotated Turing ImageAlan Turing wrote a classic paper in 1936 with the title: “On Computable Numbers, with an Application to the Entscheidungsproblem“. It was a paper on Turing machines and the limits of computability, which had a major impact on computer science and the development of the computer you are reading this post on. Every programmer/computer scientist should get ahold of this paper and read it. Unfortunately, it isn’t exactly easy to grasp if you are not used to reading research papers. In “The Annotated Turing”, Petzold does a marvelous job of dissecting the paper (and its errata), providing ample explanations and background information over 18 chapters (360 pages vs 36 of the original paper). It manages to be rigorous while still being accessible. If this book doesn’t arouse your interest in computer science, chances are nothing will.

3. Growing Object-Oriented Software, Guided by Tests

Growing OO Software ImageThis book takes two fundamental pillars of modern software development, Object-Oriented Design and Test-Driven Development, and clearly illustrates how to apply the best practices of each to build and maintain complex software. I don’t know of many developers who couldn’t learn something new about TDD in the context of OOP from this book. A must read.

4. Clean Code

Clean Code ImageWhile on the subject of Agile development, I can’t help but recommend “Clean Code” by Uncle Bob. It compliments “Growing Object-Oriented Software, Guided by Tests” perfectly by focusing on how to improve and refractor code to get rid of code smells. You can think of it as a very succinct version of Code Complete 2, with a strong focus on Agile craftsmanship. The examples, as per the previous book, are in Java but that shouldn’t be much of an issue for the open-minded developer.

5. Leading Lean Software Development: Results Are not the Point

Leading Lean Software Development ImageLean principles deriving from the Lean manufacturing world have been effectively translated and adapted to the field of software development. This book explains how to lead a team to success through lean software development in detail to team leaders and mentors. Having obtained a Lean Six Sigma yellow belt many years ago, this book definitely gave me a few flashbacks. If you are not familiar with the concepts presented, you’ll definitely find it food for thought. Building software requires far more than just writing quality code, and the techniques presented here are valuable, even if you don’t fully buy into this methodology.

6. Growing Software

Growing Software ImageWhile on the subject of leadership, if you are in charge of software development at a small company or startup, you want to read this book. My interest in this title came from the fact that its author (Louis Testa) works as a Senior Engineering Manager at Galois, a company that uses Haskell as their technological advantage (and hired Don Stewart of Haskell fame). “Growing Software” delivered on my expectations and is full of hands-on advice on how to deal with the whole workflow surrounding the creation of software from the idea all the way to the sale and support of a product.

7. The Art of Debugging with GDB, DDD, and Eclipse

The Art of Debugging ImageDebugging is an invaluable skill and one that is often left out from introductory programming books. Being able to effectively debug code is what separate professionals from beginners, and productive programmers from frustrated ones. This book is ruthlessly practical with many advanced techniques for debugging on Linux/Unix. It’s well worth its price in my opinion.

8. Applied Mathematics for Database Professionals

Applied Mathematics for Database Professionals ImageAssuming you already have a decent understanding of relational databases, and are not too scared of mathematics, this book will really bring your knowledge of how databases work to the next level, in turn improving the design, schema evolution, and SQL queries you’ll create afterwards.

9. Programming Collective Intelligence

Programming Collective Intelligence ImageIf you are building web applications that do more than simply CRUD operations on your data, you’ll want to read this book (with examples in Python). The motivated, intermediate developer will learn how to efficiently solve complex problems related to machine learning and intelligent web algorithms from this book. It’s a very accessible introduction to tough subjects and one of the most interesting books I’ve read in some time.

10. Coders at work

Coders at work ImageTo conclude this list, I wanted to include a book that’s aimed at showing programmers how some of the best programmers and computer scientists do their work. I previously enjoyed Founders at Work, and this version about programming is just as good. It’s inspiring, fun to read, and rich in insight and advice.


Upgrading to Rails 3

Rails 3 is a major upgrade; using it almost feels like working with an entirely new framework. Porting existing applications and acquiring the skills required to build new ones entails a significant amount of effort. You could scout the net for bits and pieces of information, but that would be time consuming and possibly frustrating. Thankfully there are resources available that have done the work for you, so you don’t have to waste time trying to figure out what’s new.

In this post, I’d like to point out a couple of resources that I think compliment each other well, and focus on how to upgrade applications, as opposed to simply providing you with a shopping list of features.

The first one is Upgrading applications to Rails 3, a screencast that was just released by ThinkCode.TV. This screencast is almost an hour-long and shows you how to port a real world web application from Rails 2 to Rails 3. As such, it can be very useful if you have existing code that you’d like to port over to Rails 3. The author ported a few large applications to Rails 3, as he has solid experience with it. I’m biased of course, but I feel it’s well worth $8.99. (Today only, use the coupon RAILS3 to purchase this Rails screencast for just $5.99.)

rails3.png

The second resource is the Rails 3 Upgrade Handbook by Jeremy McAnally. It’s a beautiful PDF that succinctly explains what’s new in Rails 3, as well as how to upgrade your applications to the new edition of the framework. At 10c per page ($12 for 120 pages), it too is worth the money in my opinion.

rails3uh.png

Regardless of whether you end up buying these resources or not, I sure hope you have extensive test coverage for your existing Rails 2 applications. In my experience this is a must, because porting complex applications to Rails 3 without solid test support is a definite challenge. Nevertheless, I feel that this major upgrade is truly worth it. Rails 3 really brings Rails to a whole new level and we, as a community, should be proud and excited about what lies ahead of us.


Recommended Ruby and Rails books (August 2009)

I finally got around to updating the Ruby and Rails book pages. The existing list was getting a bit obsolete and I didn’t like the idea of recommending old books to newcomers. I also had some interesting new entries.

Without further ado:

A few people may disagree with the choices, but I think most experienced Ruby and Rails programmers, who’ve read those books, will concur with my recommendations. I’m quite confident that these are, all things considered, some of the best books available on the subject.

A word to the publishers

As tempting as it is to collect Ruby and Rails books, these days I don’t feel I can economically justify the act of purchasing every Ruby or Rails book put out there. So if you are a publisher or an author, and you’d like for me to consider your book, you are certainly welcome to send me a review copy. I will definitely read it, but only include it on these lists if it’s either outstanding or as good as the existing ones. If it’s a programming book that’s not related to Ruby/Rails, yet is really good, I would consider reviewing it on my blog.


Do programmers still buy printed books?

Yesterday I published a post titled My latest order of programming books, which received a fair number of comments both here and elsewhere online.

Aside from a few good suggestions for other must-read books for programmers, there were several comments about how buying hard copies of books in this day and age is stupid. A few advocated piracy as an alternative to buying books, printed or not. Aren’t we supposed to be a group of professionals? Do we really believe that pirating books is the right answer to our profession’s need for knowledge?

The most sensible recommendations concerned the use of legally free, available material online, as well as suggestions that the $250 could be spent on services like Safari Books Online.

I love Safari Books Online. I used to have an extended trial account for a few months, and utilized it constantly. I have access to Books24×7, an alternative, less extensive service as well.

Safari Books is ideal when used as a reference. You have access to thousands of books from major publishers, so virtually any search will lead you to a few relevant volumes dealing with the subject you’re looking for. It’s also great for keeping up to date with technology, thanks to “Rough Cuts” which are books that haven’t been completed yet.

It’s an extremely valuable service and I would recommend it to anyone in a heart beat. However, there a few reasons why I still buy hard copies.

I spend long hours working and staring at the computer screen. A printed book is a chance to take a break at night, and let my eyes rest a little. I find it refreshing. And let’s face it, for extensive reading, paper is much easier to read from than the screen.

Likewise, when I’m holding a book or have it open on my desk, I’m in “book reading mode”, which makes it far easier to immerse myself in it. This means that I’m focused on the task and can proceed quickly. The only context switch that happens is between the book and the editor/shell, if it’s the kind of book that warrants typing along. If you are reading a book in a browser tab, it’s very easy to think, “I’ll just check my email for a second”, or introduce similar distractions. I’m sure I’m not alone in this respect.

When I buy a physical copy of a book, I feel psychologically more obliged to at least try to get through it. Online I experience a paradox of choice of sort. With hundreds of interesting books available there in front of me, I’m more inclined to excessively multitask, and end up checking out different books while I should still be reading the current one.

And let’s not forget that not all books are legally available online. I’ve found that many advanced computer science books are not yet available on Safari Books or Books24×7. For example, The Art of Computer Programming, Purely Functional Data Structures, Types and Programming Languages, Programming Pearls, and other worthy suggestions that were made in response to my first post, are all not available on Safari Books. As well, mathematical books that can be of use to the serious/discerning programmer are also not included (understandably).

Lastly, and I realize that this is a “vanity point” and perhaps the most irrational one on this list, I like to have a beautiful collection of books on my bookshelves. If I’m going to spend $xxx a year on books, I’d prefer to have something to show for, beside my newly acquired knowledge.

However, the sheer volume of free available content has slowed down the number of books I’ve purchased in the past few years. And I’m thinking about re-joining Safari Books Online nevertheless, as I see it as being complementary to printed books. The Safari Library option is somewhat expensive ($42.99 per month), but for the price of an extra printed book per month, I gain full access to a huge catalog of programming books and a growing list of “Rough Cuts”.

With the amount of free knowledge available, useful paid services, research papers, and relatively good deals on printed copies from Amazon, the real constraint remains time not money. But claiming that purchasing hard copies is obsolete or worse, stupid, is… well, asinine, in my opinion.

What’s your take? Do you think Safari Books Online is worth it? Do you still buy printed copies of your professional books? Do you even read programming books at all these days?


My latest order of programming books

A few days ago it was my birthday. This year I decided to reward my aging self with some books I’d had my eyes on. My budget was roughly $250, nothing to snicker at, but programming and computer science books aren’t exactly famous for being inexpensive.

The hardest part was shortlisting only a few titles, out of a substantial number of books that interest me. This ruthless streamlining was not solely motivated by cost either. Time is by far the most non-negotiable constraint, and as pretty as certain books may look on my shelves, I’d rather get titles that I know I will reference often or read cover to cover.

Last night I finally placed my order on Amazon. Narrowing down my choices wasn’t easy, but I think I was able to get a lot of bang for my buck, so to speak. I’m sharing the list of books I ordered, and my rationale behind selecting them, in the hope that some readers will find this information useful. You’ll probably find one book at least that tickles your fancy.


1) Code: The Hidden Language of Computer Hardware and Software
by Charles Petzold

Very high-level languages have major advantages, but they tend to conceal many details. As a result these low-level details are often forgotten, overlooked or no longer taught. I’m talking about gates, bit manipulation, etcetera. Ten years have passed since I last sat in a computer architecture class or programmed in the MIPS assembly language, so I see this book as a refresher about this sort of interesting details that lay between hardware and software.


2) Programming: Principles and Practice Using C++
by Bjarne Stroustrup

I’ve been meaning to get more serious about learning C++ for a while now. The fact that I chose this book may seem odd. After all, it’s a C++ book for CS 101. I’m fully aware that I won’t find many new concepts in it and that the pace will probably be very slow to me at time, as it’s aimed towards newcomers. I opted for this book, among other reasons, because it’s very recent and was written by Bjarne Stroustrup (C++’s creator) himself. It’s a modern overview of C++ today and should cover all the essentials of writing portable code with a slant towards real world work, including parts of the STL. I’m interested in revisiting well known concepts from the perspective of C++, and this title should work as a good introduction before I switch to The C++ Programming Language, Effective C++, More Effective C++, Exceptional C++, and other advanced books. Lastly, I chose it because a good friend suggested it to me.


3) Processing: A Programming Handbook for Visual Designers and Artists
by Casey Reas

Processing is another language I’m interested in. The idea of creating fancy visualizations of data is very appealing to my statistical side. This is probably another “basic” book, but I wanted to have a detailed tutorial on the subject. It’s also a very beautiful book. (Remember that deep down we are all hedonists.)


4) Clean Code: A Handbook of Agile Software Craftsmanship
by Robert C. Martin

I love “Uncle Bob”‘s writing style and this book is, according to many, a wonderful addition to any software engineer’s collection. Apparently it’s Code Complete meets Refactoring meets Test Driven Development: By Example, all wrapped up in a single book. As much as that’s possible, naturally.


5) The Little Schemer (4th Edition)
by Daniel P. Friedman

This is the first little volume in the “The * Schemer” trilogy. I’ve heard great things about this unusual Q&A book that straddles the border of functional and logic programming. I’m not new to functional programming, but I’m certain that this book will be an eye-opener nevertheless. There should be plenty of fun exercises inside. If I enjoy it as much as I hope, I’ll also get The Seasoned Schemer and The Reasoned Schemer, down the line to bring my understanding to the next level.


6) Introduction to Algorithms, Third Edition
by Thomas H. Cormen

I own the second edition of this book, but guess what? They just released a revised edition with updated content, new algorithms and it’s been expanded to take the world of multiple processors into account. If you are not familiar with this classic, don’t let the title mislead you, this is no “introduction”. It’s an excellent, rigorous tutorial and reference that every programmer should own.


7) Elements of Programming
by by Alexander Stepanov

The toughest book of the lot. This newly released theory of computation book has incredible reviews. It should be a rigorous handbook of the mathematical foundations of programming. And at this price it’s a bargain, in my opinion. The examples are in C++, so I’ll quote part of the review by Bjarne Stroustrup.

“Elements” is a great book in that it can change the way you think about programming in fundamental ways: If you “get it” programming will never be the same again for you.

Reading “Elements” requires maturity both with mathematics and with software development. Even then it is so different from most books on programming that it can be hard going. The frequent comparisons of “Elements” to Knuth’s “The Art of Programming” is well earned.
— Bjarne Stroustrup

What are your thoughts on this list? I think I could have done a lot worse with my modest $250 budget. And as you can imagine, I’m pretty excited about their arrival and am looking forward to diving into them.

On a side note, this reminds me that I should start writing detailed reviews for the most interesting books I’ve read over the past few years, not just for Ruby books (recently updated) and Rails ones (to be updated soon).

Disclaimer: The links to Amazon have my referral. It’s a small contribution to this blog that won’t cost you a dime. If you are opposed to me making a few cents from my posts, feel free to select, copy and then paste the title that interests you into Google.


Ruby 1.9 screencasts plus an announcement

Previously I mentioned the importance of migrating away from Ruby 1.8, in favor of 1.9. Before my business trip to Italy, I had a chance to watch David A. Black’s new videos for Envycast, in which he presents the essential concepts required to migrate from Ruby 1.8 to 1.9. This pair of videos totals roughly an hour and a quarter, and can be purchased in a package deal for $16. You probably won’t find them to be as entertaining as the ones filled with gags by Gregg Pollack and Jason Seifer, but in my opinion these videos are well thought out and highly informative. The price is fair if you consider that they can bring you up to speed with Ruby 1.9 in no time at all and with very little effort on your part.

ThinkCode.TV: Video di programmazioneSpeaking of screencasts, in Italy I had a chance to pre-announce my “startup on the side”. It’s called ThinkCode.TV and will, you guessed it, create and sell high quality screencasts about programming. ThinkCode.TV was founded with a couple of friends of mine who are top notch programmers and teachers respectively in the Python and the XP/Agile world. Initially we’ll focus on the Italian market (the three of us are Italian) by producing screencasts in Italian about Ruby, Python and TDD. But we plan to expand our horizons, by covering more subjects, accepting external authors, and eventually expanding to the international market by migrating our best sellers to English versions, narrated by native English speakers (to save you the hassle of having to hear a foreign accent).

Should things go well, we may expand beyond the Italian and English markets. But for the time being, I invite Italian speakers to join our newsletter (which is in Italian) to learn about the development of this project and be advised of when we release the first videos. When we branch out to the English speaking world, my readers who don’t speak Italian, will be able to learn about it through this blog.


New look and feel. Do you like it?

Those who follow this blog through the feed, may not have noticed it, but over the weekend I had a chance to revamp the look of Zen and the Art of Programming. I used a WordPress theme I’d already employed on Math Blog and customized it, basing my changes on the suggestions of the participants of my earlier survey on the subject. I’m not a web designer by any means, but I’m quite happy with the way it looks and the overall clean feel this new layout lends the site. What do you think about it?

While at it, I also updated my About page and added a thumbnail of the cover of my book to the sidebar. I finished writing Ruby on Rails for Microsoft Developers a couple of months ago and am now waiting for Wrox to do their magic and get it into stores. The book should leave Wrox’s warehouse towards the end of this month and reach customers in early April. But I’ll talk about my book and the subject of writing a technical book more in future posts.


Scaling Rails Screencasts

Scaling RailsWithin the Rails community, New Relic is a company that doesn’t need any introductions. They are synonymous with performance and reliability, thanks to their RPM product for monitoring, detecting, and fixing Rails application performance problems in real time.

What everybody may not have noticed though, is that New Relic started something called RailsLab, a site in which they publish videos and other useful information about scaling and improving the performance of Rails applications.

The first series, known as Scaling Rails, produced in collaboration with my friend Gregg Pollack, is absolutely impressive. The following is a list of the videos they’ve posted so far (they’re also available through iTunes):

  1. Introduction
  2. Page Responsiveness
  3. Page Caching
  4. Chache Expiration
  5. New Relic RPM
  6. Advanced Page Caching
  7. Action Caching
  8. Fragment Caching
  9. Memcahed
  10. Taylor Weibley & Databases
  11. Client-side Caching
  12. Additional HTTP Caching

I was surprised to see so little mention of these fantastic short tutorials in the blogosphere. These videos are a gold mine of information, which is made all the more better by the fact that they’re entirely free. Do yourself a favor and check out these awesome clips, they’re well worth your time.


Sony Vaio FW Series: A Developer’s Review

For the past three months or so I haven’t had a computer of my own. This is not as bad as it sounds, because I’ve had work hardware, but such computers are intended to be used for work purposes only. Now that DB2 on Mac has been released, I’m waiting on the new 17″ MacBook Pro, which will be added to the setup as well, but again, that’s a work machine and it won’t arrive for at least a month due to delays on Apple’s side. Long story short, I grew tired of being without a personal laptop after my own MacBook Pro died numerous weeks ago, so I decided to take the plunge and purchase a moderately priced replacement. What follows is a review of the laptop I ended up purchasing as my day-to-day personal model, after a lot of careful consideration, and a list of features I required (in order of priority).

My requirements

  • My main operating system needs to be Ubuntu, so most components should work with Linux.
  • A relatively fast machine for development. It should be able to handle Aptana Studio, NetBeans and even Visual Studio occasionally (without breaking a sweat).
  • An entertainment laptop. I want to be able to watch hi-definition movies from the comfort of my bed at night. To do this a large, wide screen, high resolution, and a Blue-Ray reader were paramount.
  • It needed to be able to facilitate backups for several gigabytes of data, which means it needed to have a combo drive that’s able to burn DVDs.
  • Sturdy overall construction.
  • Look sleek and be relatively ergonomic.
  • It had to be affordable (my budget was roughly $1500/1600 CND).

My choice

Believe it or not, there weren’t too many available choices that were able to satisfy my requirements and my budget. For a while I had a crush on the Dell XPS 16, but unfortunately the Full HD option and the Blue-Ray/DVD Burner combo jacked the cost up several hundred dollars over my budget. This model is also well known for its tendency to become extremely hot (e.g., 115° F) while on your lap, and after the problems with heat that my old MacBook Pro had, I decided that this model was definitely a no-go.

After researching numerous models, I finally came across the perfect match: the Sony Vaio VGN-FW285D/H for $1600 CND (listed price $1650 CND). The exact model names and configurations change from country to country, and even in Canada, several lower end models exist (and there’s also a “configure to order” option which ends up being slightly more expensive spec-by-spec).

Sony Vaio FW285D/H

The titanium gray model I purchased has the following specifications:

  • Intel Core 2 Duo Processor P8400, 2.26GHz FSB 1066MHz, 3MB L2 Cache
  • 4GB RAM PC2-6400 (2GBx2) (Max 4GB)
  • 320GB SATA disk (7200RPM)
  • ATI Mobility Radeon HD 3650 with 512MB dedicated VRAM (incorrectly listed as 256MB on the Canadian site)
  • 16.4″ Screen, XBRITE-Full HD (1920 x 1080), HDMI and VGA out with Smart Display Sensor
  • Blue-Ray Burner (Burns CDs, DVDs, and BDs, including dual layer)
  • Intel WiFi Link 5100AGN (802.11a/b/g/n)
  • Windows Vista Home Premium 64bit SP1

And of course it comes with the usual yadda-yadda: 1.3MPix Motion Eye camera, Dolby Sound (pretty good), a bunch of media cards readers, 3 USB 2.0 ports, a Firewire port (IEEE 1394), Gigabit Ethernet, modem, Bluetooth, etcetera. If you are purchasing this laptop in the States, you can get the same model on Amazon.com for only $1295.

What I like about this computer

There are many things that appeal to me about this laptop:

  • Performance: Talk about a fast laptop! Faster than my previous MacBook Pro. There are speedier processors on the market, but the P8400 is plenty quick as far as I can tell. This Vaio is also very snappy thanks to its large 7200rpm hard drive – something that I really appreciate as a developer and photography enthusiast. Despite Vista being Vista, it’s a very fast computer which boots up in a few seconds and can run heavy IDEs no questions asked. On Ubuntu (more on this later) it’s extremely fast. Finally, not being a heavy gamer, I find the ATI HD 3650 with 512MB VRAM more than adequate for everything I need to do.
  • Full HD Screen: I find the screen on this laptop to be spectacular. Colors are crisp and vivid, with excellent antiglare control. The view angle is remarkable too, you could easily seat four people around the laptop and they would all see a nice, crisp picture. It’s ideal for presentations and demos when a projector isn’t on hand. The 16:9 aspect ratio is amazing for watching movies, and very useful when trying to have more than one window open on the screen simultaneously. My wife and I watched a blue-ray movie on it and were both blown away by how awesome the whole full-hd experience (on this laptop) was. As I switched from the notebook to a desktop that’s hooked up to a Samsung SyncMaster 275t, the external monitor felt dull all of a sudden.
  • Blue-Ray burner: This is overkill – good overkill, that is. I would have been happy with a Blue-Ray reader and a DVD writer, but the presence of a Blue-Ray recorder really makes this laptop shine. Yes, blank Blue-Ray media is still expensive, but prices are coming down, and the ability to backup 25 or 50GB on a single disk is an extremely welcome bonus.
  • Cool and quiet: Despite the size and processing power, this laptop is definitely on the quiet side and I must say that even under stress, it remains relatively cool. The heat exhaust is on the left side, so you can safely place the laptop on your lap or on a table, without experiencing a huge deal of heat or having it shut down like some laptops are prone to doing.
  • Construction and Ergonomics: I find the notebook to be very well constructed. It’s sturdy and feels very solid, though it doesn’t feel quite as solid as a unibody MacBook Pro. I believe the lid chassis is made of metal, while the rest is constructed from durable plastic. The area where your wrists rest is made of plastic but almost feels like aluminium. There is also a slight slope between the touchpad and keyboard that makes typing very comfortable. Overall, despite the large screen, this laptop is not cumbersome, and it definitely packs a sleek, modern design which is likely to appeal to many. It sits comfortably on my laps and isn’t particularly heavy either. Sure, it’s not an ultra-portable sized computer, but considering its 16.4″ screen, I think it’s still fairly easy to tote around. The keyboard is Mac-like, even though to be fair, this style of keyboard (wherein the keys are neatly separated from each other) was first adopted by Sony and later implemented by Apple. The touchpad is nice too with very smooth scrolling (always a plus).
  • Reliable wi-fi: So far the wi-fi connection seems to be working very reliably. It has been connected with full signal since the first moment I provided credentials to my wireless network, and the speed appears to be great. Other laptops I’ve tried in my house have been far less reliable.
  • Compatible with Linux: More on this topic below.
  • HDMI Output: Having a single HDMI output (for both audio and video) made connecting the laptop to my HDTV a breeze.
  • Free Blue-Ray movies: In Canada the laptop came with three Blue-Ray movies. This isn’t a big selling point, but it’s a nice bonus. In my case, I received Casino Royale, Hitch, and Surf’s Up.

Sony Vaio FW285D/H

What I dislike about this laptop

It is hard to find negative things to say about the FW285D/H, especially if you consider the wealth of features and its affordable price tag. But I’m going to nitpick a bit, so as to make the review more informative:

  • The high resolution implies that fonts tend to be on the smaller side of things. This, depending on the user, can be a pro or a con, but be aware of it beforehand if you tend to like your font size on the hefty side.
  • On Windows the current drivers seem to only offer the spectacular 1920×1080 resolution and two other very low resolutions. I don’t see intermediary resolutions like 1366Ă—768, which would make the font larger for whenever you don’t need that extra bit of space on the screen. Update: I have blogged about a solution for this here.
  • A fair number of Sony software/utilities are preinstalled on the system. There is also a trial version of Microsoft Office and Windows Live OneCare, which I uninstalled and replaced with the home version of Avast instead.
  • Media for Windows Vista (or a recovery DVD) is not provided. The user is expected to burn their own recovery DVDs (3 regular DVDs or 2 double layers) through a Sony utility. These are copied from an EISA hidden partition (10.2GB) which can be deleted afterwards. To delete the partition you will need diskpart, as explained here.
  • The Canadian version came with a keyboard that has both English and French labels. The bi-lingual layout is slightly different than a regular US keyboard, so it takes a little while to get your mind used to having keys like this if you want touch type at full speed. Of course, if you are a French Canadian (or anyone else who types French), you’ll enjoy the bilingual nature of the keyboard. If you purchase the laptop from the States, you won’t encounter the dual language keyboard, of course.
  • Sony disables Intel VT support on most Vaios (I think it’s unbelievably stupid of them). This means that if you were to use a virtualization program like vmware, you’d obtain a 20/30% slower VM. This is not a huge deal for me (I run my VMs on a Quad-Core desktop) but it’s definitely something that has the potential to be annoying and which seems to be in place for no good reason (and, lastly, may or not be a deal breaker for you). I believe it can be enabled by patching a BIOS ROM dump, but it’s the kind of tinkering I’m not personally eager to do on the first day after my laptop purchase, especially since this point doesn’t really affect me. Should I develop an actual need for this, I will look into it and report my findings in this blog.

Sony Vaio FW285D/H vs MacBook Pro

Linux compatibility

On my laptop I have Vista and Ubuntu in dual boot. Ubuntu compatibility was very important to me because I intend to use Ubuntu as my main OS (particularly for development) and only use Vista when needed – or for entertainment purposes (e.g., playing Blue-Ray movies). The great news is that everything worked out of the box with Ubuntu 8.10 x64. And I mean everything that I could possibly test. Video, audio, wireless connection, bluetooth, hibernating, putting the laptop to sleep, you name it. Everything worked out of the box, which speaks volumes for both the compatibility of the Sony Vaio FW Series and the progress level of Ubuntu as a desktop operating system.

If you buy this laptop, and plan to dual boot Ubuntu, you can save yourself a lot of headaches by paritioning your hard drive during the Ubuntu installation, from a live CD. You could use the hidden partition that you deleted as a swap partition, reduce the size of the Windows boot partition, and with all the free space left over create a partition for Ubuntu or add an extra Windows partition and an Ubuntu one. For example, I have a 60GB Windows Vista partition, a 190GB “media” NTFS partition which is accessed by both Windows and Linux, and then about 45GB allocated for Ubuntu. The first partition on the disk, which replaces the unallocated space created by deleting the EISA hidden partition, is a swap partition. Yes, with 4GB of RAM, I didn’t need such a big swap partition, but I had the free space all in one place and decided to go for it.

A word of caution for dual booters who are planning on having the Windows Vista partition as their second partition. You need to edit your menu.lst to change the Vista section from root (hd0, 0) to root (hd0, 1). This correctly indicates where to find Vista when you select Windows from GRUB at boot time. If you don’t go through this step, you may face an Error 12: Invalid Disk Requested or similar messages.

Conclusion

The final verdict is more than positive. This is a very solid laptop with amazing features, for a reasonable price. Unless your budget is significantly larger than mine or your requirements wildly different, I think that the Sony Vaio FW Series won’t leave you disappointed. In particular, if you are looking for a development and entertainment laptop that will work with Ubuntu Linux, without any hassle, then this could be the answer for you, provided that the lack of virtualization is not a major issue (or you are willing to figure out how to enable it).

If you own this computer or end up buying it as well, definitely feel free to share your thoughts on it in the comment section.


Learn Merb

Merb's logoThe most effective martial artists specialize in their discipline, but are not afraid to cross-train in others. Bruce Lee—arguably the most famous and influential martial artist of the past century—trained first in Tai Chi Chuan, then Gung Fu, and boxing, as well as learning western fencing. The insight taken from so many disciplines led him to create the Jeet Kune Do form of combat.

Programmers are not all that different. Cross-training in other languages and frameworks can only improve one’s overall mastery of the craft. When it comes to Ruby frameworks, the two most popular choices are Ruby on Rails and Merb. They’re often seen as being contenders, but this truly isn’t a zero-sum game; learning both is a very sensible move. They both enable you to write web applications in Ruby, and are somewhat similar, so learning one after you know the other shouldn’t be very challenging. In the many cases people learn Merb after they’ve had some experience with Rails, but either way, acquiring a solid grasp of both frameworks provides developers with extra flexibility. Often people who learn both, will end up mostly just using one or another, depending on their individual preferences. But it’s worth knowing them so as to be able to write both CRUD-style applications that fall within Rails’ solution space, and more complex, edge cases where Rails’ opinions will end up contending with yours.

Among the reasons to give Merb a chance, is its focus on performance, a smaller memory footprint and an extreme level of modularity, which enables you to pick and choose which components you’d like to use.

Merb is not as mature as Rails, of course, but it has reached version 1.0.x and with it developers can have greater confidence in a more stabilized API. Now is perhaps the best moment to get involved and learn more about this rising framework. Not surprisingly though, Merb finds itself in a similar spot to the one that Rails was in a couple of years ago (in terms of weakness of documentation when it comes to getting started). Thankfully, this point is being taken seriously and there’s been some major progress in terms of improving the documentation for Merb. Below are some useful links to get you started with Merb.

Merb has an official API documentation, a wiki, a google group, and a community site called Merbunity for news, projects and tutorials. The irc.freenode.net #merb channel is also a useful and welcoming spot. Furthermore, there is a Peepcode PDF draft called Meet Merb. If you want something even more substantial, on the book front there are several titles coming out in the near future. These include Merb in Action, The Merb Way, Beginning Merb and Merb: What You Need To Know. There is also an open source Merb book, whose development is led by Matt Aimonetti. It’s a work in progress, but probably a very good starting point, which just happens to have the added bonus of being free. And if your interested in Merb, don’t miss InfoQ’s interview with Yehuda Katz, who’s Merb’s lead developer and one of the sharpest guys we have in the Ruby community.

Finally, if you are a professional developer who wants to quickly progress with Merb and bring their skills to the next level, do not miss your chance to attend a three day intensive course on Merb, which is being offered by Yehuda and Matt in Phoenix, AZ between January 19 and 21 (2009). Registration has been open for two days already and 20 out of the 30 available spots have already been snapped up. The remaining seats won’t last more than a day or two, so if you are interested, don’t delay (sign up now and you’ll also benefit from an early registration price).

2009 is almost here, so why not take the opportunity to learn Merb this year?


IBM’s XML Challenge (lots of prizes inside)

The XML ChallengeIBM is holding a series of challenges centered around XML. The whole event is labeled The XML Challenge (subtitle: Search for the XML superstar). Rockstar references aside, this is a pretty cool initiative that can provide you with some freebies as well as high quality prizes if you win any of the available contests.

The Contests

What I say below applies to US and Canada, as the contest is being held worldwide in 30 countries separately, and each of these may have different individual contests and prizes as well. In fact, the first thing you’ll see when you visit the xmlchallenge.com site should be a popup that prompts you to select your country.

For US/Canada there are 5 contests: Video, Gadget, Query, Porting and XML. The Video Contest consists of creating a funny/creative/cool video about XML, XQuery and/or DB2. The Gadget Contest is about developing a downloadable gadget/widget that leverages DB2. The Query Contest requires you to use XQuery to query a database and come up with the answer to five questions. The Ported Application Contest is all about porting an existing application to DB2 or creating a new one that uses DB2. And finally, the XML Contest asks you to build a useful, user-friendly XML application from scratch. The last two contests can be approached as a team or as an individual. The Query, Ported App and XML contests start today!

You don’t have to participate in all of them, of course. But by participating in any of these you gain points, and there are six badges that you can obtain: XML Challenger, XML Rookie, XML Whiz, XML Star, XML Master and XML Grand Master. I feel so nerdy reporting this. The XML Grand Masters will be enrolled in a draw for an additional prize.

The Prizes

Speaking of prizes, let’s see what goodies are up for grab. There will be a few give-aways just for participating. For example, the first 500 participants will receive an XML Challenge T-Shirt as well as a Rubick’s Cube. The first 1000 to complete the Quick Quiz during registration will also receive a free T-Shirt. But let’s move on to the more substantial prizes.

For the sake of awarding prizes, the contestants will be split in two groups, students and professional developers.

The Video Contest: The deadline is December 17, 2008 and a few selected winners will receive an 8GB iPod Video Nano (for both students and developers).

The Gadget Contest: The deadline is December 17, 2008 and the winning students grab Canon Powershot SD870 Cameras, while winning developers get 80GB Zunes.

The Query Contest: After you register, you’ll have 24 hours to submit your answers. The first 50 successful participants for each group (for a combined total of 100) will receive a 1GB USB key, while all the contestants with the right answers will be entered in a draw for a grand prize. This is a Playstation 3 40GB for the students, and a 32GB iPod Touch for the developers;

The Ported Application Contest: The deadline is January 31st, 2009. The winning team or individual amongst the students will receive an HD Pavilion HDX Notebook, while the winning developer will score a Lenovo IdeaPad U110. The second prize for both of the two groups will a Garmin nĂĽvi GPS.

The XML Contest: The deadline is January 31st, 2009. The 1st prize for each group will be a high-end 17″ Alienware Laptop (two laptops will be awarded in total). The second prize for both groups will be a Nintendo Wii (again, two in total).

Finally, two lucky XML Grand Masters, one developer and one student, will receive a Bose Wave Radio II.

I hope you consider enrolling now and best of luck! If you need some help with getting started with DB2 Express-C, you can download the free e-book which is available in several languages. Oh, and finally we have an Italian version as well.

Promote this post

Hey, would you give me a hand in promoting this post? If you are in the US or Canada, and mention & link to this post from your blog, you’ll receive a free XML Challenge T-Shirt and a Rubick’s Cube as well. All you have to do is send me an email (to acangiano at gmail.com) with a link to your blog entry, as well as your shirt size and complete mailing address. Thank you!


Merb, Rails Myths, Language Popularity and other Zenbits

Zenbits are posts which include a variety of interesting subjects that I’d like to talk about briefly, without writing a post for each of them.

Merb: A few days ago Merb 1.0 was released. Congratulations to Ezra Zygmuntowicz on this important milestone, the Merb community and Engine Yard (who finances the project). Merb 1.0 wasn’t even out yet when some people had already started commenting on the fracturing of the Ruby community that this new framework might bring with this, and the impact that this high visibility “competitor” might have on Rails. I believe that having more than one widely adopted web framework will only benefit the Ruby community. Furthermore, it’s important to remember that this is not a zero-sum game. Ruby programmers are perfectly capable of learning two frameworks and using one or the other, depending on the project at hand. This is particularly true if we consider that Merb, for all of its advantages – and disadvantages – when compared to Rails, is not totally different from its forerunner. If you are an expert Rails programmer, you should be able to become proficient in Merb in very little time. To help with this process, the Merb community needs to concentrate on the documentation now, given that the API is finally stable.

Rails Myths: David Heinemeier Hansson began a series of posts about Rails Myths. I like the idea of seeing common myths addressed straight from the horse’s mouth. Over the past two years, Rails has received quite a bit of backslash and old fashion FUD, so it’s important to set the record straight, whether the myths are entirely fabricated or if there is some element of truth to them. Whether you agree with David or not, it’s also nice to hear two sides of the same story. In fact, at the beginning of my book I debunk a few myths, just to set the record straight regarding what some readers may have heard surrounding the framework. It was a fun part to write.

My Book: Speaking of my book, Ruby on Rails for Microsoft Developers, I’m getting closer to the finish line. I’m about to complete Chapter 9 (out of eleven chapters). The initial schedule I was provided with has been extended slightly so that there will be sufficient time to properly review the content and ensure that it’s up to date with the final release of Rails 2.2. Some people wondered what the “Microsoft Developers” part means. Is it for people that work at Microsoft? Is it for .NET programmers? Is it for people who develop on Windows?

The truth is that “Microsoft Developers” is probably just a marketing term that Wrox selected as a catch-all for of the aforementioned categories of programmers. As an author I’m trying to serve all of them well, by providing a guide that sneaks in much of the Rails culture and softens the migration path by using an Operating System, and to a certain extent, tools that they’re already familiar with. In my opinion one of the major obstacles when switching to, or trying, Rails when coming from the Microsoft world, is the culture shock. The documentation and most books assume that you are familiar with *nix systems and tools, and this can be frustrating for those who are forced not only to learn a new language and framework, but also an entirely new set of tools. As it’s targeted at Microsoft developers, the book obviously makes quite a few references and comparisons to the .NET world, where they fit. This is done so that the many .NET programmers amongst the group of so called “Microsoft Developers” will find the book particularly useful. Yet the book remains generic enough so that it can be used by any programmer (particularly Windows users), even those without any knowledge of the Microsoft .NET Framework or ASP.NET.

Python books: While on the subject of books, I wanted to mention that the final version of the Pylons book is available online. Despite the much less fancy UI, the book pretty much does what the Django Book did in the past. And both are available in print as well (The Definitive Guide to Django: Web Development Done Right and The Definitive Guide to Pylons). Pylons is a Python web framework that can be viewed as a Ruby on Rails clone, in a far greater way than Django could ever be considered.

Another thing I want to mention is that I received a copy of Expert Python Programming. I haven’t gotten to far into it yet, but from what I’ve seen so far, things look good. I hope to be able to read it through, over a weekend in the near future and then provide a proper review. Stay tuned.

Language Popularity: If you take a look at the TIOBE Index, you’ll notice a few interesting things: Ruby has dropped two positions since last year, and it’s now the 11th most popular language in the world. This shouldn’t be cause for concern though, as shown by this Ruby graph. Python on the other hand is increasing in popularity and moved from the 7th to the 6th most popular language. Interestingly, according to the index (the results of which are educated guesses only), Python would seem to be more popular than C#. I find this to be true, in terms of online activity within an increasingly vibrant community, but in my opinion, the job market hasn’t caught up yet. In fact, at least in Toronto, when there’s a Python opening it’s pretty much an event that’s worthy of being discussed on the local Python mailing list. C# openings are much more common. This may be different in Silicon Valley, of course. It would also seem that Delphi has experienced a huge come back, moving from the 11th position last year to the 8th one this time around. It’s hard to imagine that Delphi has had a similar level of adoption as C# and thus has become more popular than Perl, JavaScript and Ruby. Delphi is a great solution for Win32 programming, but I don’t quite believe this overly optimistic outlook. And if this is the case, where are all the Delphi jobs and buzz?

DB2: This interview shows a few good reasons why even smaller and medium sized companies are increasingly adopting DB2. And while the video doesn’t mention it, IBM is coming out with an updated version of DB2 Express-C 9.5. This new version, 9.5.2 or 9.5 FixPack 2, is going to introduce exciting new features, including an engine for full text search.

The Great Ruby Shootout These days you hear a lot of talk about parallel programming. Intel promotes it and despite their bias, it’s plausible that parallel programming will become important as the CPU market heads towards an increasingly larger number of cores, as opposed to focusing on the frequency of said CPUs. In the world of Ruby, this translates into multiprocessing, as opposed to multithreading due to the infamous GIL (Global Interpreter Lock). This means that Ruby will most likely approach the problem similarly to how Python 2.6 did with the multiprocessing module, which is a process-based interface. The obvious exceptions are JRuby and IronRuby, which establish a 1 to 1 relationship between green threads and OS threads.

For the shootout, it would be interesting to see some multithreaded code, so as to get a better sense of how well JRuby and IronRuby compare to MRI and 1.9, when more cores are available. In fact, the long-promised shootout will be performed on a quad-core machine with 8GB of RAM. If Charles Nutter, John Lam, or any of their team members would like to contribute some programs that are able to take advantage of “native” multithreading, I’d be very happy to include them in the Ruby Benchmark Suite, to be used for my shootout.

The repository requires some love and refactoring, since it needs to be split in two types of benchmarks. The simpler one will evaluate the execution time minus the startup time, while the more advanced benchmark will also exclude the time required for parsing and loading modules, classes and methods in the AST. It would also be nice to test each program with variable input sizes and report these results accordingly. Right now I’m very busy with the book, but as I become more available, I’ll start working on this.

Finally, I want to point out a very interesting article about performance and UIs. Slow is indeed a very relative concept, and it’s important to understand how to analyze and respond to the user requirements when it comes to the responsiveness of an application as a user interacts with it.

Hardware: I finally bought a Trackball made by Logitech and the Microsoft Ergonomic Keyboard (Microsoft makes great hardware). I don’t have wrist problems, but I’d like to see how these two affect my extensive computer usage. I plan to report my experience as soon as I’ve had a chance to use these input devices for a while, since I know this is a topic that interests lots programmers (many of whom end up being victims of RSI, and some of the IRS :-P ). I also bought a bad-ass color laser printer which is quite handy when you’re a programmer and you are writing a book. I’ll let you know how it goes. What I didn’t buy, but still think is awesome, is the Flip minoHD. It’s the equivalent of an iPod for the world of camcorders. $235 for a camcorder that’s so perfectly compact, and yet that can record in HD, is a pretty sweet deal. I’m considering it for Christmas, assuming it reaches Canada by then.


Review of the first two Envycasts

The following quiz contains five fairly simple questions about ActiveRecord and Rails 2.2. Try to see if you can answer all of them.

1) What’s wrong with the following (technically valid) line of code?

Guide.find(:all, :include => [:user, {:questions => [:user, {:answers => :user}]}],
                 :conditions => "answers.user_id = 42")

2) Having specified :counter_cache => true in an association, what’s the difference between invoking size, length or count on the associated collection?

3) How do the following models work?

class Rate < ActiveRecord::Base
  belongs_to :rateable, :polymorphic => true
end

class Post < ActiveRecord::Base
  has_many :rates, :as => :rateable
end

4) In Rails 2.2 how would you disable validation of a model’s associated objects?

5) How would you use caches_action to cache the content of an action but not the layout?

Confused, lost, not sure? Read on.

Gregg Pollack and Jason Seifer, of Rails Envy Podcast fame are up to something interesting, yet again. They recently started publishing commercial screencasts.

The first envycast is called Advanced ActiveRecord and as you’d expect, it covers several intermediate level topics that often confuse beginners. From relatively simple concepts like dirty objects to polymorphic associations and Single Table Inheritance (STI), including several performance considerations. The video is 37 minutes long and ships with a useful PDF cheatsheet.

The second envycast is titled Ruby on Rails 2.2 Screencast. It comes in at almost 45 minutes long and will prove useful to any Rails developer who’d like to upgrade their skills to Rails 2.2. It covers most of the changes, but for a more thorough analysis of every detail in the change log, they are also making a PDF by Carlos Brando available. Both the video and the PDF sell for $9 each, but you can get them together in a bundle for $16.

This is a preview of the Rails 2.2 one:


Overall I think these videos are very solid. They are informative, accessible, have good examples, and above all are fun and entertaining to watch. If you enjoy the style of humor distilled weekly through Gregg and Jason’s podcast, you’ll love their videos as well. Nine dollars to learn more about ActiveRecord or to get you up to date with Rails 2.2 in less than an hour, is truly an inexpensive price to pay. I also like the fact that their videos are made available in both Quicktime and Theora Ogg format.

Final verdict: I can confidently recommend them.


Disclosure: I obtained the two videos for free, as review copies, but I have no commercial affiliation whatsoever with the Envycasts producers.


Ruby on Rails for Microsoft Developers available for pre-order on Amazon.com

Ruby on Rails for Microsoft Developers is now available for pre-order on Amazon.com. Contrary to what the Amazon page states, the publication date is planned for the middle of December, not January. Similarly, the description is quite messed up and loosely based on the first outline. It almost makes it sound like a book on Ruby as opposed to one on Rails. In reality, only two chapters are dedicated to Ruby, while all the others are Rails specific. A more accurate description should be up soon though.

This is the cover, with the picture of yours truly. Ladies, easy on the emails, I’m happily married. :-P Jokes aside, I’ll share a bit of trivia about the picture with you. The few decent photographers in the area quoted me outrageously high numbers just for the one shot I needed for the cover. Being passionate about photography, I ended up shooting it myself, so it’s a self-portrait. I wonder if it’s a first in the world of Wrox covers.

Cover of the Ruby on Rails for Microsoft Developers book

Page-wise, I’ve written roughly half the book, which is going to be about 450 pages, and I expect to finish writing sometime in October.


Ruby and Rails books, two years later (photo)

Two years ago:

Java vs. Ruby

Today:


Review of the screencast series The Ruby Object Model and Metaprogramming (episodes 1-3)

Even if you’re new to the Ruby community, you are unlikely not to have heard about the Pragmatic Programmers, who are well reputed for publishing great programming books. You may not have noticed that lately though, they’ve also been releasing several series of screencasts.

Each episode lasts about half an hour and sells for a mere $5. This strategy will work well in their favor because screencasts are a great way to teach programming. So far they’ve put out 5 series: Expression Engine, Core Animation, Erlang by Example, Everyday Active Record and, their latest entry, The Ruby Object Model and Metaprogramming.

If you are reading this blog, I’ll assume you’re mostly interested in the last two topics. I haven’t had a chance yet to watch the Active Record ones, so I can’t say much about them, other than that I have faith in their author, thanks to his magnificent work on the Railscasts.

Today after work however, I spent about an hour and a half watching the first three available episodes of The Ruby Object Model and Metaprogramming. This is a brief review of my thoughts on them. In short: they’re fantastic. But let me provide you with a bit more of a in-depth analysis than that.

These screencasts shine for the simple reason that you feel as though you’re sitting right there, next to a master programmer like Dave Thomas, as he explains Ruby concepts in detail to you. Whenever you’re not very clear about a concept, you can go back and listen to the explanation as many times as you’d like. You can pause, experiment with irb, and then go back to the screencast. After watching the first episode, I though that the $5 price was a steal.

Currently the following three episodes are available:

  1. Objects and Classes (29 mins)
  2. Sharing Behavior (39 mins)
  3. Dynamic Code (31 mins)

The first episode lays the groundwork for the series and introduces a useful diagram that enables you to easily visualize the Ruby object model correctly. Concepts like singleton methods and ghost classes are really well explained. The first episode also covers ‘self’ and the concept of current class, which is often confusing to beginners.

The second episode explores what constitutes good object oriented design, as well as the usage of prototype programming, inheritance (and how not to abuse it), and finally an excellent explanation of modules and mixins. If you are a beginner you may not know the difference between including and extending a module, or the true power of mixins. Fear not, the last part of second episode really covers those subject well.

The third episode starts by defining blocks and their usage, including the difference between lamdba and Proc.new. It then moves on to explore the concept of bindings capturing the execution context, and the importance of closures in metaprogramming. The last 12 minutes or so are spent dealing with the subject of dynamically defining methods, which is at the heart of metaprogramming, and the video includes a nice example of how to create your own version of attr_accessor by defining, in a module, a method that dynamically defines getter and setter methods.

I’d say that aside from the feeling that I was enjoying a “private lesson”, what I liked the most was the coding style recommendations about when to employ a given concept and when to opt for something else. The examples were clear and easy to follow as well.

I can’t recommend this series highly enough to any Ruby programmer with a basic grasp of the language. I feel that intermediate developers will get the most out of these videos, but they’ll also definitely be very beneficial for beginners. Real experts shouldn’t find any alien concepts, at least in the first three episodes; I know I didn’t. Yet, they’ll appreciate, just like I did, the fresh slant when it comes to reviewing some of the illustrated concepts and examples. There will also be a few “ah-ah!” moments here and there, I guarantee you.

Five stars, and I’m certainly looking forward to future episodes.


This Week in Ruby (May 29, 2008)

This is the 9th episode of This Week in Ruby, please consider subscribing to my feed so as to not miss any weekly installments.

Ruby

Two days ago JRuby 1.1.2 was released. Amongst several bug fixes and improvements, this release is characterized by a focus on performances. Startup time, threading, method calling and YAML symbol parsing have all been drastically improved.

Huw Collingbourne of SapphireSteel, has announced that he’ll be releasing a complete book on Ruby, chapter by chapter, free of charge online. After reading the first chapter, I can attest that it’s excellent. Keep an eye on it, as new chapters get added.

The Pragmatic Programmers put out a series of screencasts for sale. The most relevant series for Ruby programmers is Everyday Active Record. The first two episodes (a half an hour long, each) are out and can be purchased for just $5 a piece. The preview — and Ryan Bates’s reputation — lead me to believe that they are entirely worth their very reasonable sticker price. Speaking of screencasts, a new one about merb-slices was released on Merbunity, check it out if you’re into Merb.

There were two important releases last week, Mack 0.5.5 — which features a new rendering engine with support for Haml and Markaby — and DataMapper 0.9, a major reworking of the ORM. A third release, which is perhaps just as welcomed, was launched by _Why who included a few graphical improvements for Shoes, his GUI application toolkit. Definitely neat stuff, which I invite you to take a look at if you’re working on a Mac.

Peter Cooper published 21 Ruby Tricks You Should Be Using In Your Own Code. You probably know already most of the common ones at least, but they’re quick and fun, so if you haven’t checked out the post yet take a moment and do so. Other must-read tutorials and articles were Ruby && DTrace! (really neat results), Ruby EventMachine – The Speed Demon by one of my favorite Ruby bloggers, and Will’s Guide to Mashing-up Remote Databases using Page Scraping.

In a post made a couple of days ago, Robert Fischer opened up a can of worms by bringing up the issue of Ruby and XML libraries. As most of you know REXML is far from being issue-free (performance in primis), and in The Status of Ruby’s libxml Robert uncovers that the author of LibXml Ruby is unable to actively pursue the development of his extension. This issue concerns me, but if I’m working with databases, I prefer to take advantage of DB2 Express-C ’s fantastic pureXML features, which give me the sort of speed, flexibility and stability that I won’t find in a Ruby library anytime soon.

Before highlighting some of the news from Rails-land, I wanted to inform you that a new version of The Great Ruby Shootout will surface in June, as I intend to test a couple of special new entries.

Rails

Today, RailsConf 2008 started and it certainly stands a great chance of being dubbed an exhilarating event. A few people enquired to see if they could meet me there, but unfortunately I couldn’t make it. Chances are that you’re reading this post from RailsConf. If that’s the case, say hi for me and don’t forget to visit the nice fellas from Engine Yard, Morph (my sponsor), Phusion and GemStone. Oh and also, feel free to pass around the url of this entry. ;)

Rails 2.1 RC1 is out, so you’ll find this article on upgrading to Rails 2.1.0_RC1 useful. Fabio Akita released a new version of his popular tutorials, Rolling with Rails 2.1 (part 1 and part 2). And if you are looking for an advanced authentication/authorization system for Rails 2, take a gander at Lockdown on RubyForge.

My friends at SeeSaw implemented a series of Rails Widgets which can easily be installed as a Rails plugin. Feel free to use them and/or contribute, in order to add further support for simplifying and reusing common UI elements. Speaking of shiny things, check out this Ruby on Rails icon pack; very pleasing to the eye, in my opinion.

RubyInside published a list of 28 mod_rails / Passenger Resources To Help You Deploy Rails Applications Faster. As DHH forecasted, “this could definitely become very popular, very fast ;) ”.

New Relic released their RPM solution for monitoring and improving the performances of Rails applications to the general public. You can get it here.

And finally, some great news just came in, IronRuby is running unmodified Rails. “Excellent” (said in Montgomery Burns’ voice, complete with characteristic hand gesture).


Ruby on Rails for Microsoft Developers

Last Friday I sent the first chapter of my book to the Development Editor. It’s only one chapter, which is about 30 pages or so of text and figures. I foresee and fully expect that the real challenges are still to come; yet a great deal of work already went into this first stepping stone and I feel very satisfied by the initial results.

While I briefly mentioned, on Twitter and here, that I was going to write a Rails book, I never provided any details given that the book was still being discussed and the contract had yet to be finalized. Now I can finally provide you with a bit more information. The book will be Ruby on Rails for Microsoft Developers and it will be published in December 2008 by Wrox (in their Professional Series).

I’m always motivated by a sense of purpose, and wouldn’t be able to find it if the book were to be yet another generic Rails one. I’m ecstatic about this project, because I feel that it’s a book that matters. If I do a good job, this title will be more than a Rails guide for .NET programmers, it will be an immersion course into the Rails community and culture for those developers who come from a very different background and have, more often than not, different opinions and viewpoints on development. I’m writing it because I feel it’s a book that needs to be written.

Being a book by Wrox, you’ll also get to see my chubby face on the cover, a very strong argument against the otherwise nice personal touch that Wrox covers convey. ;-) Given that self-portraits are discouraged, I’m open to suggestions and recommendations for a good professional portrait photographer in Toronto or the GTA. More than a photographer, I’d need a miracle worker. But oh well, I started a proper diet nevertheless, even if it won’t have done any good by the time my picture is taken in June. :-)

Frivolous matters aside, so far the journey that just began has been great and characterized by the distinctive feeling of working with a team of real professionals who’re eager to help. I’ll keep you posted as I progress through this marathon.


This Week in Ruby (May 20, 2008)

This is the 8th episode of This Week in Ruby, please consider subscribing to my feed so as to not miss any weekly installments.

Ruby

Yehuda Katz released a couple of “gems” this week: Thor improves Ruby’s support for scripting, and it was created while he was working on a Textmate gem for handling bundles.

You may have heard about the book: The Ruby Programming Language. I found this review to be an interesting read if you are considering purchasing it.

Struggling with regular expressions in Ruby? Now you can use Rubular, an excellent way of editing and testing Regular Expressions in Ruby, so that “you don’t have a new problem”.

If you are one of the developers who prefers Flex to Ajax, then you need to check out Ruboss, a new framework aimed at simplifying the creation of Flex powered Rails applications. The co-author of the framework is also the author of Flexible Rails, a well written book that I’m trying (slowly) to read, even if at this stage I don’t plan to use Flex.

DataMapper continues to gain momentum in the Ruby community, particularly for its usage with alternative frameworks. An article titled Thoughts on DataMapper provides a lot of insight into this enterprise level ORM.

Rails

The big news this week is that Rails is finally on Rubinius. This follows a previous announcement in which the Rubinius team managed to get Merb up and running. Once long ago, at the time of my first shootout when Rubinius was a very young project and performed poorly, I had an email exchange with Evan Phoenix and I told him, “I secretly think that your project may become the most interesting implementation of Ruby.”. I stick to that conviction. As long as they manage to improve performance to the point of being as fast as Ruby 1.9, they have a shot at becoming the most popular Ruby VM. The company that made this possible is Engine Yard, and you may be interested in checking out this interview with their CEO, Lance Walley.

WindCityRails is a one-day (September 20, 2008) not-for-profit conference. There are only 150 places available and these will sell out really fast. Book your sit now, it’s only $99 for a day of fun and coding.

Other remarkable articles from this week were: Chunky Iterator: So You Don’t Have to Load All Your AR Objects at Once, Do we really need Controller and View tests?, Guide to Unobtrusive JavaScript and SWFUpload, Paperclip and Ruby on Rails.

Not exactly published last week, but still worth mentioning is this series of Notes from the Advanced Rails Studio (part 1, 2 and 3).

mod_rails

Dreamhost is now officially on Passenger; this is a major score for the guys at Phusion. They also have a challenge up with t-shirts offered as a prize, for those who can identify the various deployment configurations compared in two speed and memory charts, while testing the blog engine Typo 5.0.3.

This week Geoffrey Grosenbach shared his point of view regarding mod_rails in Ask Your Doctor About mod_rails, while the second part of Ubuntu 8.04 Rails Server Using Passenger went up.

It could be said that the Phusion guys are very good at creating hype for their products, but — for now I can’t say more than that — they seem to deliver.


« Previous Entries

Copyright © 2005-2010 Antonio Cangiano. All rights reserved.