fizwidget

cat /dev/random

Functional Pipelines

The concept of pipelining is pretty simple – components are connected in series such that the output from one flows into the input of the next. Piping data in shell scripts is an example most programmers are familiar with:

1
cat logs | grep 'ERROR' | sed 's/color/colour/g' | sort | uniq

This style of programming doesn’t have to be relegated to shell scripts though – it’s a universal concept that can help us write better code in many different languages. Instead of piping data from one program to another, we’ll compose functions (or equivalently, chain methods).

Python or Ruby?

Python and Ruby are the two heavyweights in the general-purpose, high-level, dynamic language category. They’re both awesome, but given the choice, I’ll generally go with Ruby. This is my attempt at explaining why…

Implicit Futures in Ruby

Say we’re writing a program that performs several time-consuming operations, like network requests, disk accesses, or complex calculations. We want them to execute concurrently, but we also want our code to remain simple and easy to understand. There are many different ways of approaching this problem, but in this post I’ll focus on implicit futures and how they can be implemented in Ruby.

Nothing but Functions

Imagine we’re using a programming language that doesn’t give us any way of defining data structures. No arrays, no tuples, no structs, no classes. Nothing. All we can do is define and call functions.

Now imagine we need to work with a collection of items. Are we screwed?