VS Code – invalid version: is

Recently I noticed that some of my VS Code extensions weren’t working properly. Specifically, the ones that perform PHP linting and syntax checking. Opening up the VS Code developer tools showed this puzzling message:

Activating extension failed: Invalid Version: is.

I couldn’t find anything matching that online, and trying to debug it further didn’t reveal anything useful.

I eventually took the (somewhat extreme) path of removing VS Code entirely (application, settings, extensions), and even removing my entire Zsh environment. The plan was start all over again and see if that helped.

It didn’t.

I then downloaded the extension code and used the extension development environment to step through the extension and saw that it was loading PHP to parse out the version (php --version), and the response from PHP was:

WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.24-(to be removed in future macOS) (cli) (built: Feb 28 2021 09:53:14) ( NTS )

The parsing is a regular expression that’s looking for PHP 7.3.24, but is finding the PHP is from the second line.

Thanks Apple.

The solution is to install PHP with brew, and use that version.

brew install php

Now to restore my VS Code and Zsh environment.

Wrong is Yoda

Like any profession, programming is full of things you should do, and things you shouldn’t. Some of these are passed-down experiences, and some are momentary fashions.

One of the former is that you should write a conditional using Yoda notation.

That is, instead of writing:

if ( x == 1 )

You should write:

if ( 1 == x )

The reasoning being that it avoids unintentionally assigning a value:

if ( x = 1 )

This, according to The Wisdom, is the cause of such incredible bugs that we need to contort our brain to prevent it ever happening.

While I appreciate the desire to prevent bugs, in this instance it seems entirely unnecessary. In fact, I’d say that it’s positively detrimental.

You see, the code is written once.

It is read many, many, times, and each time you have to mentally reverse your natural tendency to think of if x = 1 and make it become if 1 = x.

Do you think like that? I don’t. It’s a lot of wasted effort.

Is this such a massive problem that it requires this kind of cognitive overhead?

In my entire programming career I’ve maybe made the assignment mistake once. It was easy to spot.

On top of that, we now have incredible linting tools that identify these situations. There is no reason to have an assignment inside a conditional anyway, and we can let our tools tells us this.

You should write your conditionals the way your brain reads them. The cognitive load happens once, when writing, not once every time it is read.

Yoda is clearly not a programmer. Each time I come across a Yoda conditional it costs me valuable seconds in which I could be trying to understand how Kirk is Yoda’s father’s brother’s sister.

Also, I immediately dislike the code. I don’t like code that I dislike.

Very very wrong is Yoda.

LEGO Mario

As I’m now able to experience a second childhood (i.e. I’ve carefully curated my daughter’s tastes to match my own) I thought that the new LEGO Mario was interesting.

It’s a LEGO figure that takes two AAA batteries, has bluetooth, a speaker, and an OLED screen in the eyes, mouth, and stomach area.

I think there’s also a motion sensor, and an image sensor on the bottom that can detect colours as well as some form of QR code.

The basic idea is that you build a course for Mario and then as you play the course the figure can detect the coloured bricks, collect coins, and play sound effects.

My daughter likes bouncing it around the room, and on my head, to see where coins are hidden.