Why I dumped Linux for Windows

For most developer types like myself, it’s usually the other way around - ditching Windows for Linux. However, I find myself in an interesting position.


My original reason for switching over to Linux a year or two ago, was because I was fed-up with Windows 10’s sluggish performance on my otherwise decently powerful desktop. I dual-booted Ubuntu 17.10, and it worked pretty well - switching back to Windows occasionally when I wanted to play video games or use Visual Studio. Ubuntu was responsive as my daily driver, it was easy to develop on, and most importantly it was free.

Over time I noticed things start to slow down. The performance issues were becoming more and more obvious, but they were not the same as my issues with Windows, where it was slow from day one. I was thinking that I was bloating Ubuntu with all the nonsense I was putting on it - all sorts of virtualisation programs and heavy disk encryption that probably wasn’t necessary.

This was when I switched to Linux Mint, just at the start of this year - literally twenty days ago. I installed it in the same way as I did when I originally switched to Ubuntu - just threw in another SSD and dual-booted with my current system, so I could bring all my old documents a little easier.

I was surprised that a new install of Linux Mint was as slow as Windows, but of course it wasn’t actually the OS’s fault. The SSD I used was the same one that I had previously installed Windows. So it was this ageing SSD’s fault all along!

So I gave Windows another shot on a newer Intel SSD, and I was absolutely blown away with the speed. It was faster than Ubuntu on an identical Intel SSD! Login time was near-instant, and programs were loading faster. Of course this is all based on my perception, I didn’t actually time or test anything. I’m probably being tricked by partial loading or that skeleton loading cleverness.

Nevertheless, the responsiveness of the recent Windows makes me think that the reasons for anyone actually making the switch to Linux are quickly diminishing.

Some bullet points

  • Speed
I’ll give Linux the advantage of a lower overhead, but otherwise Windows appears to beat-out Debian Linux in performance, in my experience. Perhaps you’ll see greater reason for Linux on less powerful or old hardware.
  • Compatibility
I’ve never had to worry about any drivers other than for my old printer on Windows. They have everything ready for me during installation, whereas on Linux I’ve always had to install my own drivers or connect to ethernet to get WiFi up and running. There must a trade-off with software/driver bloat or licensing that I’m missing, but I clearly prefer the direction Windows went.
  • Software
Windows has almost everything. I’ve been known to play a few video games in my spare time, and the only Linux-native games I can play are indie 2D-sidescroller games. And then of course there’s the Adobe suite, iTunes, and Visual Studio - all of which are non-existent on Linux. And if ONE PERSON tries to recommend ‘TuxPaint’ or ‘TuxTunes’ or any of those other ugly, poorly designed alternatives, I will cry. It’s 2018, we polish our software visuals now - even if it’s FOSS.
  • Security
I was debating this argument internally, but I think it works here. I know Windows has a bad rep for getting infected with all sorts of viruses, but at least it has proper defences available. The defence strategy for Linux is obscurity, which is not a defence strategy at all. And perhaps people confuse correlation for causation - the weakest link in computer security is always people, and people who use Linux are likely to be computer savvy.

Your parents, grandparents, and children are likely to be using Windows because of its prevalence, and these are the people the download and run these random programs because and advertisement told them to. I can bet you that the same thing will happen on Linux, if it was the most popular OS. The difference is that Windows has specialised software like Malwarebytes and Avast to remove and prevent infection, where on Linux you would have to restore to a segregated backup, or just re-install the OS. Maybe you would remove it manually, if you knew what you were doing. // end security rant.
  • Price (??)
This one was interesting for me as well. Microsoft is taking something of a gentle approach with payment for using their software these days. You can download an ISO off their website for free, and use it for quite a while without registering it. I’m currently running the OS like this, and all it’s restricting me from doing is customising my desktop and task bar. It also has a little watermark in the corner. I can continue to use it like this until uni starts again and I can get my free student license, or when my friend stops using the home license I purchased a while ago - whichever happens first.

Yes, I know that Linux is always free, but I would argue that on this front that Linux and Windows are on a largely even playing field, given the features and support of Windows.



Hopefully that didn’t cause too much cognitive dissonance, but that’s how I’m feeling about the current state of operating systems. What a geeky thing to think about!

Distribution of Circular Queued Work in Node.js

I was building an application that worked with Twitter for a friend, but it unfortunately got killed by Twitter for violating their terms of service - oops. However, that application, while it was running, needed to be able to work with a lot of inputs at critical times. There was no way that a single operator on a circular queue, slowly working its way through linearly, was going to cut it - more and more items would expire before it can get back to the beginning.

