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

The Filter Bubble is Dead… and Then it Reanimates and Bites you in the Ass… Maybe…

I had an interesting discussion where the “Filter bubble” was declared dead and non-existent. That got my attention.

But first: “A filter bubble – a term coined by Internet activist Eli Pariser – is a state of intellectual isolation that allegedly can result from personalized searches when a website algorithm selectively guesses what information a user would like to see based on information about the user, such as location, past click-behavior and search history.” // English Wikipedia

I wondered where the opinion that the filter bubble was dead came from, so I searched the phenomenon and found, a bit (but not too) surprisingly, that in Sweden the filter bubble seems to be dead, while in the English speaking world it seems to be more of an ongoing debate.

Irony!

I just looked at the Swedish and English Wikipedia page for “Filter bubble” for that insight (and read a lot “between the lines” since neither one of them really gave any definite answer to the question).

However, the whole discussion of whether a phenomenon such as a filter bubble is dead is an alarming sign that you know little or nothing about how computer systems work or can be programmed.

Before we go on, I interpret “intellectual isolation” from the quote above to mean intellectually isolated by external means, not being, somehow isolated intellectually in your mind.

I.e. that the filter bubble is an external phenomenon and that in order to determine its full impact you’ll also need to study its effect on the mind. E.g. does the filter bubble make us more fundamentalist in our opinions, etc.

To do scientific studies, or experiments, to determine if the filter bubble does not exist is about as stupid and useless as performing scientific studies, and having lots of debates, of course, about whether it is possible for a Word document to contain the word “stupid”.

For all that we know, there could be a configuration parameter in Google and Facebook and their likes, called “enable-filter-bubble” that could have the value “false” today and “true” tomorrow.

Or for that matter could be set to “false” if the system detects activities that could indicate you are trying to perform an experiment to determine if a filter bubble exists.

I’m not saying this is how it’s done, I’m saying this is possible to do with computers. (Although, maybe not good enough to really fool us… maybe…)

So, if you publish a paper or article today saying that you have found no filter bubble, the evil social media platforms can change the value of that configuration parameter tomorrow (woahahaha!)

Research into confirmation bias, by all means, or how much effect a filter bubble, where such a thing does exist, has on people.

Obviously, keep looking for algorithms that seem to produce too biased search results and feed content that could prevent users from getting objective information.

But the only reasonable attitude towards specialized algorithms you do not know anything about (and in fact are likely forever prohibited by law from knowing enough about) is to assume you have to do a reality check now and again to verify that you’re not being manipulated.

Oh, and by the way, in the case of confirmation bias, the manipulator is you yourself, not an algorithm… in that case, the algorithm is just a tool to lull you into stupid satisfaction with your splendid, time-proven, world view… (Or maybe confirmation bias is a tool in the hands of the evil mind-controlling algorithm…)

Legislation that would prohibit mind-altering manipulative computer algorithms is, of course also a way to go… (imagine the EU spent all that energy getting all their citizens all these extremely tiresome “we’re-using-cookies”-banners when they could have protected us against mind control!)

I am not saying social media platforms and search engines are necessarily evil or trying to manipulate us. I think the filter bubble was an unintended consequence of trying to prevent information overflow and to stay interesting to users or in fact not losing them (all, of course in the name of the holy ad-sales-revenue).

Imagine, if you searched for “all the ways immigrants are ruining our country” and got results that stated, “immigrants are not ruining our country” (or vice verse). Chances that you would use that search engine again is very low, even if your search seemed to support an opinion that could need some counter-arguments.

Behavioral science or media studies are not able to tell us that there are no algorithms that produce search results and content feeds specialized to such an extent that we’re not exposed to new ideas.

They could, however, tell us if such algorithms are harmful to us or not (and if we end up in a world were one social media platform or search engine company owns every service we get information from—or our choices of information services produce that result—the answer is a resounding yes!)

You should probably not get all your news from Facebook or Twitter (and I don’t even know how that would work or what “news” you can get from those two, but that is frankly a subject for another post) or any one place.

I think state-sponsored TV and webs might still be OK.

Unless, of course, you’re worried that you’re living in a “western filter bubble”. Then Aljazeera or the likes might be something to look into.

Or are living in a country where state-sponsored TVs and webs are subject to censoring. Then maybe Facebook is the way to go… or at least get closer to good.

Otherwise, I think information consumption works pretty much like food consumption: don’t eat too much of just one thing… variation is key!


Header image: Piqsels.com, CC0, Link

Online Forum Conundrum – or the Evil OP

On bad Google Days, I come across these answers to my very urgent problem X:

Original Poster: I have problem X! Help!

The Unhelpful Guesser: Have you tried [unrelated solution].

Cosufferer: I have the same problem! Please let me know how this goes!

The Problem Specifier: Can you specify under what circumstances X occurs?

Original Poster: I get X when I Y with Z.

Second Cosufferer (quotes Cosufferer): +1 need to know this too!

The Log Meister: Can you post the contents of [list of log file paths].

Third Cosufferer: I am very interested in the solution to this problem!

Original Poster posts the logs but Log Meister is never heard of again.

The Reset Rebooter: Have you tried rebooting? Reinstalling? Upgrading?

Original Poster: @The Reset Rebooter: all of them to no avail…

Fourth Cosufferer: How is this going?

Original Poster (a month later): Anyone? Help!

Original Poster: I have solved the problem! Thanks for all the help!

