&. |

A software developer’s musings on software development

Sometimes, don't be friendly to the user

Warning: I wrote this blog in 2019. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

I’ve recently come to the revelation that sometimes it’s okay—desirable, even—to go out of your way to make software that is not user-friendly or easy to use. In specific situations.

Consider a nuclear weapons facility with a plastic box1 over the launch button2, or the familiar “in case of emergency break glass” boxes with an axe or fire alarm or something3. What these have in common is that obstacles are put in place between the user and the system they control in order to artificially make certain actions more difficult. Say, the action of butt-dialing a nuclear holocaust.

This is not user-friendly; this is, in fact, making the device more difficult for the user.

A while back, I added something similar to some of my code. One of my responsibilities is to write/maintain some DevOps tools that are used to deploy updates to various servers. Deployments can be pretty difficult, so I made this tool as easy to use as possible. I made it so easy, in fact, that people would accidentally deploy to the wrong server. Like, deploying to a production server in the middle of the day. Uh-oh!

My first fix for this was to make the user type the name of the deployment target that they had just selected. But even this was not enough, because people would blindly type in the name without thinking about it. But, based on a consistent server naming convention, I can tell whether the deployment target is a production server or not. When I detect this happening, I put up yet another dialog in front of the user:

Dialog box: Slow down pardner! It looks like you are deploying to production! If this is really what you meant to do, enter "deploy to production" into the box below.

This serves a purpose similar to the glass over the fire alarm: it forces the user to slow down and consider what they are doing. And because this is an internal tool, I get to have a little more fun with the verbiage. :)


  1. I have always thought these things should have a cool name, but as far as I can tell they don’t have one. 

  2. I’m not sure if this actually exists or if it is just from the movies. My attempts to google it mainly turned up photos of movie props. 

  3. I’ve always thought this is a little strange. Like, “hey we’ve got an emergency here”, “I know what we should do! Let’s put some broken glass on the ground!” 


Introducing Everytime

Warning: I wrote this blog in 2019. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

Time zones are hard. Everytime makes them easy!

Everytime sits in your system tray, and it shows the current time in as many time zones as you want. Get it on GitHub

Everytime screencap


Introducing Chord-o-matic

Warning: I wrote this blog in 2018. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

I’ve now released what is quite possibly my most ambitious side project, the Chord-o-matic Chord Player:

Chord-o-matic screenshot

This is an app that lets you select the notes that to play on a fretboard, and it tells you possible names for the chord, and why it gave the chord that name. It also lets you hear what the chord will sound like.

My reasons for writing this app come from some frustrations that I have trying to adapt music for guitar. At church, I play guitar for the kids’ choir about every other month, and the music I have to work with is never actually written for guitar. So I start with sheet music that is intended for piano and singing. The problem is I read sheet music at a first grade level. Whereas someone more knowledgeable/experienced than me can just look at the music and say “G, D7, C, G, Am, G7, G” or whatever, I take several hours to get to that point. Usually I start with the sheet music, write down the name of each note, then go back and figure out what chord is being formed by the notes played at that moment. Then I figure out where is the best place to put the capo to play the song more easily.

One tool I found that helped me with this is the JamPlay Guitar Chord Finder, and if you look at that you will see that my app is heavily inspired it. I basically did an HTML5 rewrite of the app. There were a few things that bugged me about their app, and so I set out to change them:

  1. JamPlay uses Flash, which is quickly going extinct as browser manufacturers drop support for it. I wanted something written in HTML5.
  2. I needed the option to add a capo, and to alter tuning (i.e. down half step).
  3. I needed the ability to change the guitar tuning, or even to change the type of instrument (guitar, ukulele, etc.)

Upon setting out, there were two problems I would need to solve:

  1. The front-end to render the interactive guitar.
  2. The back-end1 to take a set of pitches and return the possible names of the fingered chord.

I expecteded that the first task would be the most difficult, especially considering my UI skills are not the greatest. But in actuality, I think I spent much more time spinning my wheels on the chord naming task. I assumed that there was some well-defined algorithm which took a set of pitches and returned chord names, and that all I would have to do is open the Wikipedia page or something and port the pseudocode to Javascript. As it turns out, there’s a lot of variation in chord names once you get out of the common chords (majors, minors, and sevenths). Different people have different reasonable interpretations, and many of the established names seem to actively work against any kind of algorithm2. So what I ended up with is a bunch of spaghetti code that I hope to go back to and clean up later, to the extent that it is even possible. One resource that I found extremely helpful for this is the ScalesChords Chord Namer, which lets you select a set of notes in a chord, and it generates possible names for that chord. And, most importantly, it tells you why it generated that particular name. All said and done, I think I learned as much music theory in the past few months as I have in the entire two decades I’ve been playing guitar.


  1. Technically, it’s all front-end, but this is the part that’s pure algorithm. 

  2. For example, you might think a seventh chord is a chord with a seventh in it, but it’s actually one with a flat seventh. A chord with a seventh is called a major seventh. Unless the fifth is flat and you have a minor third (diminished chord), to get a dim7 chord you take a diminished chord and add a double-flat seventh (i.e. sixth) instead of a flat seventh like you do with any other chord. The kind of mess that results in spaghetti code no matter how hard you try. 


