All posts by erk

I love writing, computers, puns... and can sometimes be spiritual, or mindful.

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?

No?

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

Don’t believe me?

Good!

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",
  streamBytes);
long totalBytes = 0;

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

  while ((read = is.read(buffer)) > 0) {
    totalBytes += read;   

    // do something with bytes
    // ...

    // increase progressbar
    progressBar.step(read);
  }

  // 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

The National Nuclear Arms Association

M388_Davy_Crockett_mounted_on_Jeep_c1961Having carefully scrutinized all twenty-seven words of the second amendment to the U.S. Constitution I see nothing that would prevent the introduction of a National Nuclear Arms Association that would fiercely protect the American people’s right to arm themselves with nukes!

After all. There are Russians and North Koreans in the world!

Alas, District of Columbia v. Heller states:

“Like most rights, the Second Amendment right is not unlimited. It is not a right to keep and carry any weapon whatsoever in any manner whatsoever and for whatever purpose”

You might have convinced me to become an American if it hadn’t been for your totally wussy amendment interpretations.

Man up!


Image: By U.S. Navy – U.S. Navy All Hands magazine May 1961, p. 21., Public Domain, Link

Date formats

Since it seems popular to create and use illogical date formats, here are some suggestions:

  • October 22 15 2018 CE 10
  • Monday 10 15 2018 CE 22 October
  • 22 2018 15 Monday CE October 10
  • 10 Monday 22 15 October 2018 CE
  • Monday 2018 CE October 15 22:10
  • 15 October 22 Monday CE 10 2018
  • 1 10 10 15 22 2018 CE

What’s the date? Well, of course, 2018-10-15 at 22:10, which happens to be (happened to be?) a Monday.