06 February 2007

Finger-picking good

Whew. I haven't played the guitar this much since October. I played until my fingers hurt. Then I played a few more songs. [M]rs. montsamu and baby montsamu were the receptive audience, although both settled in for a nap by the end. I'm getting closer to putting closing the books on a new song called The Sparrow -- a departure from my usual kind of song in that it actually has an expressed meaning, and is intended for children. But I guess that is just one example as to how a new dad's life changes.

Sometimes a sparrow's ignorance
can be confused for divine providence
because sometimes
knowing how far can keep you from taking flight at all.

02 February 2007

Erlang: parallel-map and parallel-foreach

In a post to erlang-questions last summer, Erlang on the niagara, Erlang super-hero Joe Armstrong posts a simple "parallel-map" implementation that he uses in place of some of his simple "iterative-foreach" calls to quickly achieve dramatic speed improvements by taking advantage of multiple processors. The post got me thinking, particularly in light of recent discussions on side-effects and purity, about the real differences and guarantees of such simple things as map and foreach.

Principally, map is (1) supposed to be called with a function with no side effects, (2) guarantees order of return to match the input list, and (3) makes no guarantee on order of function calls, while foreach is (1) used explicitly (and solely) for its side effects as (2) it has no return value (other than the atom ok for success) and (3) guarantees the order of function calls to match the order of the input list. Now, Joe's code was for a parallel-map implementation -- returning a list of results from the application of the given function, no guaranteed order of execution -- when it was actually being used to replace a foreach statement. It happened to work out nicely that his code did not rely on any order of execution promises.