Negativity

Warning: I wrote this blog in 2017. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

Earlier today I tweeted:

I have wasted too many hours of my life debating whether to write "if(somearray.length == 0)" or "if(somearray.length <= 0)". I mean, I know .length could never return a negative... but what if it does???

I want to elaborate on this using more than 140 280 characters. The situation where I tend to do this is when I come upon code like this:

  function processStuff(stuff) {
    if(stuff.length > 0) {
      //this is basically the whole function
      doStuff();
      //seems wasteful to indent this stuff
      doMoreStuff();
      //maybe another 100 lines of code
      return whatever;
    }
    else {
      //throw an exception or return an error message or print an error message or something like that
    }
  }

Two problems:

  1. The majority of the code is indented twice.
  2. The else clause is very far from the corresponding if clause.

So the solution is to refactor so that the current else clause is at the top

  function processStuff(stuff) {
    if(stuff.length == 0) {
      //throw an exception or return an error message or print an error message or something like that
    }

    //this is basically the whole function
    doStuff();
    //look it doesn't have an extra unnecessary level of indention now!
    doMoreStuff();
    //maybe another 100 lines of code
    return whatever;
  }

The problem now is that the before and after this refactoring is not strictly identical. The negation of stuff.length > 0 is stuff.length <= 0, not stuff.length == 0. The first code would have gone through the error condition if stuff.length is negative, but the refactored code won’t.

Now, I know that the length of an array will never return a negative in any programming language I’ve ever heard of. But, like I tweeted, what if it does?!

I want to ensure that I don’t break anything by refactoring. And it’s also not going to hurt anything if I write stuff.length <= 0. But then I wonder what the next person to see my code will think. “Is there some reason this idiot1 thought array length could be negative?”

And I go through this thought process everytime I encounter this situation, mentally debating the pros and cons, instead of just accepting that it doesn’t matter and moving on.


  1. Believe me, the last programmer was always an idiot. Especially when it was me. 


BigFraction now on Maven Central

Warning: I wrote this blog in 2017. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

My BigFraction Java library is now available on Maven Central, free to be used in any Java project built using Maven or any compatible build tool (Gradle, Ivy, etc.).

This project is something I started on my own nearly a decade ago, for my own use in solving Project Euler problems. About three years ago I put it on GitHub. Much to my surprise, several people found it and started using it. But the only way to use it was to check out the source code and build it yourself—not very practical to the way most Java projects are built today. I wanted to get the library on Maven central about a year ago, but I procrastinated for a long time thinking it would be a difficult process. Turns out, it is relatively easy, and completely free, to get your open source library hosted and indexed.

If you run into any issues, please report them on GitHub.


Half A Lifetime Ago

Warning: I wrote this blog in 2017. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

One of the cool things about being a software developer is this: if something doesn’t exist, and you want it to exist, you can make it exist. Today I was thinking about the fact that almost half of my life has been since high school. Then I started to wonder when exactly half a lifetime ago was.

This is easy enough to solve with one line of javascript:

new Date(Date.now()/2 + new Date(birthYear, birthMonth-1, birthDay)/2)

This seemed like the kind of thing that normal people would be interested, so I spent a little time this afternoon making a workable (but still pretty ugly) UI around this one line of javascript: tilde.ampersand.space/half-a-lifetime/

The code is also on GitHub: github.com/kiprobinson/halfALifetime


You Won't Believe How Many Hello World Programs Can Fit On A T-Shirt!

Warning: I wrote this blog in 2016. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

I’ve designed a t-shirt that is especially for programmers. It contains the simple hello world application, written in forty-seven different programming languages.

Click or Tap or Otherwise Activate This Hyperlink to Buy!

T-Shirt with Hello World in Forty-Seven Languages

Below is the “key”, for anyone interested. A few of these aren’t technically programming languages (like binary, QR), and a few are just frameworks within another language (like Angular, Swing). I’ve ordered one of the shirts myself and it looks pretty nice—I had to make sure of that before I offered it for sale. I’ll probably work on a version that works against a dark background, when I get the time.

Binary

0110100001100101011011000110110001101111001000000111011101101111011100100110110001100100

Java

public class Main {
  public static void main(String[] args) {
    System.out.print("hello world");
  }
}

AngularJS

<input type="text" ng-model="sometext" />
<h1>hello {{ sometext }}</h1>

Scala

object HelloWorld extends App {
  println("hello world")
}

XSLT

<?xml version="1.0"?>
<greeting>hello world</greeting>

Fortran

program hello
  print *, "hello world"
end program hello

Haskell

main = putStrLn "hello world"

8086 Assembler

