Soundtracks for coding

I wish I was one of those people who could listen to an audiobook while they work, but I can’t. I don’t know if it’s something unique to programming, or some inability of my brain to handle auditory multi-tasking, but I can’t read/write code (or much else) while also listening to human speech. Am I alone? I’ll bet I’m not. In Manish Sinha’s recent article, “What it feels like to be in the zone as a programmer“, he identifies the same issue:

I don’t want to talk to anyone. If I do find myself in a conversation, I’m not able to function correctly because I can’t. That part of my brain is disabled. Words will try to come out but won’t. I’ll mostly listen and patiently wait until I can return to the code. To the other person, I probably appear like I’m somewhere else. It’s because I am.

That struck a chord with me. My wife can testify that when I’m coding I can barely form sentences. Talking stops me from coding, and vice-versa. I need to close off the world, seal myself in a cone of silence. When silence gets boring, I need wordless, melodic noise to fill the hole. This is why I have fallen in love with soundtracks. Movie and TV soundtracks are the ultimate coding music. I used to consider myself a movie buff, but I’ve long ago transitioned to simply being a movie soundtrack buff. I’ve listened to hundreds of soundtracks in the last decade, from Bernard Hermann to Daft Punk and everything in between, and these are the ones that I keep coming back to for coding.

The Knick – Cliff Martinez

Cliff Martinez – who gave us the score to Drive – produced an electronic soundtrack which doesn’t seem to fit a show about hospitals in the 19th century. I don’t care whether it does or not, it’s great music to code to.

Moon – Clint Mansell

Clint Mansell did an amazing job when tasked with creating a score for the cult classic Moon. It helps that this movie is one of my favourite sci-fi films. The soundtrack beautifully captures the isolation of living alone in outer space.

Jane Eyre – Dario Marianelli

I have a soft spot for piano music, and Dario Marianelli always delivers. Jane Eyre is no exception. The refrain is a little reminiscent of the theme to Downton Abbey, expanded out into something much richer.

<iframe src=”https://open.spotify.com/embed/album/4EHO6nIhB0OCyOY2vQ8yqX” width=”300″ height=”380″ frameborder=”0″ allowtransparency=”true”></iframe>

Airmech – Front Line Assembly

The score to the 2013 multiplayer robot combat game, Airmech, is Front Line Assembly‘s first attempt at a soundtrack (if you don’t count some of the music for Quake Arena). It’s notable in that it is completely instrumental, featuring none of the media sampling that they’re more well known for. There’s a definite dubstep influence, which wouldn’t normally be for me, but it’s not overbearing. Everything That Was Before is the highlight for me – a light, slow-building track that usually arrives just when I’m hitting my stride.

The Ghost Writer – Alexandre Desplat

I don’t know anything about the movie Ghost Writer, and much like The Knick, I don’t want to or need to. It could be a fine movie, but I don’t care. The soundtrack is a great showcase of Desplat’s talent. Ghost Writer has a beautiful staccato rhythm of typewriter keys which makes writing or coding to it feel like… destiny.

The Grand Budapest Hotel – Alexandre Desplat

Most of Wes Anderson’s soundtracks are compilations of existing music, but for The Grand Budapest Hotel he went for something a little different, bringing the talented Mr Desplat on board to craft a full orchestral soundtrack which starts with a vocal / yodelling track from a Swiss folk group called Öse Schuppel, and builds from there.

Westworld – Season 1 – Ramin Djawadi

If you haven’t seen HBO’s Westworld, stop reading this and binge-watch the whole thing now. This blog post can wait. Done? Good. Ramin Djawadi is nothing short of a genius, and the way he turns songs from contemporary artists like Radiohead and The Rolling Stones into old west numbers is outstanding. Paint It Black in particular is a masterpiece. It captures the heart of old school westerns like The Searchers and True Grit while still remaining true to its roots. I also prefer his piano rendition of Black Hole Sun to the original – and I love the original.

Battlestar Galactica – Season 1 – Bear McCreary

Bear McCreary’s riffs off the mini-series soundtrack to create a modern, percussive theme, equally at home scoring human drama or space battles. There are some odd tracks on here. One in particular, Battlestar Muzactika, can easily pull you out of ‘the zone’ as the style is so jarringly different from the other tracks, but it’s quite short. Look up the translations for the Italian lyrics to the opera piece Battlestar Operatica for some series in-jokes.

