Wednesday, November 29, 2017

Microsoft Edge

Mozilla has recently release Firefox Quantum. I supposed because it's supposed to be a quantum leap in web browser technology. Does this means that Scott Bakula will show up in your web browser at critical moments to help guide you through your web browsing experience? Nope. Sorry. It just means the Firefox has a brand new web engine that's been redesigned to similar to Chrome but better. If you haven't been taking Firefox seriously for a while now is the time to try it again. My experience has been great so far. Not only have I started to use Firefox again but it's now my web browser of choice.

Recently Windows went through one of those comically long updates and loaded the release notes for the update into Microsoft Edge web browser. Neat! I thought to myself. I haven't tried Microsoft's web browser in a long time and I know they've been working on it. If Firefox can improve so much maybe Edge can as well.

The first thing I noticed in Edge is that the scroll wheel on my mouse doesn't work. It seems to work everywhere else just not in Edge. How did they even do that? Well, I'm not going to debug that. Not now I have a Firefox that doesn't suck. Maybe I'll try Edge again in another 5 years or so. You know, when they've figured out how to get the mouse wheel scrolling work.

New information! It turns out that CatMouse was causing the problem. Windows 10 seems to ahev CatMouse like functionality built into it so removing it was now big deal.

Thursday, November 23, 2017

IPv6 adoption hits 20%

About 2 years ago I noticed that IPv6 adoption was at about 7%. Well now IPv6 adoption is at 20% and still growing quickly. 20% is excellent! One in five people on the internet have an IPv6 address. This is the year of IPv6.

I'm still a little hopeful that this will mean that p2p technology will become viable again, but it's hard to say for sure. Security is much more important than it once was. I've also been burnt by the criminally cavalier approach to security that most companies seem to have. I may trust my router (barely) but not anything else. As a result I haven't turned on IPv6 on my router because I don't trust that everything on my LAN will actually do the right thing in that scenario.

*sigh*

Security on desktop and laptop machines isn't too bad anymore. The Windows 10 and OS X will ask the user if a program wants to open a port. Additionally, modern OSes do try and minimize their attack surfaces by not listening for connections when not required. I just can't remember if I've done something silly like turned on file sharing with guest access and that will be shared on the open internet. It wouldn't be the first time I've made that mistake. One of these days I'll have the time to experiment and see if file sharing restricts itself to LAN addresses. Also, if we get an public IPv6, does the OS also give us a private LAN address as well so we can bind more sensitive services only to that.

Tuesday, November 21, 2017

Typescript is fun

I recently went from programming on Java for almost 20 years to programming exclusively in Typescript and I like it.

Typescript is a super set of Javascript. It is essentially a typing system built on top of Javascript and it works amazingly well. When I first started programming in it I expect it to be a dancing bear, and from one perspective it sort of is, but man does this bear dance.

The way to think about Typescript is it makes Javascript scale. It's not really trying to be its own language as much as a set of tools that allow you to take existing Javascript code and add some typing sanity onto it. What makes it work is a combination of crazy good type inference and a sort of strong duck typing. So if you have something like this:

interface Person {
 String name;
 int age;
}

interface Monkey {
 String name;
 int age;
}


you can do this:
Person p = new MonkeyInstance();

or this:

Person p = { name: "Steve", age: 12 };
Monkey m = p;

and it doesn't care. So long as the interfaces are compatible you can assign it and it's all good. Java can't do this because Java is tracking types at the byte code level. A monkey and person are two different types that just happen to have the same properties. For Typescript having the same properties is what defines a type.

(Java does allow this sort of assignment in an around about fashion with functions. For instance, you can pass any method that takes a value and returns a value to a method expecting a Function. But it only works with functions, not objects)

Typescript also implements an idea I've wanted to see implemented for a long time. Nullable as a type!

In Java, we've started to use "Optional" instead of null because it makes the optional nature of the value part of the type. But, what if the language did it for you? Well Typescript does. Basically, you can't do this:

Person p = null;

You have to express that p might be null like this:

Person | null p = null;

Trying to do this using Java syntax gets confusing but the idea is that p might be a Person or it might be a null. Like using Optional, it makes the compiler track that a value might be optional, but unlike optional it's built in. The same multi-type trick works with any types:

Person | Exception p = findPerson();

p might be an Exception type or a Person and you'd need to do some additional work to work out what p is.

You can append however many you want:

Person | Exception | null p = findPerson();

In java you can do this with exception catch blocks, but nowhere else:

try {
 stuff();
} catch (NullPointerException | IOExecption | SqlException ex) {
 // ...
}

Here's a video of the inventor of Typescript explaining how Typescript deals with null.