3 Mind-Blowing Paradigms from Strange Loop

I had a long-time programmer tell me: “Once you know a few programming languages, you pretty much know them all. At the end of the day, programming is all just variables, conditionals, loops, and so on.” If you’re nodding your head in agreement, it’s time to seek out more interesting programming paradigms!

Several of my fellow Atoms and I attended Strange Loop 2013 last month. There were a huge number of awesome talks on a wide variety of programming topics, including several that challenged my assumptions about what concepts are really essential in computer programming.

Here are three programming paradigms featured at Strange Loop 2013 and the Emerging Languages Camp that blew my mind. These paradigms aren’t new to computer science, but I found them fascinating, and I hope you will too! Read more on 3 Mind-Blowing Paradigms from Strange Loop…

Beware the Elvis Operator in Groovy

While implementing a really simple caching mechanism in a Grails app, I came across what seemed like some odd behavior. I had an array of objects that would be built up within a function if not passed from the caller. To keep it as an optional argument, I had a default value of “null.”

def doStuff(arg1, arg2 = null) {
    arg2 ?: DomainClass.findAll(it.property == arg1)
    // Do stuff

This strategy was working most of the time, but there were still spurious database accesses whenever an empty array was being passed in. As it turns out, the spurious database accesses were occuring whenever the parent was passing an empty array for arg2. In Groovy, empty collections are falsy, as are empty strings and the number 0.

Read more on Beware the Elvis Operator in Groovy…

When Is a Set Better Than an Array in Ruby?

I’ve been using Ruby for quite some time, but it was only recently that I found a hidden gem in the standard library, the Set class. If you are familiar with the mathematical concept of a Set, then Ruby’s implementation will hold no surprises for you.

Using a Set in Ruby

Ruby’s Set supports all of the common set operations including union, intersection, and subtraction. Read more on When Is a Set Better Than an Array in Ruby?…