Sadly, it’s not on Spotify, but you can find it on Youtube here:

Another Earth – Fall On Your Sword

The electronic soundtrack to Brit Marling’s sci-fi movie about an identical earth in our orbital plane. This is a great mix of experimental electronica, beautiful piano and a haunting cello refrain which repeats through a number of tracks. Fall on Your Sword also did the music for the TV show Magicians. 

Atonement – Dario Marianelli

Another Marianelli masterwork, and another soundtrack with typing noises. The track Elegy for Dunkirk is particularly special. Bonus points for ending with my favourite piece of classical music, Clair de Lune. Sometimes I just listen to Clair de Lune over and over as coding music. There’s an extended, looped version here on youtube which is an hour long.

The Lord of the Rings Suite – Howard Shore

It’s hard to separate a soundtrack from the movie it accompanies, especially when that movie is something as monumental and unforgettable as Lord of the Rings. My love of the movies influences my feelings about the music, but even without this there are pieces which Howard Shore has crafted which transcend the movie. Concerning Hobbits is just so evocative of a summer’s day in the country. The Breaking of the fellowship is a haunting ode to the rest of the soundtrack, but then breaks halfway into a beautiful soprano solo evocative of Welsh coal-choirs. Enya’s May it be is what Elvish music must sound like. And all these tracks are just from the first movie soundtrack. There are just as many gems on the 2nd and 3rd album.

Gladiator – Hans Zimmer

Hans Zimmer made his name with this groundbreaking soundtrack – a perfect mix of middle-eastern vocals, Spanish guitar and an explosive brass section. The style has been copied and imitated countless times over the years. One of the most memorable and identifiable scores of the last 20 years.

Bonus: The Planets – Gustav Holst

Perhaps the most influential composer on the big name soundtrack artists. In just one track – Mars, the God of War – you can hear the origins of The Imperial March from John Williams’ Star Wars score, and The Barbarian Horde from Zimmer’s Gladiator. I like to think of The Planets suite as a soundtrack some lost 1930s science fiction serial that never saw the light of day.

That’s my list. These compilations of music have helped me a lot when coding and writing. Hopefully there’s some inspiration here for someone else out there.

 

Electron memory usage compared to other cross-platform frameworks

Electron is everywhere you look these days. As a developer seeking to build cross-platform apps, it’s very appealing. It’s free, easy to use and quick to develop with. It’s a very fast way to get an MVP (minimal viable product) to market. On the other hand, a lot of programmers who are smarter than me have a real issue with it.

Every time Electron is mentioned online, you’ll invariably hear the opinion that Electron apps use 300+ MB of RAM and run like a dog floundering in molasses. “Why can’t people write native apps anymore?” the coding elite cry. Maybe the people who make these comments have a point. Native is surely faster than javascript running in a browser instance. But just how much faster?

I decided it would be fun to compare a few different cross-platform approaches and see how they stack up, memory wise. The results had a few surprises.

I created a simple ‘hello world’ app across the various frameworks, with one slight twist – hello world would be an html string <h1>hello world!</h1>, so any given app would need to be able to render HTML. I based this off the Electron quick start app.

Disclaimers:
I am not a scientist.
I simply used task manager to check the RAM. Your mileage may vary.
HelloWorld is hardly a good real world test, but I don’t have time to write a full app in each framework.
If I removed the HTML requirement and just went with plain-text, the non-javascript frameworks might be leaner, but there are plenty of real-world use-cases for displaying HTML in an app.

Please don’t treat this post as a serious study – it’s just one programmer’s experiment.

 HelloWorld <H1> App
(Ordered from lowest to highest RAM usage)

Tech Processes Total RAM
Xojo 1 12MB
Xamarin.Forms/C# 1 20.3MB
Python/Qt 1 20.8MB
Java 1 24.9MB
NW.js 5 55.3MB
qbrt/HTML 2 59.6MB
ReactNative 1 65.6MB
Electron 5 68.9MB

