Throat, Git, and A Deepness In The Sky

CodeFX Weekly #7 — 17th of February 2017

Throat hurts, head does too, and I’m sneezing even though it’s 20+ °C in here and I’m well dressed (not just my usual Chivas-Regal-stained bathrobe). As you might be guessing I’m not eager to write a lot so let’s get this over with.

I send this newsletter out every Friday. Yes, as an actual email. Subscribe!

This Week

After conference week it took me some time to settle back in and start working regularly. Looking into my magic calendar I’d say that this week’s fight between discipline and distraction ended in a draw.

I worked a lot on SitePoint and finally managed to catch up with all the great proposals. There will be some neat publications over the next weeks. This week we continued quick-tipping (race conditions) and looking at Lombok (beyond POJOs).

Then we changed our newsletter format and for the time being the editorial will be published as a regular article on SitePoint (so they won’t show up on Medium anymore, which is a little sad). I just published the first one, taking a stab at conferences and professional speakers, conjecturing (wow, that word looks wrong!) that they feed the hype cycle.

Speaking about conferences, I was talking at Frankfurter Entwicklertag on Thursday. Yet again about JUnit 5, which, I have to admit, starts boring me. Not the project but the never-changing talk covering all the basics. I did have the opportunity to talk with Matthias Merdes and Johannes Link about the project, though, which was a lot of fun!

Work on the book is a little lagging — I was planning to have edited chapters 3 to 5 according to the reviews by the end of this week but now I’m still stuck in 3. I didn’t get a review on 5 yet, though, so I’m not yet the holdup.

I also did a lot of paperwork (no more backlog, wohoo!) and published a well-received post on handling exceptions in streams. That will actually be a series — the first post explains how to repackage checked exceptions so they can be sneaked past the functional interfaces. One comment pointed me towards Durian, “Guava’s spikier (unofficial) cousin”, which I want to take a look at soon.

As you can see, I spent no time coding, which means that I have nothing to offer in that regard.

Fuck, I just now realize I still didn’t get around to finish grading the Kotlin exams! I’m all done correcting and giving points but I still need to put the grades on there and in some stupid spreadsheet.

How do you manage time for work and new learning?

I was asked this via Twitter and planned to respond today. As per lurking sickness, that ain’t gonna happen. Sorry, I hope next time.



As most people who use Git regularly, I created a couple of aliases within Git. But I also have a bash alias — I use git status a lot and decided to truncate it to g (paralleling l for ls -lah). I just read yet another Git tip article and it mentioned the status flag --short.

Wow, much better! I was missing the branch I was currently on but that can be put back in with --branch. So for about five minutes g was git status --branch --short.

Then I realized that I also quite often look at the log right after checking the status to orient myself. I already had git wat set to git log --graph --decorate --oneline -15 but why type it manually in the many many cases, where I want to see the log right after the status. And since status --short freed up some vertical screen space, I decided to include the log in g.

After some shuffling around, this is what I ended up with:

# in gitconfig
st = status --branch --short
wat = log --graph --decorate --oneline -15
# in bashrc
alias g='git st; echo ''; git wat -5'

So here’s what I get for the Jigsaw Advent Calendar (but with more colors):

$ g
## 03-services...origin/03-services
?? log
* 9ccaaff (HEAD -> 03-services, origin/03-services) Update command line to remove JIGSAW_BIN and use 'find'.
* edecd38 Use new 'requires transitive' instead of 'requires public'
* 1d61769 Update module path flag from '-mp' tp '-p'
* c274805 Create README for this section
* 8807dd0 Update script to new module structure


History Hereticism

Recently, I had to rewrite Git history. Not a little, though, not a mere rebase over the last couple of commits. No, I wanted to eradicate a particular file as if it had never existed. Why?

The Jigsaw book is written in Asciidoctor and I hacked the PDF generation process to include some more admonitions (the icons next to the text). I figured this would make it harder fore the reviewer to generate the final PDF on their machine (some command line options are required), so I decided to include it. That was not a good choice.

The tendency to have small commits and the fact that Git stores the entire file on each commit let the repo’s size grow quickly. By the time the PDF reached 10 MB, the repo had passed 500 MB. You might think that that’s not too bad. After all, I’ve already written about 30% to 40% of the book so the total size could be estimated to be maybe 2 gigs. Not too much, right?

If you indeed think that, then let me smack you over the head in the name of your high school math teacher. Because you just brought a linear extrapolation to a quadratic fight. Each line that was once written will be included in the final PDF and will get added to the repo over and over and over. Git’s way to compress/pack makes this less explosive but the overall picture remains.

I’m sure I’ve once heard that you could do something that replays every commit, executing a command before committing the changes. And indeed there is:

