This Week I Learned (June 2019 — w1)

Keefer Rourke
3 min readJun 14, 2019

--

Following up from this post, I think that posting weekly is going to be a good frequency for this exercise. Months aren’t divided evenly into weeks though (sigh), and I don’t want to be posting June/July updates, so “weekly” will be approximate.

Without further ado:
This is mostly stuff that I learned at work. Specifically stuff about Kotlin and the JVM. That said, I designate weekends as relaxation stations, so this blog post starts with absolutely nothing technical.

2019/06/01: 🌳 Growing bonsai trees is an artform. 🌳

Also. A bonsai is not a kind of tree as I had previously thought. You can miniaturize any tree and call it a bonsai!

Juniper bonsai tree, by Bjorn Bjorholm. See more here.

The white parts of the tree above were deliberated killed for artistic impact, while still keeping the tree healthy and alive. Miniature arborists, you have inspired me with art I have never known before!

2019/06/02: 🎲 Tabletop RPGs > online RPGs. 🎲

I played a tabletop RPG for the first time in a long time, and had more fun than I have had playing videogames in like forever.

⚠️ Complexity on a tabletop does not compare to complexity on a computer.

The mental overhead of managing choices and cards and physical board pieces seems to be way higher. Why I wonder! Maybe I need to spend less time in front of screens and sharpen my real-life processing abilities 🤷‍♂

2019/06/03: ⏰ You cannot lateinit primitives in Kotlin. ⏰

class Foo {
lateinit var value : Int // Not allowed!
}

I found this to be really annoying and weird, especially since Kotlin appears to be conflating Java primitives with their object-boxed sisters. Kotlin’s Int is a “primitive” but it maps to Java’s Integer object!

This forces me to make a choice between these ugly options:

var value: Int? = null // Make it nullable?
var value: Int = 0 // Choose a sentinal value?

2019/06/04: ☕️ Nested Annotations are a thing in Java. ☕️

@NestingAnnotation({
@Nested(foo=”bar”),
@Nested(foo=”baz”)
})

2019/06/05: ❌ Kotlin does not have checked exceptions. ❌

After a month of working in the language, I’m surprised I didn’t learn this sooner.

This can cause some weirdness if you find yourself calling Kotlin code from Java because you won’t be able to catch what you expect.

This is a workaround as suggested by Kotlin docs:

@Throws(IOException::class)
fun write() {

if (error) throw IOException(…)

}

This makes me unhappy because of the redundancy!
But I also hate checked exceptions!

2019/06/06: 🧘‍♂️ I am happier when I meditate regularly. ️🧘‍♂️

I’d fallen out of the habit over my last school term, probably because I was stressed over midterms and exams. Was I really too stressed to do a calming activity? That’s totally backwards!! I’m getting back into the habit with Headspace. I’d also totally recommend mindfulness to my friends.

(This isn’t an endorsement of Headspace in particular!! I just find guided/recorded sessions to be most helpful, since meditating in silence is really really really really really really difficult.)

2019/06/07: 👨‍💻 Java inner classes are… weird. 👨‍💻

Java originally did not support inner classes, so they were sort of hacked into the compiler so as not to need to make any changes to the JVM.

E.g. If you compile something uninteresting like this:

public class Shell { public class Core { } }

You get Shell.class and Shell$Core.class which, when decompiled, look like this:

// Shell.class
public class Shell { public class Core { } }
// Shell$Core.class
public class Shell$Core {
// This <init> is marked synthetic in the bytecode instructions.
public Shell$Core(Shell var1) {
this.this$0 = var1
}
}

The compiler generates a constructor for the inner class that takes an instance of the enclosing class. Neat!

Stay tuned for the next post!

--

--

Keefer Rourke

Software developer and digital rights activist. Ethical tech makes me happy. https://krourke.org