Posts in the “programming” category

The three principles of functional programming

Functional programming is interesting. On the one hand it’s very (extremely!) disciplined. But on the other hand, people can’t agree on certain definitions. As an example, here are the “three principles of functional programming,” from this tweet:

1. Orthogonal composability
2. Maximum polymorphism
3. Maximum deferment

Conversely, here are the “three pillars of functional programming,” from Functional and Reactive Domain Modeling:

1. Referential transparency
2. Substitution model
3. Equational reasoning

When I learned OOP I saw that it was based on several principles that everyone agrees upon. When I started learning FP (and later took two years to write Functional Programming, Simplified) I was surprised there wasn’t a single accepted definition of functional programming. I ran across the principles/pillars in the last two days and was reminded of that again.

Phrases to use instead of “foo bar baz”

As I get close to releasing the Second Edition of the Scala Cookbook, I’m trying to use the “foo bar baz” phrase less often, and trying to find better and more meaningful phrases. Thanks to Arrow and The Flash, one phrase I’m using is “Big Belly Burger.”

If you know any great phrases to use to help rid the world of “foo bar baz,” let me know here on Twitter. Here are a few I just looked up:

bond, james bond 
clear eyes full hearts can’t lose (friday night fights)
elementary, my dear Watson 
fasten your seatbelts 
frankly my dear 
gonna need a bigger boat 
hasta la vista (baby)
here’s looking at you kid
I see dead people 
just keep swimming
make my day
no crying in baseball 
not in kansas any more 
of all the gin joints 
open the pod bay doors, HAL 
pass the beernuts (Cheers)
play it again sam
show me the money
shaken, not stirred
Soylent Green is people 
the walking dead 
too much fruit (in the house)
who’s on first?
why so serious?
you talking to me? 
you’ll thank me later

A Markdown cheat sheet

This is a simple Markdown cheat sheet. I created it for my own needs, so I can find what I use and need quickly. If it’s a helpful resource for you too, cool.

[toc hidden:1]

The meaning of the word “reify” in programming

I don’t recall hearing of the words “reify” or “reification” in my OOP years, but that may be because I studied aerospace engineering in college, not computer science. Since learning functional programming (FP) I often see those words, so I thought I’d try to understand their meaning.


I ran into the word “reify” when I saw code like this:

trait Foo {

object Foo extends Foo

I’d see code like that then someone would describe that last line as a “reification” process.

What “reify” means

The short answer is that the main definition of reify seems to be:

“Taking an abstract concept and making it concrete.”

For the longer answer, I found the following definitions and examples of reification.

An article on the problems with OOP

There seems to be a lot of OOP-bashing lately, which I’m not a fan of, but this article titled Goodbye, OOP makes decent points about the problems with inheritance, encapsulation, and polymorphism. IMHO, OOP still makes sense in certain areas, including GUIs like Java Swing and JavaFX, so I’m not ready to throw it out completely or bash it.

How to use `curl` scripts to test RESTful web services

There may be better ways to do this, but when I was writing a mobile app, with the JavaScript client written in Sencha Touch and the server written with the Play Framework, I wrote some curl scripts to simulate GET, POST, DELETE, and PUT request (method) calls to my Play Framework REST/RESTful web services.

GET, POST, DELETE, and PUT examples

The following examples show the code for each of these scripts. First, here’s

curl --request GET http://myhost/notes/rest

Quotes from Clean Code

Back in 2013 I read the book Clean Code by Robert C. Martin, and in an effort to keep that book alive with me a little while longer, I decided to make my own “Cliffs Notes” version of the book on this page. One of my favorite notes from below is that a language named LOGO used the keyword to in the same way that Scala uses def, so a method named double would be defined as to double... instead of def double..., which seems like it would help developers name methods better.

Martin Fowler on lambdas, circa 2004

I ran across this historical tidbit from Martin Fowler a few days ago. It’s interesting to see that in 2004, lambdas weren’t too well known, and they’re associated here with dynamic languages. With a degree in aerospace engineering, I only knew of them from in interest in Lisp, and then Ruby around this time.

Higher order functions *are* the Haskell experience

This is a great way to put this: “Higher-order functions aren’t just a part of the Haskell experience, the pretty much are the Haskell experience.”

(A “higher-order function” is generally defined as (a) a function that can take a function as an input parameter, or (b) returns a function as a return value.)

The quote and image come from this LYAHFGG page.

How to use SQL SELECT, GROUP BY, ORDER BY, and COUNT (all in one)

Don’t tell anyone, but my SQL skills are pretty average these days, at best, mostly because I haven’t had to do anything hard in a while. But just now I was happy to write this little SQL SELECT query that does a GROUP BY, an ORDER BY, and a COUNT, yielding the results shown in the image:

select nid, count(nid) from term_node
where tid in (3,1,11,10,9,8,7)
group by nid
order by count(nid) DESC

I’m going to use this query — or one very similar to it — to get a list of nodes (nid) that have the most tag ids (tid) from the list of tid in the query. In theory, the nodes (blog posts) that have the most tags in common should be the most related to each other. So, in my Scrupal6 replacement for Drupal 6, this query is a way to get “related” content for a given blog post. (The tid list shown comes from node id 4, so I need to also exclude nid=4 from the results. I also need to add a limit clause to the query.)

If you ever need to do a group by, order by, and count in one SQL query, I hope this example is helpful.

An offer to write open source documentation for a modest fee

Have you often looked at the documentation for an open source project and thought, “If that documentation was better, I’d be glad to give this project a try. The problem is, it’s like an expert wrote these docs, and I have no idea where to even start.”

Solution: Starting in July I’ll have some free time, so I’m offering my technical writing services for the low, low price of $30/hour. I’ve charged 7x that for programming; this is a bit of an exploration to see if there’s a market here.

Caveat: I can only work ~10-15 hours/week. Things I can write about easily are Scala, functional programming, Flutter, Dart, and Java. Other things I have some knowledge of are Android, Kotlin, Rust, and TypeScript. Email “al at valleyprogramming dot com” if interested.