Arne is a developer, public speaker, programming coach, author and open-source contributor. With a passion for both human and programming languages, he has spent the last decade teaching and exploring the finer points of Ruby, LISP, Haskell, Mandarin Chinese, and others. When not hopping conferences or Pacific islands, he can be found at his home base in Berlin, brewing fine teas while pondering the future of open-source and the web.
This is the second part of a two part series on functional programming in Ruby. Before we explored immutable values, now we’ll look at the other side of functional programming: pure and composable functions. Pure Functions A pure function is a function where the return value is only determined by its input values, without observable […]
Functional programming has been around for a while. McCarthy envisioned LISP in the 1950’s, but you could even argue that the Lambda Calculus, a mathematical device to reason about computation that predates LISP by a few decades, was the first functional programming language.
Despite it’s ripe, old age, FP isn’t planning to leave us any time soon. Scala, F#, and Clojure are all functional languages that appeared roughly in the last decade. All of these “new” languages are still gaining followers. The functional paradigm seems more alive than ever.
There are good reasons for this. We live in a world of multicores and big data, a time of massively concurrent, distributed systems. Coordinating concurrent processes is hard, but functional programming can make it a bit easier.
Working with immutable data is a requirement for functional programming. This poses some challenges, but it provides new opportunities as well. The price of memory and storage is at an all-time low and, once you start to see the benefit of immutability, in-place editing of data seem like an optimization from an age long past.
As Rubyists, what do we make of this? Do we jump ship and start learning Haskell or Clojure instead? I don’t think that’s necessary, but it’s still a great idea. Spend some time with a functional language until things start to “click”, and you are bound to bring some interesting ideas back home to Rubyland. You don’t need a functional language to program in a functional style, nor do you need to be a purist or a pedant to reap the benefits.
Trello is a great collaboration tool. It’s based around boards, which contain lists of cards. How you use it is up to you, as it’s one of those simple tools with many uses. Want to plan or coordinate with multiple people, or just manage your own todos? Just set up a board and get going.
All of Trello’s features can be controlled through its API, and it’s completely free, including use of the web and mobile apps, as well as access to the API. With the
ruby-trellogem you can be automating your boards in no time.
As Rubyists we are no strangers to testing. Unit testing is not just best practice, it is dogma. Code is considered broken until we have tests to prove otherwise. But not all test suites are created equal. Writing good tests is an art, and bad tests can be worse than no tests, slowing development down without increasing the confidence we have in our code.
So who tests the tests? The question may seem frivolous, but the answer is simple, Mutant does!
Mutant is a mutation tester. To appreciate what it does, let’s imagine doing its job by hand. Appoint a person in your team to be the saboteur, their job is to pick a piece of fully tested code and deliberately introduce defects. If this can be done without raising an alarm, in other words, without causing a test to fail, then a test is missing. It’s then up to the original author to add a test case to detect the sabotage.
Ruby’s standard library is a treasure trove of useful classes, and the
Pathnameclass is certainly one of them. Introduced in Ruby 1.9,
Pathnamerepresents a path on the file system, providing convenient access to functionality that is otherwise scattered across a handful of other classes like
Now that the life of Ruby 1.8 has officially come to an end, and 1.9 is nearing its fifth birthday, it’s high time to drop the legacy support and embrace the elegance and ease of use
Pathnamehas to offer.