Six languages to master

July 29, 2012

This post, by Michael O Church is an excellent post on being a better programmer and full of a lot more awesome than the title implies. You need to read the entire thing. After he makes the case for which five programming languages to learn, the best stuff starts when he makes his case for the sixth:

The sixth is one that very few programmers are willing to use in source code: English.

He rightly defends comments and documentation:

Most problems are custom problems that require documentation of what is being solved, why, and how. People need to know, when they read code, what they’re looking at; otherwise, they’re going to waste a massive amount of time focusing on details that aren’t relevant.

And makes very salient points about depending on IDEs to develop. This is one of many, but my personal favorite:

If you’re IDE-dependent, you can’t write code outside of a corporate environment, because when you go home, you don’t have a huge support team to set the damn thing up.

Really great read.

A world without nil

July 25, 2012

Previously, we saw how just using functions in Ruby, we could create a lot of powerful code. Let’s continue the theme of “programming with constraints” and try to solve an actual problem. nil.

Adventures in functional programming with Ruby

July 17, 2012

The following is an aimless journey through a degenerate form of Ruby, in an effort to learn a bit more about functional programming, simplicity, and API design.

Suppose that the only way we have to organize code in Ruby is to make lambdas, and the only way we have to structure data are arrays:

square = ->(x) { x * x }
square.(4) # => 16

person = ["Dave",:male]
print_person = ->((name,gender)) { 
  puts "#{name} is a #{gender}"
}
print_person.(person)

This is the most bare-bones essence of functional programming: all we have is functions. Let’s write some real-ish code this way and see how far we get before it starts becoming painful.

What is 'better' code?

June 27, 2012

We all want better code. Rails creator David Heinemeier Hansson said that the only way to evaluate a code change is if the new code is “better” than the old. Of course, he didn’t define what he meant by “better”. At Scottish Ruby Conf, Dave Thomas said that good code is code that is easy to change. This is a bit more specific, but not really enough to give any real direction.

Let’s see if we can derive a real understanding of code quality.

Single Responsibility Principle and Rails

June 10, 2012

Was reading the slides from Aaron Patterson’s Magma Rails talk and noticed some pretty innocuous Rails code that, upon further reflection is the beginning of disaster for a growing application. As many other Rubyists are beginning to realize, spreading your application logic across only models and controllers leads to a mess. Let’s look at the code, understand why it’s bad, and create a better version.

Lookup tables with lambdas

May 16, 2012

Yesterday, I tweeted:

This may seem crazy, but it’s a really just an enhanced use of what Steve McConnell, in “Code Complete”, describes as Table-Driven Methods. Let’s see what that has to do with my crazy Hash construct.

Five Months of eBook Sales

April 24, 2012

I really enjoyed reading Jesse Storimer’s recent post, 4 Months of ebook Sales, about the sales of his book “Working with Unix Processes”. His feelings echo my own regarding my book, “Build Awesome Command-Line Applications in Ruby”:

I’m ecstatic with the results so far, but I have no idea how they compare.

Our books complement each other quite well, and came out around the same time. He wrote his largely on his own, going the self-publishing route, while I wrote mine with the Pragmatic Programmers. I thought I’d write a similar piece from my experience going the “traditional” route.