The karma of writing a book

As I’m writing my new book on functional programming in Scala I started thinking, “What if the person who creates Skynet or the Matrix reads this book and suddenly understands how to create their evil invention? But ... if I don’t create this book, they’ll stay on their previous course in life to be a world-famous cookie baker.”

It’s quite a responsibility, knowing that you could be responsible for a future without great cookies.

Don’t let yesterday contain the greatest things you’ve ever done

Via a friend on Facebook:

“My advice: Don’t let yesterday contain the greatest things you’ve ever done. Make tomorrow contain your next great goal. Because once you feel your greatest days are behind you, you begin to die.”

At the very least that quote is about the importance of having goals.

The state of payments systems in ten years

“If you think you know what the state of the payments system 10 years out you're in a state of delusion.”

~ Charlie Munger talking about AMEX

Scala for-loop examples and syntax

Table of Contents1 - Example data structures2 - Basic for-loop examples3 - Generators in for-loops4 - for-loop generators with guards5 - Scala for/yield examples (for-expressions)6 - Scala for loop counters (and zip, zipWithIndex)7 - Using a for loop with a Map8 - Multiple futures in a for loop9 - foreach examples10 - Summary

Besides having a bad memory, I haven’t been able to work with Scala much recently, so I’ve been putting together this list of for loop examples.

This page is currently a work in progress, and as of tonight I haven’t tested some of the examples, but ... if you’re looking for some Scala for loop examples — technically called a for comprehension or for expression — I hope these examples are helpful.

How to use multiple Futures in a Scala for-comprehension

Table of Contents1 - The correct approach (simplified)2 - A thorough example for verification3 - The wrong approach4 - Summary

As a quick note about Scala Futures, if you want to create multiple Futures and merge their results together to get a result in a for comprehension, the correct approach is to (a) first create the futures, (b) merge their results in a for comprehension, then (c) extract the result using onComplete or a similar technique.

What is a Future in Scala?

In the Scala Standard Library, a Future is a data structure used to retrieve the result of some concurrent operation. This result can be accessed synchronously (blocking) or asynchronously (non-blocking).

~ from the akka.io docs

(For more information, here’s my Scala Futures example.)

One day you’ll love someone who won’t love you back

I’ve been really irritable lately, mostly as a result of not getting an answer to my ongoing health issues. Probably because of this, today I had this thought that when people say, “Nobody loves me,” it occurred to me that it would probably more accurate if they said, “The person I want to love me doesn’t love me.” Then when I saw the following Twitter post just now I thought I might as well go ahead and write what I was thinking. Here’s the text of the Twitter post:

Of all the future perils for which we warn & prepare children, no one ever mentions: “You’ll one day love someone who won’t love you back.”