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.

The Digital Direct Democrazy System

The Digital Direct Democrazy System: Welcome to the Digital Direct Democrazy System. We will now ask a number of questions that will be used to determine your political profile.

The user answers the questions.

The Digital Direct Democrazy System: Thank you! We have determined that you are a raving Nazi and will immediately start building the concentration camps…

The User: Hey? Wait! Those were just my personal opinions!

The Digital Direct Democrazy System: Please be patient. This could take a little while…

The User: Hello?! WTF?!

The Digital Direct Democrazy System: Please be patient. This could take a little while…

The User: Whatever…

Java 8 – A Filter By Any Other Name Would Probably Smell Sweeter

I’m thinking the choice of name for the filter function in Java 8 steams was a really poor one.

I mean, what is a filter? Something that keeps things out, or something that catches the things we want?

Yes.

Dictionary.com has several definitions, from “any of various analogous devices, as for removing dust from air or impurities from tobacco smoke, or for eliminating certain kinds of light rays” to “to remove by the action of a filter”.

An air filter, we hope, will keep harmful airborne particles away. We also hope a filter in a sanitation plant will do similar work. (We should all know that the filter on a cigarette is only there for the sales pitch…)

I’m thinking gold-digging would use filters with the opposite purpose, but you pan for gold, don’t usually filter… I guess…

The guy that came up with the name “filter” might be a physicist and using this dictionary.com definition of filter: “Electronics, Physics. a circuit or device that passes certain frequencies and blocks others.”

But thankfully that’s not how the Streams-documentation suggests the filter-function should work…

Or the name was inspired by coffee filters? … no, wait, that’s very wrong!

Regardless…

Using the name “filter” for the function that will decide, like the gold diggers filter (that doesn’t really exist… ok, a physicist’s “circuit or device”… 😐 ) what to keep, seems very unintuitive to me, and I suspect it requires that you learn that in Javaspeak, “filter” means only one of the two possible definitions of filter (of which the “wrong” one seems über quasi… or like you take your coffee the very caffeinated way… with a spoon…)

I suggest adding “include” and “exclude” instead and then one of them (or both) can redirect to filter behind the scenes. (I’m inspired by Rsync…)

I’m thinking it should be quite hard to misunderstand those two. (And very hard to think using “filter” is a better choice)…

Writing programs in programming languages is, just as when you write in any other language, definitely communication with computers, other programmers and yourself in six months when you’ve forgotten what the hell the program code you’re staring at was supposed to do… And poor communication is the root of all evil and the end of all marriages… or so I’ve heard… 😀

I’m certain there are bugs out there right at this moment because of this language choice. (I’ll let you know how many of them are mine as I find them…)

(And by the way, the thing that catches the things you want is called a net, not a filter… maybe filter should be renamed to “net”? Since “catch” already is a keyword… :P)

Java Lambda Humor

I was experimenting with Lambdas in Java on IntelliJ IDEA… they have a sense of humor.

I was wondering how simple a lambda could get so…

final Supplier<Double> supplier = () -> 1d;
double value = supplier.get();

A lambda (supplier) that produces a number (1) from no input. Pretty simple. What will happen to the code if I refactor supplier to make it an inline expression?

double value = ((Supplier<Double>) () -> 1d).get();

Well… that’s kind of in line with casting and such. Not that nice looking… However, now the IDE tells me I can make a simplification… “Replace method call on lambda with lambda body…” let’s try that:

double value = 1d;

Yeah… hmmm… that’s a pretty simple “lambda” indeed… hah!

Forty-Two

7.5 million years ago.

“Let’s build a giant computer that can give the ultimate answer to the meaning of life, the universe, and everything!”

“Let’s do it!”

One year later.

“We’ve built a giant computer that can give the ultimate answer to the meaning of life, the universe, and everything!”

“Let’s test it!”

“Ok. It’s just a beta so let’s start with something simple like ‘seven times six’.”

One minute later.

“…It’s slow.”

“Yeah, let’s get some lunch…”

One hour later.

“It’s really extremely slow, isn’t it?”

“Let’s wait and see…”

One day later.

“Still computing? Is it even working?”

“Yes!”

“OK. Let me know when you have the answer…”

Today.

“The giant computer that was built to give the ultimate answer to the meaning of life, the universe, and everything has produced an answer!”

“Yay! Let’s hear it!”

“It’s … forty-two.”

“What was the question?”

“It doesn’t seem to have been programmed to remember, but I can only assume it was along the line of ‘What is the meaning of Life, the Universe, and Everything.’ Don’t you think?”

“And the answer is ‘forty-two…’ fascinating…”

The Complete Guide On How To Clean A Mac – Setapp

“What’s the easiest way to keep your laptop running in tip-top shape? Keep it clean, of course! It doesn’t matter how old your Mac is, a clean Mac will always outlast its newer cluttered counterpart.”

via The Complete Guide On How To Clean A Mac – Setapp

Keeping your Mac clean… but probably not the way you thought…

“An oft-asked question by many Mac users is “How do I clean my Mac’s system?” The advice they frequently receive involves things like deleting log files, clearing caches, removing cookies and all manner of other things. There are dozens of utilities that help users do these tasks. So, which one is best? The answer may surprise you: none of them! But why?”

via The myth of the dirty Mac

Although, I have had my Anti-Virus prevent me from opening web pages and downloading stuff so I think I need them, and others agree…

“No software is immune to attack, including macOS. The rising popularity of Apple computers has made them a prime target for malware. And security companies are increasingly offering antivirus for Macs, but do you really need it?”

via Do You Need an Antivirus on a Mac?

Rubber duck debugging

In software engineering, rubber duck debugging is a method of debugging code. The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, line-by-line, to the duck.

via Rubber duck debugging – Wikipedia

Although, I can’t really imagine that implementing this en masse in my current office landscape will gain much in the effect of not interrupting your colleagues… I imagine sales will step in and stop it before any larger customer can see us… 😀


Header image: “Ty Beanie Duck Programming — It may not be a rubber duck, but I can hug it when it goes really bad!” Own work.