Xojo – Based on a proprietary version of BASIC, Xojo can target macOS, Microsoft Windows, Linux, iOS, the Web and Raspberry Pi. I’d heard of it a couple of times, but never played around with it until I decided to do this comparison. It’s got the lowest RAM usage of any of the tested frameworks. Unfortunately, it’s not free – it starts at $299 for a licence to build desktop apps (macOS, linux, windows). Every other cross-platform framework on this list is free to use. Also, since installing the framework my phone browsing is now plagued by ads for Xojo. It could be a coincidence, but it seems unlikely.

Xamarin.Forms/C# – Microsoft’s cross-platform framework runs on Windows 10, MacOS, Android, iOS, and Windows Phone. It’s free, and memory usage is great at 20.3MB, although some of that could be hidden behind the UWP processes which are embedded within Windows 10. For this reason it’s difficult to say exactly how much RAM is really being used. That said, I did build the same app out in WPF, and the RAM usage was very similar, so maybe it is reported accurately. If we give it the benefit of the doubt Xamarin.Forms has the lowest RAM usage of any free cross-platform framework. Just bear in mind it can’t be used on older versions of windows.

Python/Qt – often touted as a preferred alternative to Electron, and you can see why. 20.8MB is pretty effective, just a fraction more RAM in this test than Xamarin or Xojo. However, I’ve heard grumblings about Qt licencing.

Java – it’s been years since I wrote any java, but it came back easily enough. A simple JEditorPane inside a JPanel allows me to render our HTML. Java does very well, holding steady at 24.8MB. Java is a very accessible and proven programming language, and being the development language of android apps has given it a massive boost in popularity lately. You don’t have to look far to find resources to learn Java

NW.js – NW.js is pretty much the same thing as Electron. it uses Chromium, but it has one handy feature that the apps can be distributed WITHOUT the runtime, which reduces file size considerably. NW.js used 55.3MB in testing to render our index.html. This is a big jump from Java – more than double the RAM.

qbrt/HTML – This was my first big surprise. I’d never heard of qbrt before researching this post. It’s a little known project by Mozilla engineer Myk Melez. It replaces a previous project, Positron, which was a Mozilla Gecko based Electron alternative, which maintained compatibility with Electron. That project has now been discontinued, and qbrt is the replacement. It’s in the very early stages, not ready for production, but it is worth keeping an eye on. Firefox is enjoying a lot of performance improvements lately, thanks in part to a rewrite in Rust, and these improvements could eventually lead to something which runs leaner than Electron with the same speed of development.

ReactNative (for Windows) – The biggest surprise of my testing was that ReactNative for Windows used only slightly less RAM than Electron to show a simple hello world. 65.5MB was used. ReactNative is often touted as a much better way to write cross-platform apps using JavaScript. Granted, this app included React where the others did not, but React-native requires React. If you were to add React to Electron the RAM would probably go up, but of course you don’t need react in Electron, or any of the other alternatives on here.

Electron – The Electron quick start app is already <h1>hello world!</h1>. All I did was remove the code that checks for version, though I doubt that had any effect. 68.9MB used, across 3 Electron processes and 2 node.exe processes. It’s not exactly a 300MB hog, but it is more than twice the RAM usage of Java and three times that of Python.

Just for fun, here’s the memory usage of that same index.html in all the various browsers I could think of

Browser Processes RAM
IE11 1 20.7MB
Chrome 5 82MB
Microsoft Edge 4 139.5MB
Opera 7 146.3MB
Firefox 1 160MB
Vivaldi 7 244.9MB

I was very surprised to see chrome’s memory usage so low, since it is often called a memory “hog” next to the others. In fact, only IE11 bested it on memory (another surprise). But this is not a test of browsers, I just thought it was an interesting comparison to the above frameworks.

By these tests, Electron is fairly deserving of its reputation as a memory hog. This is no surprise I guess. What may be a surprise is that:
1) ReactNative is not any better and
2) Xamarin.Forms apparently uses less memory than Python/Qt

When Electron gets called out, it is often compared unfavourably to a browser running the same app. The Slack app, it is claimed, uses more RAM than simply running Slack in the browser. However, in my tests, Electron used less RAM to display the hello world HTML than even the leanest Chromium based browser. It’s all academic really – if you fire up a browser to use Slack, it might use more RAM than the dedicated app – but the chances are good that you’ll have other tabs open. If every tab you have open in your browser right now was an Electron app, you’d have no RAM left at all.