Me: ?!?!

We love errors!

Experienced programmer: I am disappointed in this application… it doesn’t throw enough errors.

Inexperienced programmer: Huh?!?!

Errors are your friend because they tell you that something went wrong, and you get a list of potential places where it went wrong with line numbers in the code and everything (if you’re in debug mode, and using a somewhat mature framework).

In a contrary, applications that do their damndest to avoid errors usually end up doing nothing, or the wrong thing, without complaint, and your debugging effort is more akin to that of a therapist than a programmer.

Here are a few things to consider.

Don’t swallow exceptions

try {
  //...do something that may throw an error
}
catch (Throwable t) {}

If you don’t know what to do with the error, don’t catch it. If you need to do something, catch the error but throw another if the error is still a problem.

Stopping errors should propagate all the way to the user interface where they can be packaged nicely in a dialog or error page or some other device that prompts the user to provide other input, change the application configuration or call an admin.

If the error prevents the application from doing its job, the error prevents the application from doing its job. Period!

Of course, the best way to deal with user input is to implement data validation to prevent bad data from ever get past the UI of the application (which of course isn’t possible to do in all cases… hence the rest of this article.)

If a resource is involved, look into the try-with-resource-construct in Java or the using-construct in .Net. They will close a resource if there was an error or not.

Don’t throw exceptions with no or whimsical messages

Never throw errors without a message. Or with an ambiguous message:

if (value > max)
  throw new IllegalStateException("Error!");

Do you hate the above code? Good, it’s the classic Mac OS “An error of type 1 has occurred”-error message all over again. (And I’ve actually seen something like it in a mature paid-for product).

Return a meaningful error message. If you can, also add information about why there was an error:

if (ds.Tables[0].Rows.Count == 0)
{
  throw new Exception(
    "Unable to locate super user (user with ID=1)");
}

Imagine you’re the one getting the error message, and you’ll probably know what to do and that you need to do it.

Don’t use return values instead of exceptions

public int doSomething() {
  if (unable to do what I should)
    return -1;
  ..
}

If you run into an error condition, throw exceptions instead of returning values.

A calling method may mistake that -1 for a valid response. It will not mistake an exception in the same way!

There may be a case for returning null in some cases, for instance when there are no data.

Don’t fear null

Null, by the way, is another underutilized feature of programming.

In Java 8 there’s the Optional-class that can be used in cases where the value may or may not exist (e.g. a search).

Before Java 8 you have different options.

For a search, you could return an empty list.

However, when dealing with values that may, or may not, be set, null is the only way to go. (Pre- and post-Java 8).

Consider the following (slightly edited real-life) example:

public List<RowDto> GetItems(
  List<ColumnDto> columns, 
  string userName, 
  string searchTerm, 
  List<int> filters, 
  string sortColumn, 
  bool sortDescending, 
  int numberOfRows)
{
  ..
}

Now consider that the actual implementation of the view that displays items can have default sort ascending or descending.

How do you know when the framework asks for default sort or when the user has decided they want a specific sort (by clicking the headline of the column to sort)?

You don’t.

The sortDescending variable should have been nullable (bool? sortDescending in .Net/C# parlance).

In that case, it would have been possible to check for a null value (signaling default sort) and determine if the sort should be ascending or descending depending on the specification of the view.

Here’s another example where a value may be set or not, but the whole null handling has been hidden from the outside world (not that different from Optional, but with the ability to set the value as well, and several values in the same object…):

public class MyClass {
  public int getValue() {
    if (value == null)
      throw new IllegalStateException(...);
    return value;
  }
  public void setValue(int value) {
    this.value = value;
  }
  public void unsetValue() {
    value = null;
  }
  public boolean isValueSet() {
    return value != null;
  }

  public String getValue2()
  ...

  public Object getValue3()
  ...

  private Integer value;
  private String value2;
  private Object value3;
}

Catch error conditions early and throw exceptions (but do it right…)

Another tip is to catch errors early and throw exceptions. E.g. in Java 8, use the Objects.requireNonNull()-function.

However, always make sure your methods first verify the in-data and only then start changing the state of the object. Otherwise, if that object survives your mishandling, it will likely cause ripple effects throughout the application.

Consider the following:

public void myMethod(Object o1, String s1) {
  if (o1 == null)
    throw new NullPointerException();

  someOtherMethod(o1);
  .. + other work on o1

  if (s1 == null)
    throw new NullPointerException();
  
  .. do some work with s1
}

What happens to the state of this object if o1 is non-null and s1 is null?

Build a better system

One system I’m building generates a static site, but it takes a long time to do this, so I’ve decided to make sure my code is as efficient as it can possibly be:

public Writer writer(File file)
   throws FileNotFoundException
{
   Objects.requireNonNull(file,
      "Argument file is null");
   if (renderedFileList.contains(file)) {
      throw new IllegalStateException(
         "Trying to write the same file twice: " 
         + file);
   }

   renderedFileList.add(file);
   ...
}

This way I can always rest assured my programming never creates the same file more than once, and if I were to get this error, rather than calling it an unnecessary check and remove it, I’d go in and remove the second rendering… unless of course, I’m overwriting files…

After all, that site takes several minutes to render, so I’d rather only render it once!

As I’ve gained experience in programming I’ve come to change my opinion about errors and program crashes from “Oh! F*ck!” when I got them, to “hmmm, what’s up?” when I keep pounding in code without getting them.