.model small
.stack 100h
.data
msg  db  'hello world$'
.code
start:
  mov  ah, 09h
  lea  dx, msg
  int  21h
  mov  ax, 4C00h
  int  21h
end start

php

<?php echo 'hello world' ?>

Go

package main
import "fmt"
func main() {
  fmt.Println("hello world")
}

Lisp

(print "hello world")

Flex (MXML)

<?xml version="1.0"?>
<Application xmlns="http://www.adobe.com/2006/mxml">
  <Label text="hello world" />
</Application>

Hex

68 65 6c 6c 6f 20 77 6f 72 6c 64

ActionScript

createTextField("hello", 0, 0, 0, 100, 100);
hello.text = "hello world"

.bat

@echo off
echo hello world

Perl/Python/Swift

print "hello world";

Cobol

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
  DISPLAY 'hello world'.
  STOP RUN.

Visual Basic

Imports System
Public Module modmain
   Sub Main()
     Console.WriteLine ("hello world")
   End Sub
End Module

Prolog

write('hello world'),nl.

HTML

<html><body>
hello world
</body></html>

R

state start:
  pstr("hello world\n");
  halt;

lolcode

HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE

SQL

SELECT 'hello world' AS hello

Java (Swing)

javax.swing.JOptionPane.showMessageDialog(null, "hello world");

Scheme

(let ((hello-world (lambda() (display "hello world")(newline))))
  (hello-world))

C

#include <cstdio>
int main() {
   puts("hello world");
}

Ruby

puts 'hello world'

Pascal

program HelloWorld;
begin
  writeln('hello world');
end.

Mathematica

Print["hello world"]

Basic

10 PRINT "hello world"

ColdFusion

<cfoutput>hello world</cfoutput>

jQuery

$(function(){$('body').text('hello world');});

Brainf***

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

Whitespace

···→··→ ···↲
→   ↲
·····→  →   ··→ ·→  ↲
→   ↲
·····→  →   ·→  →   ··↲
→   ↲
·····→  →   ·→  →   ··↲
→   ↲
·····→  →   ·→  →   →   →   ↲
→   ↲
·····→  ·→  →   ··↲
→   ↲
·····→  ·····↲
→   ↲
·····→  →   →   ·→  →   →   ↲
→   ↲
·····→  →   ·→  →   →   →   ↲
→   ↲
·····→  →   →   ··→ ·↲
→   ↲
·····→  →   ·→  →   ··↲
→   ↲
·····→  →   ··→ ··↲
→   ↲
·····→  ····→   ↲
→   ↲
··↲
↲
↲

Smalltalk

Transcript show: 'hello world'.

C Sharp

public class Hello {
  public static void Main() {
    System.Console.WriteLine("hello world");
  }
}

Lua

#!/usr/bin/lua
print("hello world")

Javascript

document.write('hello world');

ASP.net

<% HelloWorldLabel.Text = "hello world"; %>
<html><body>
<asp:Label runat="server" id="HelloWorldLabel"></asp:Label>
</body></html>

Piet

Hello World program in Piet

Objective C

#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
  NSLog (@"hello world");
  return 0;
}

Ada

with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
begin
  Put_Line("hello world");
end Hello;

QR

QR Code encoding the text Hello World

c++

#include <iostream>
int main() {
  cout << "hello world" << endl;
}

MATLAB

disp('hello world');

No Excuse for No Security

Warning: I wrote this blog in 2016. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

A long, long time ago, in 2015, securing a website was an expensive, tedious process. Then along came Let’s Encrypt, a non-profit certificate authority that provides SSL certificates completely for free. Real (not-self-signed) certificates that get a green padlock in your address bar. And they make the process super easy and automated. If you’re on shared hosting it might be a little harder, but your host should be able to implement it fairly easily. Dreamhost made it basically one click for me. You should read that post it’s pretty good. One thing to note is that Chrome and Firefox both have plans to start marking http connections as insecure, rather than default neutral status (the current status quo).


JSON Formatter

Warning: I wrote this blog in 2016. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

In the last two days I’ve written a new, simple JSON Formatter. This is a very simple tool that allows you to prettify/uglify JSON data. It is basically just a textarea tied to the JSON.stringify() method that is built-in on every modern browser.

I created this after being frustrated with other online formatters that don’t work well for large data because they require the data to be submitted to a server for validation. My tool runs entirely client side. Live preview here.

You can even run it without an internet connection. Tool is written entirely with Vanilla JS, a hot new Javascript framework that is all the rage these days.

View Project on GitHub.


y2k16 bug

Warning: I wrote this blog in 2016. That is a long time ago, especially on the internet. My opinions may have changed since then. Technological progress may have made this information completely obsolete. Proceed with caution.

This website is now in its second calendar year. Which means the code to print the copyright at the bottom of the page just went to an untested branch of code. Turns out it had a bug!

y2k16 bug on this site

I have squashed the bug. Happy New Year! :)