The thing about Electron is, there’s a time and a place for it.
VSCode is an excellent use case – a complex cross-platform IDE with a very quick release cycle, a large plugin ecosystem and a requirement for display and processing of a lot of different types of markup. But I’ve also seen a tray notification app built in Electron. An SD-card formatter. A “quick” launcher. These things can and should be built using Xamarin, or Python or Java instead.

This is just a surface comparison of course. Memory isn’t everything. There are so many more reasons why you might choose one framework over another. Ease of use. Familiarity. Toolset / IDE. Licensing. But Electron discussions almost always come down to memory, and that’s why I wanted to write this post in the first place. I’d love to re-visit these frameworks in more depth in a future post, and maybe add a few more to the list.

Some fun Raspberry Pi projects

I’ve got a spare Raspberry Pi Zero W sitting on my desk doing nothing, so today I decided to go looking for fun, easy Pi projects. Here’s a few I found which are a little different from the usual media player / arcade emulator / door opener projects you see all over the place.

Desk Projects

If you have a spare pi in your drawer but don’t want to leave the cubicle, these little projects are perfect.

Pi-Hole
Turn your Pi into a router proxy to block ads and other unwanted internet slime at the router level. In theory this would mean no more taboola links or ads on your devices without needing to install any kind of ad-blockers on the devices themselves.

Wireless Printer
If you’re anything like me you hoard old technology like it’s going to come back into fashion someday. I’ve gotten better lately, and thankfully I don’t have a shed full of old printers anymore, but if you did have an old non-wireless one, you could easily bring it kicking and screaming into the 2010s with this clever hack.

File Server
This makes an external harddrive accessible over the network, basically turning it into a fully functional NAS.

Audio Projects

There are a lot of audio projects out there, here are a few of my favourites

Audiobook Reader
I love minimalist controls, and you can’t get more minimalist than this single-button audiobook player. Press to play/pause, and hold down to skip to a previous track. Genius.

Turn an old amp into a wireless speaker
There are all kinds of airplay / google music / pandora radio rpi projects out there, but I like the style of this one.

Outdoor Projects

TimeLapse Dolly
RPi Timelapse camera setups are ten a penny, but this one has a dolly, so your timelapse shots will have that David Attenborough narrated BBC documentary feel to them.

Solar weather station

Driving

Touch screen car computer
Carputer
Lots of folks out there are putting pi into their dashboards. I’d love to do this. I could fit my entire music collection on a single 128GB micro SD card, but my current car stereo can’t handle anything bigger than 8GB. I want to build one of these:

Extra Credit Projects

For the over-achievers of the world, here are some not so easy, but totally amazing projects.

CNC Wood Burner

Freely-arranged screens

Smart Mirror

Despite all these amazing links I’m full sure I’ll still be staring at an unused raspberry pi in a months time!

Vivaldi, and browser options

I installed Vivaldi the other day to give it a whirl. I was a little sceptical of their claims that it was a browser “for developers”

Then I went into the options. My jaw literally dropped. Literally.

2017-01-20-10_31_17-vivaldi-settings_-startup

Look at all those options!

Vivaldi has options that other browsers don’t provide by default. You can change the theme at a specific time of day, set up mouse gestures, move tabs to the sides or bottom, set a time-limit on your browsing history, change your default fonts (as in, when a web page says “sans serif” you get to pick what that means)

Firefox, Chrome, and Opera (my favourite, up to now at least) have plugins to cater for all of these things, but vivaldi does them out of the box. I thought that would make the whole thing feel bloated, but it’s buttery smooth. It seems to load pages faster than any other browser, though I suspect that’s down to the progress bar, which shows how many bytes have loaded (mesmerising).

I’m going to set Vivaldi as my default from today on, with Opera to fall back on if needed

iPhone 4 battery life

I recently fixed up an old iPhone 4 for fun and to try out iOS. Turns out it’s limited to iOS7 which means most of the apps I try to install don’t work. Damn you apple, damn you.

I stuck it in airplane mode to fast charge, then plugged it out and forgot about it. A few days later I came back and found it at 100% battery life. Turns out the iPhone 4 has incredible battery life if you put it in airplane mode and do nothing with it.

photo_2016-06-16_10-22-40

6 Days, 17 hours, 85% and counting