Posts in the “programming” category

Could Functional Programming be called Algebraic Programming?

Lately as I’ve been writing and editing Functional Programming, Simplified: Updated for Scala 3: Could Functional Programming be called Algebraic Programming?

Yes, FP is about pure functions, HOFs, and functions as values, but it’s also about domain modeling (ADTs), immutable variables (algebraic) and immutable data, errors as values, and EOP (expressions as equations).

Other notes:

  • Functional programmers also use the term “blueprint” a lot, so that’s another possible name.
  • To be clear, I’m not calling for a name change or anything like that, just observing that Algebraic Programming may be a more accurate name.

Two great quotes on data, domain modeling, programming, and design

Here are two great quotes on programming, data modeling (domain modeling), algorithms, and design that I was just reminded of, thanks to this Twitter question:

Linus Torvalds: “Bad programmers worry about the code. Good programmers worry about data structures and their relationships.”

Fred Brooks: “Show me your flowchart and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won't usually need your flowchart; it'll be obvious.”

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.

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.

How to use curl scripts to test RESTful web services (GET, POST, etc.)

Summary: This tutorial shows how to use Unix/Linux curl scripts to test REST/RESTful web services.

There may be better ways to do this, but when I was writing a mobile app — with a 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.

You can also write REST clients with Scala, Java, and other languages, but for various reasons I wanted to test these web services with curl. As an added bonus, you can include scripts like this into your testing and integration process, if you like. You can also use the same approach with Nagios to make sure your service is still running.

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]

How to call/test a web service from a browser

Web service testing FAQ: How can I test a web service from a browser?

There was a time in my life when all I did was write and test web services, and here are a few notes I learned about hitting one of my web services from a browser.

Looking at the WSDL for a web service from a browser

To view the WSDL document for a web service I created named UserService, I just went to the following URL in my browser:

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.

LOGO used “TO” like Scala and Ruby use “def”

I ran across the following page in the book Clean Code, and it really caught my attention. In short, there is a programming language named LOGO that apparently used to keyword TO in the same way languages like Scala and Ruby use “def.” This is described near the bottom of the page in the following image, in the area I highlighted:

Clean Code - The TO keyword in the LOGO programming language

I’ve never used LOGO, but that sounds like a clever approach, and since I ran across this discussion, I have to say, it’s had an effect on my methods. Every time I type “def,” I think “TO,” and it makes me think a little bit more about how I want to write my method.

For more information on book, check out the Clean Code book.

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

It feels like my SQL skills are pretty average these days, but that’s only 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) as 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.

Docker cheat sheet (cheatsheet)

This is the beginning of a Docker cheat sheet. I couldn’t find any out here that I liked, so I’m starting to create my own, which will hopefully be organized the way I like it.

This content is cross-posted at My Valley Programming Docker cheat sheet.

Docker Basics

Recommended as a first command on a Docker system:

docker version     # should show Client and Server sections

Docker Lifecycle

This section mostly comes from (

To be a programmer is to develop a carefully managed relationship with error

“To be a programmer is to develop a carefully managed relationship with error. There’s no getting around it. You either make your accommodations with failure, or the work will become intolerable.”

~ Ellen Ullman (via this tweet)

This quote makes me think of all those years of exception-handling with Java. I never knew there was a better way to handle errors, so I developed a strategy of letting my exceptions bubble up to the controller level (as in model/view/controller), where I would deal with them. These days I know I can use Option/Some/None in Scala, as well as Try/Success/Failure.

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