Blog Post Archive

Things I’ve written over the years. Explore blog posts by date below or by tags.

Give Me Smarter Objects

A coding exercise I do once in a while is writing Battleship. It’s a fun little exercise, comes with a slew of interesting decisions, and every once in a while I do this exercise with a candidate as part of the interview process. It’s always exciting to see what other developers come up with. Today I was doing the exercise and I contemplated on the primitive obsession code smell that always seems to creep into my code and saw a beautiful way to apply the extract class refactoring that very succinctly shows how nice object oriented programming can be.

null, Software Design, and Scala’s Option

For the past year or so I’ve been writing a lot of Scala and fallen in love with its Option type and how it allows me to avoid nulls. I reflected on null, why they are bad, and how optional types allow you to write more expressive code.

What is null?

Most programming languages have the concept of null (or nil) that represents the absence of a given value or object. At it’s surface the absence of a value probably just translates into a pointer of value 0x0 or in languages that do not zero variables, a pointer anywhere into the memory. But aside from the implementation details the more interesting question is how null fits into a language’s type system.

A New Theme

After toying around with the really nice Temple theme I decided there was no better way to spend my afternoon than building my own, new theme for my blog.

If you haven’t notice, I recently switched my blog from Jekyll to Hugo. The upgrade path from the really old version of Jekyll to the latest version wasn’t quite working as expected, and having to mess around with Gemfiles isn’t really something I enjoy. Hugo on the other hand is written in Go and comes as a single, standalone binary. That seemed really appealing and I’ve had good experiences when trying to build a little photo gallery builder with it a while ago before Hugo had actual photo support. Moving the content over from the Jekyll frontmatter to the Hugo frontmatter was done easy enough, I even moved some of the good posts from my really old blog on here. I was almost perfectly happy, exception for the theme. The Temple theme is nice, but it wasn’t quite what I wanted. So this weekend I built my own (yeah, you’re looking at it).

Inspiration and Action

I’m currently re-reading Growing Object-Oriented Software, Guided by Tests, and this quote really spoke to me:

We should be taught not to wait for inspiration to start a thing. Action always generates inspiration. Inspiration seldom generates action.

– Frank Tibolt

I think of myself as a perfectionist, the kind of person that hates to produce anything short of flawless. And while this is great quality to have because it drives me to improve and progress, it’s also incredibly crippling and frustrating. I’ve often noticed that while I had great ideas, I would often fail to implement them because I would try to over engineer my approach so it would solve everything perfectly. Obviously, many of these ideas and projects never went anywhere. But then on the contrary, ideas where I just started hacking something together often went much further and produced something usable and new.

On Wasted Time

Recently I’ve been feeling… unaccomplished. Despite all my achievements, acquired skills, and successes I’ve had a thought gnawing at the back of my mind. I realized, after looking at my extensive list of side and toy projects, that none of them are making any progress. In some of them I invested lots of time, others are just ideas, barely sketches. But they all have in common that I grew tired of working on them. Either because after a day at work my brain is tired, or because other things are taking precedence. I’ve moved into a house that requires constant upkeep. Things break or wear out and before your know it you’ve spent an afternoon fixing something. And then I’ve finally picked up a regular workout routine. Generally I’m proud of that, and because these things take time, I had no time for my side projects. Or at least that’s what I thought and told myself.

Google Appengine, Go, and Vendoring

I’m working on a small app running on Google App engine using Go and upgraded to the latest version of the GAE SDK. The latest version uses Go 1.6 instead of 1.4 like the older version I had. Upgrading was mostly straightforward, but once I started using vendoring I got strange build errors like this:

2016/05/22 13:26:47 go-app-builder: Failed parsing input: parser: bad import "syscall" in vendor/golang.org/x/net/ipv4/dgramopt_posix.go

I got different variations of this, but all came down to the same problem: some code was importing packages that GAE doesn’t want you tu use. Sadly these errors don’t show up during normal goapp build or goapp test cycles, but only when you want to deploy or start a local devserver.

Writing an Operating System - Environment Setup

I’ve been reading The little book about OS development and wiki.osdev.org and took some notes along the line. Here’s what I wrote on environment setup.

Environment setup

You’ll need a cross compile toolchain consisting of GNU Binutils and gcc. The osdev wiki has a great page on setting up a cross compilation toolchain.

It took me a few times because I didn’t read the instructions properly. It is important to unpack the sources for binutils and gcc and have separate build directories, gcc-4.2 and gcc-build for example. Then, for building gcc, make sure the newly built binutils are on your path.

gorename and invalid expression

This took me longer to figure out than I care to admit, so here’s the solution.

The issue comes up when trying to use gorename:

$ gorename -from "github.com/ilikeorangutans/foo".MyType -to 'MyBetterType'
gorename: -from "github.com/ilikeorangutans/foo.MyType": invalid expression

Even though the from query looks normal, gorename just refuses to work. However the issue is not so much with gorename but rahter my shell, zsh. Turns out properly escaping your from query, fixes the issue:

$ gorename -from '"github.com/ilikeorangutans/foo".MyType' -to 'MyBetterType'
Renamed 15 occurrences in 5 files in 1 package.

Notice the single quotes around the entire from parameter.

Using Golang and Graphviz to Visualize Complex Grails Applications

At work we are maintaining several large and complex grails applications. In order to improve stability and reliability, we’re trying to increase test coverage. But as with all projects, time and resources are limited. In order to get a better understanding of what parts of the application are more important than others, I decided to use Graphviz to help me get a better overview of our applications.

Meet Graphviz

I discovered my love for the dot language when I used it years ago to analyze template hierarchies in a proprietary CMS system I worked on. In a nutshell, it lets you specify a graph with nodes and edges plus some extra attributes for labels, shapes etc. It’s really a concise little language:

ilikeorangutans

Jakob Külzer’s personal blog