Adding an Extra Indirection to Enable Code Reloading in Clojure/Java Interop Code

February 14, 2021

One of the killer features of Clojure is its ability to reload code and incrementally develop in a running environment. Another strength of Clojure/Clojure script is that it is deliberately a hosted language, leveraging the broader Java/Javascript ecosystem for libraries, frameworks, etc.

However, the dynamic code reloading and interacting with Java libraries can create some friction. Adding another layer of indirection sometimes reduces that friction. Let’s look at an example. Let’s assume we have a large Java library to which you provide a callback functions/object. Like an HTTP-server, network- or some other library. Easy, you implement the interface of the library. Note that the library instance is preserved with defonce.

Java and Clojure Best Friends Forever
Figure 1. Java and Clojure Best Friends Forever
Continue reading →

C# Updates for the Absent C# Developer (C# 6.0 and newer overview)

December 5, 2020

This post is part of C# Advent Calendar 2020.

Update 6. December 2020: Some good small discussion on

It has been a while since I actively developed in C#. I mostly worked with C# and .NET during the 3.0 to 4.5 days and I did async/await work very early on, so I skip over that as well. After a job change, I didn’t touch C# for actual work. I mostly just watched the development from the sidelines via news. Today, I take a short look at some features. I will skip a lot and just add some of my highlights tour.

C# grew up
Figure 1. C# All Grown Up
Continue reading → IP Range Is All Loopback

September 26, 2020

That the IP is a loopback/localhost is widely known. It is used daily by many developers for testing of programs talking over the network. However, did you know that the whole IP range are loopback addresses? You have a few million IP addresses reserved on each machine to talk to itself.

Millions of loopback addresses
Figure 1. Millions of IP addresses should be enough for talking to yourself
Continue reading →

Time is Complicated: java.time

July 12, 2020

Time is complicated, really complicated. We have historically grown calendar systems, historical units, timezones, limelight savings times, etc. On top of that, we have precise atomic clocks and astronomical time definitions drifting apart and need periodical corrections, like with leap seconds.

Agreeing On Time
Figure 1. Agreeing On Time
Continue reading →

Time Does Not Flow Evenly

May 31, 2020

You are working on some system and you need some kind of timestamp in milli- or nanoseconds. Nothing easier than that. In Unix you might use clock_gettime and in Java System.currentTimeMillis() and of your go.

// Forgive me my C, I probably got things wrong =)
#include <sys/time.h>
#include <stdint.h>

int64_t time_stamp_nanos(){
    struct timespec current;
    clock_gettime(CLOCK_REALTIME, &current);
    return current.tv_sec * 1000000000 + current.tv_nsec;
Continue reading →