Instead, what I decided was best was to simply add all of these work items into a database, and execute some interesting queries on child processes - ‘workers’.

If you don’t want an explanation, I put together something of an example on GitHub, right here.

 

The workers

I didn’t bother with anything too fancy - even though I definitely did over-engineer this example. It’s just a forked script with IPC for communication, sending each other information via objects.

 

index.js

The index.js file is our root script - the parent. It creates worker processes and adds it to an array, that allows us to interact with it from the parent.

Node.js sets up IPC (inter-process communication) automatically, and we send the worker its ID. I chose to set an ID myself in the parent, but you could just as easily use the workers process id, as it would be better scoped to the server.

I also set up an ‘awaiting payload’ system, so that we could setup health checks and dynamically drop and spawn new processes. I haven’t actually developed this yet, but maybe later.

The setInterval at the bottom of this script it to keep the script running forever - otherwise it would terminate as soon as it reached the bottom of the script, and kill the forked processes before they can even do anything. If you were using this script in a framework such as express or sails, this is unnecessary as they keep the script running anyway.

Fun fact! - A javascript interval is never scheduled when it is set to infinity, even though the script expects it to do so, meaning the script never terminates.

 

worker.js

Pretty basic! All it does at this point is receive some info from the parent, and schedule a work loop to run every second.

This requires the worker loop to get the data itself, rather than relying on the parent to send it data to work on.

The thinking behind this type of design is that the worker can get the data to work on as it is required. There’s never a moment when it has nothing to work on, or where it has too much to work on.

This design, however, requires some slightly fancy queries to select data from a database (mysql in this case) in a way that prevents race conditions and over-working on the same work item.

 

The SQL queries

All of the following queries would be placed into the work_loop function in worker.js, using your favourite MySQL connector or equivalent. You can see this in action in the GitHub example I’ve set-up.

In any other project, you would probably begin by SELECT-ing work items that haven’t been worked on, then UPDATE-ing to claim a few items as being worked on by a particular worker process. This won’t work, they will no doubt select the same rows. You might also think to use a transaction, but this probably won’t cut it either.

What we need is something atomic - completing in a single query. The simplest way to do this is to flip our queries around. UPDATE first, SELECT second. How trivial!

With the first ? param being the ID of the worker.

As you can see, this selects the work item that is the oldest, and either unclaimed, or where the claim is old enough that it was likely to have stalled or failed.

You can then easily select the work based on the worker’s ID, perform the work, and then unclaim the work! Easy as!

Linux Mint Development Environment Setup Quirks

As part of my ‘new year, new me’ campaign for 2018, I decided to switch from Ubuntu 16.04 to Linux Mint 18 - can you guess why?

 
I don’t have that much to set up most of the time, save for some development tools such as VS Code and GitKraken. I otherwise use the default applications for everything.

After admiring the Cinnamon desktop environment for a little while, I went about installing my development tools. I came across a few issues, mostly to do with the different distros shipping with different software.

Here are some of these problems, with solutions.

Encrypted 7zip files

Since I was moving operating systems, I took some backups of the various folders and other things I wanted to take with me.

I had to put them somewhere other than the drives I was about to wipe, and they were too large for any thumb drive I had lying around, and it would take far too long to upload to Drive. My only option was to put it on a public samba share in my home network, obviously having to encrypt them.

When I got my new install of Linux Mint connected to the network share, I found I couldn't decrypt the 7zip files with the default archive manager.

Problem

The issue was that I could not open the files, because the p7zip package does not ship with Linux Mint, whereas it must obviously ship with Ubuntu.

Solution

Simply add the package with apt:

sudo apt install p7zip-full

And then try again with the archive manager, should be all good.

GitKraken not starting

I got into GitKraken because they let you use the pro version for free if you're a student, as part of the GitHub education pack. It's pretty great, and very good looking. If it weren't my daughter I would probably be dating it.

Anyway, it installed on Mint just fine with a deb package, but it failed to open.

Problem

It appears that it requires libcurl3 to be installed, and - like last time - doesn’t seem to ship with Linux Mint.

Solution

Once again, super easy. Just hit it up with the terminal:

sudo apt install libcurl3

And you should see that ugly squid the next time you try to launch it.

Featured

Debounce API Requests in a JS Class

I have a react application that needs to access an API endpoint on the client side - which is hit when a user clicks on a button, as well as...

Popular