# replay all commits executing `rm ...` before each
git filter-branch -f --tree-filter 'rm -rf manuscript/book.pdf' HEAD
# after checking that all is in order, delete the original commits
git update-ref -d refs/original/refs/heads/master
git reflog expire --expire=now --all
git gc --prune=now

I have to admit I was a little fearful but it looks like it worked out. If you ever think about, I don’t know, retroactively applying a code style for example (yes, I’m looking at you — you know who you are!), this would be an option that does not change all of your files in a single commit.


The rest of the newsletter talks about The Lego Batman Movie, 10 Cloverfield Lane, and A Deepness In The Sky. While I do not spoiler the stories, I do give away on some of the background that develops throughout the narratives.

The Lego Batman Movie

Usually I’m not one for shallow entertainment but after a stressful week and a busy Saturday in Helsinki, I decided to relax and watch something, well, shallow. The Lego Batman Movie has gotten some good reviews and after my recent resurgence of Lego love I decided to give it a go. That was stupid.

While superficially funny and with a seemingly witty plot (Joker and Batman have a hate relationship that Batman, being a loner, does not not acknowledge) the effect wore of quickly. After the joke with the shark repellent, about 20 minutes in, there was nothing really funny left. Another half hour later I wondered whether my reader’s light would disturb the people around me but didn’t have the guts to try it out. I still sat through the whole thing but was non-plussed.

After coming back to the hotel I was starved for good entertainment and decided to finally watch 10 Cloverfield Lane. Great movie! Best line is near the end when the heroine sees something truly outlandish and perfectly captures the viewers astonishment with a flat remark of “Oh, come on!” (You have to see it to get it.)

A Deepness In The Sky

The other day I finished A Deepness in the Sky, the second book of Vernor Vinge’s Zones of Thought series. If you’re at all interested in Science Fiction, you must read this book! (Its a prequel to the others and self-contained so you can read just this one.) There are a number of awesome ideas in there.

Legacy Code

One of them, a fairly minor one actually but interesting to programmers, has to do with legacy code (of all things). Presumably, at some point computer hardware reaches a physical limit and form there on no longer undergoes fundamental changes. As a consequence there is no need to constantly rewrite existing software.

Now, consider a fleet with dozens of space ships, each a couple of kilometers long and millions of tonnes heavy, full with all kinds of automation. Just imagine how much software must run in such a fleet. Of course it needs constant adaptation to changing requirements but because the hardware never undergoes fundamental changes, each new thing is built on top of what was there before.

The character literally spends a decade or so familiarizing himself with a system built over the course of 8'000 years! Yes, eight fucking thousand years of legacy code! The typical developer cringes when code is older than 8'000 hours.

The Human Condition

Another idea I really liked was two-pronged.

One the one side stood humanity’s realization that no matter what they tried, every planetary system they inhabited would sooner or later face a catastrophic event that would set the poor souls back to the middle ages. It could be war, it could be disease, it could be failure of automation that grew eternally more complex until it eventually failed — for whatever reason, as the narrator would’ve put it, on a long enough time line the survival rate for everyone drops to zero.

This was such a constant that an entire branch of science evolved around how civilizations could bounce back from these (near-)extinction events that happen every couple thousand years.

On the other hand stood the limitations of interstellar fleets. While they lacked the potential to evolve themselves into extinction, thus evading this destructive cycle, they were never technically advanced enough to be truly self-sufficient. They could stay out between the stars for hundreds of years but eventually they needed a harbor to patch up their ships.

The tension between these two poles plays an important role in the story and I found it fascinating.

Interstellar Flights

A great strength of the book is how unexcitedly it describes interstellar flights. No faster then light bullshit, no wormholes, no nothing.

Fleets travel with 0.3c and at any given time most of the crew lies in cold sleep (which stops aging), with only a small round-robin watch being awake for the hundreds of years it takes to travel between the stars. At the same time medical advancements extended human lifetime to two to three hundred years, which makes it bearable to spend 20 or so years of subjective time on a profitable trade route.

The book describes what that means for the societies that fare between the stares and explores some interesting ideas. The scope on which individuals and societies plan takes a whole different level.

I want to finish with another nice detail: Anything shorter than tens of years is measured in seconds, ksecs and msecs to be precise. Some quick arithmetics tell you that a kilosecond is about 20 minutes and a megasecond about ten days. It’s fascinating how this slowly grows on you and by the middle of the book you developed an intuition for how much time these units span.

Great, now I’m all ecstatic for SciFi! Ok, don’t tell my wife (she’s out with colleagues tonight) because we’re supposed to watch this together but I think I’m gonna accidentally double click on this The.Expanse.S02E01.1080p.WEB-DL.DD5.1.H264.mkv file I have lying around here. Oops.

so long … Nicolai

PS: No shots this time.

PPS: Don’t forget to subscribe! :)