Terence Eden. He has a beard and is smiling.

Terence Eden’s Blog

Theme Switcher:

Unicode operators for semantically correct programming

· 29 comments · 100 words · Viewed ~480 times


Why do most programming languages use the / character when we have a perfectly good ÷ symbol? Similarly, why use != instead of ≠? Or => rather than →? The obvious answer is that the humble keyboard usually only has around 100 keys - and most humans have a hard time remembering where thousands of alternate characters are. Some programming fonts attempt to get around this with ligatures. That all…

Book Review: The Programmer's Brain - What every programmer needs to know about cognition by Felienne Hermans

· 7 comments · 500 words · Viewed ~11,314 times


Book cover for the Programmer's Brain.

There are some books which make you feel smarter just by having them on your shelf. This is one of them! I would consider it essential for anyone working with code - whether a wide-eyed newbie or grizzled veteran. How do human brains understand code? What neurological quirks do we all have? Which common mistakes can be easily avoided? Only by understanding our puny hardware ("Isn’t it a miracle …

⩵ != ==

· 3 comments · 100 words · Viewed ~437 times


Lots of mechanical fingers typing on a complicated keyboard.

One of the frustrating things about computers is their limited input options. A "standard" PC keyboard only has about 100 keys. Sure, some have some bonus buttons for controlling the machine, but it is becoming clear that there simply aren't enough buttons to efficiently program computers. Most programming languages have the concept of relational operators. How does variable X compare to…

Code Palindromes

· 150 words


Binary code displayed on a screen.

An idle thought on a long weekend. Is it possible to create an executable binary which is a palindrome? It's trivial to create a palindromic program in, say, Python: print("hello") # )"olleh"(tnirp Save that as test.py and then run cat test.py | rev | python3 and it'll work. But that's boring! You could do the same by reversing the bits, rather than the characters: 01110000 01110010…

Goodbye avatars .io - hello unavatar!

· 2 comments · 200 words · Viewed ~1,557 times


A smiling pixel art face.

Given a social media user's username, how do you get a picture of their avatar? I always used avatars.io - but sadly that service has bitten the dust. So I've switched to unavatar. It's dead easy to use. https://unavatar.now.sh/twitter/edent will return @edent's avatar. You can use GitHub, Facebook, Gravatar, Instagram, Telegram, YouTube, SoundCloud, and a couple of other providers. Simple…

Programming Languages - look how far we've come!

· 250 words


List of computers.

Back in the 1980s, when my family first got a micro-computer, there were only limited ways to program your machine. The Internet was basically non-existent for domestic users. You could buy thick computer manuals, swap cassettes with other enthusiasts, or build a light pen and point it at a flashing square on your TV (Really!) Or, you could go down to your local newsagent, buy a magazine, and…

Why do we have different programming languages?

· 6 comments · 650 words · Viewed ~3,901 times


Pencil protrail of William Shakespeare - as though he were a Klingon from Star Trek.

I made a little girl cry recently. "But why do I have to learn Python?" She wailed, "I like Scratch!" "I know," I said, "But there are different programming languages for different sorts of tasks." "That's stupid" she said, with all the perception of 6 weeks Code Club experience. "You can do everything in Scratch." I found it hard to argue with the twelve-year-old - you can do just about…

Falsehoods programmers believe about flags

· 3 comments · 400 words · Viewed ~2,745 times


A dropdown box showing the flag of Canada next to a plus 1.

(For more about the "Falsehoods" meme - read the big list of falsehoods programmers believe.) Do You Want To Phone A Friend? A popular website asked me to confirm my phone number. It "helpfully" pre-filled the country-code with +1. And proudly displayed the Stars and Stripes. Except, of course, the USA isn't the only country to use +1 - our friends in the Great White North also use +1. …

Adjusting timestamps on images with Python

· 1 comment · 200 words · Viewed ~3,541 times


A cute penguin.

As ever, mostly notes to myself. I have a bunch of old images which don't have any timestamp associated with them. This quick Python script will add a DateTime EXIF metadata tag to an image. This uses piexif which can be installed using pip install piexif This simple script reads a photo, adds a timestamp, then saves a copy of the new photo. from PIL import Image from PIL.ExifTags import…

Don't use negative numbers for error codes

· 9 comments · 250 words · Viewed ~2,185 times


A warning to programmers - try to understand how people will use your error codes. This morning, I was confronted with a rather bemusing error message on my WordPress blog: Ok, so this should "never happen" and yet somehow it has. I wonder what on earth the error code means? I selected the error code and Googled it! I just copied and pasted the error message into Google and got back a set …

Why I vertically align my code (and you should too!)

· 34 comments · 750 words · Viewed ~86,380 times


There was an interesting discussion on HackerNews last week about the Linux Kernel coding style. During the discussion, I kicked off a minor holy war about whether one should vertically align code. I'm all for it! Let me explain why. What Is Vertical Alignment? Take this trivial example: int robert_age = 32; int annalouise_age = 25; int bob_age = 250; int dorothy_age = 56; I find easier to …

Extracting Your Own Location Information From Google - The Hard Way

· 23 comments · 1,350 words · Viewed ~42,000 times


Update! There's a new way to do this - read my latest post to find out how. Two or three years ago, I was contacted by a recruiter from Google. They wanted to know if I'd be interested in working for the advertising giant. We played the usual game of dancing around salary and schedules, when he dropped the bombshell - they were looking for people to work on Google+. I asked the recruiter if…