Category Archives: Computers and Internet

Posts on computer science and the web, rants about OS:es, Window Managers, Platforms for almost publishing content on the web, and the like.

How about that temporal programming?

Did you read my article on temporal programming?

Cool, huh?

Did you manage to make temporal programming in Java work?


You need a quantum computer, of course, and Java 15…

Don’t believe me?


After all, yesterdays was April 1st!*


* Ok. Come to think of it, with time zones and all… I am guessing the post was technically published on mars 31st in, e.g. the Americas… :÷|

Temporal Programming

Have you ever wanted to know information beforehand?

With temporal programming, you can!

For instance, when reading an input stream, you want to show a progress bar for how far along you’ve come. But, in order to know what percentage of the stream has been processed, you need to know how many bytes it contains.

Some streams are based on files so you can use the file to figure out the size. The same goes for some streams from web servers. But then there are other streams where the size isn’t known beforehand.

Temporal programming was invented for them.

Here’s an example:

temporal long streamBytes;
final ProgressBar progressBar =
  new ProgressBar("Reading stream",
long totalBytes = 0;

try (final InputStream is = ...) {
  byte[] buffer = new byte[1024];
  int read;

  while ((read = > 0) {
    totalBytes += read;   

    // do something with bytes
    // ...

    // increase progressbar

  // set the max of the progressBar
  streamBytes = totalBytes;

All the magic is in the temporal keyword… much like the native keyword, it makes “stuff” happen behind the curtain…

At first, the value of the temporal variable streamBytes isn’t known, and in normal cases, this would create a compile error. However, the value of streamBytes is set at the end of the program, and can then be used in the beginning much as if the variable had been set from the start.

Pretty cool!

Of course, this example with a progress bar and a stream is much less exciting than an example with a stock ticker, for instance…

There’s money to make there!

Header image: By fdecomiteTunnels of Time, CC BY 2.0, Link

Dark Mode Fail

I know dark mode is all the rage. A must-have for the trend-sensitive software developer. However, the reason to have dark mode is to save people’s eyes in dark rooms… not blast them to pieces.

Take a look at Microsoft Office’s dark mode fail in a dark room, I dare you:

Microsoft Office Dark Mode Fail

Of course, dark mode done right will have its issues as well… Try to pick out the orange colored comment in Scrivener’s dark mode… if you can:

Scrivener Dark Mode Comments

Yeah, no. Those aren’t the names of the colors 😀 and it’s easy to pick the right one when you have the others for contrast, but wait till you open a document with comments in one color… is it yellow, orange, red? Ummm…

But at least Scrivener won’t leave white spots dancing in front of your eyes for the rest of the evening… so that’s always something…

I for one have learned not to use Mac OS’s Mail app to send customer mail when in dark mode. Those CCed names are pretty much hidden and all of a sudden internal e-mails become external and you find yourself wishing you’d been better at keeping your promise to never say (or write) anything about someone you wouldn’t say to them.

The extremely annoying text editor bug

This bug exists in all text editors I tried so far, with the exception of iWorks Pages… (they have their own set of issues anyway…)

To recreate the bug:

  1. Type text in the text editor really fast. You may even type random text if you’re not such a fast typer…
  2. Immediately after, start deleting with backspace
  3. Still moving quickly, press ctrl-Z (or command-Z on a Mac) for undo
  4. You thought the editor would undo your deletes, right? Hah!

I’ve been kicked by this nasty thing so many times. I type something. ADHD kicks in and I change my mind half way through, starts deleting, changes my mind again and presses cmd-Z. And it undoes everything instead of just the deletes.

Word does this, Scrivner does this… every simple text editor does… apparently 99% of text editor users does the index finger waltz?

One thing to avoid when using Objects. requireNonNull in Java 8

Consider the following singleton:

public enum MyVeryImportantSingleton {

  private String a;
  private String b;

  public void set(String a, String b) {
    this.a = Objects.requireNonNull(a);
    this.b = Objects.requireNonNull(b);

If it would be called in the following manner:

try {
    .set("Hello world", null);
catch (Throwable t) {
  ...all sorts of recovery operations
  ...leaving the system running

MyVeryImportantSingleton‘s a-field is set, but the b-field is left in its previous state. This, of course, could turn into really bad news.

The right way to implement set() would be:

public void set(String a, String b) {
this.a = a;
this.b = b;

This is also a great praxis for all form of input error checking. It should first be finished, and then the object state can be updated once all input is ok.

You never know when your method will be called from inside a catch-block by a programmer that, incorrectly assumes the object state is okay even if an exception was thrown.