Hidden complexity in cute animal pictures
Tags: codequality, software, cats, dogs
Published: 2017-10-05 05:59:22

---
title: Hidden complexity in cute animal pictures
published: true
description: The hidden complexity in seemingly simple things, like viewing an adorable animal.
tags: quality, software, cats, dogs
canonical_url: https://mortoray.com/2017/10/05/hidden-complexity-in-cute-animal-pictures/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/5ztd21jhqueew6awia30.png
---

You head over to your favourite link site and click one of the pictures -- or let's be honest, you ctrl+click all the pictures. Your browser is filled with tabs of cute and cuddly little creatures. For all their simple attractiveness, getting those images on your screen is a technological marvel. Have you ever considered how much is involved?

I brought this up in a recent discussion about software development, in particular about the [low quality of software nowadays](https://mortoray.com/2016/09/23/are-we-forever-cursed-with-buggy-software/). We wondered about the complexity of flying an airplane compared to something like viewing an image. Though airplane programming is by no means easy, viewing an image is a mind-boggling interplay of thousands of little bits. It's magical that it ever works!


## Calling the cuddles

Let's start by clicking a link to a puppy.

![Cute dog](https://mortoray.files.wordpress.com/2017/10/pet-2571552_640.jpg)
##### URL: https&#8205;://mortoray.files.wordpress.com/2017/10/pet-2571552_640.jpg


1. There's a thumbnail of an adorable animal but you'd like to indulge in its full cuteness. You do this by clicking on the image, or the title of the item.  Glossing over a lot of details here, somehow the computer has managed to track the cursor, determine that you are clicking as opposed to scrolling, figure out which element you clicked on, and know that it is a link and should be loaded.

1. The "link" resolves to a URL, as shown with the image above. This link encodes severals bits of useful information. To make sense of it the computer first needs to parse it. It pulls out the scheme, or protocol, `https`. It also gets the domain `mortoray.files.wordpress.com` and the path `/2017/10/pet-2571552_640.jpg`.

1. The domain `mortoray.files.wordpress.com` tells us the location of the image. As the internet loves numbers more than names, we first need to translate this name into a number: an IP address. Translation is done with a service called DNS; these are remote computers that keep tables of names and numbers. Let's just skip the part about how your computer figures out which DNS server to use.

1. With the address, your computer can start talking to the remote server. As there's a lot more to the internet than just web pages, communication happens over a variety of layers. The browser speaks to the remote server with `https`, which is the web protocol: it knows about documents and types. This runs on top of TCP/IP which gets data from point A to B and back. If you like metaphors, you can consider TCP/IP to be a moving van. It takes stuff from one location to another never caring what that stuff is. HTTP would be the contents inside that moving van. One of those vans will arrive back at us carrying the image file.

1. A file is binary data: a long sequence of numbers. Files could contain anything, so the HTTP layer tells us what it is: a JPEG image, or rather `image/jpeg` in technical MIME lingo. The browser can't use this file directly, the actual image is specially encoded. It must use a tool, a software library, that can understand the JPEG format and convert it to a series of coloured pixels.

1. It's not really coloured pixels yet; it's still just more numbers sitting in the computer's memory. These need to get to your display. The browser, using one out of many possible graphics libraries, will send this data to the video card. It also instructs the video card where it should draw the graphic, including how big it is, possibly stretching the image to fill the screen. The video card further processes this data, along with data from all other running programs, and assembles what you see on the screen.

There, now we know what it takes to get charming creatures on your screen...


## What else?

...or do we?

I've glossed over a lot of details. Each of those steps hides many levels of detail.

I've ignored the hardware the browser is running on. The browser doesn't get to talk directly to the video card, or to the network; it makes requests via the operating system (OS) instead. All that network stuff runs on physical cables and boxes. Suffice to say there are more protocols involved than just HTTP and TCP/IP.

I've conveniently ignored what the remote computer does. We sent a request for an image, but it has a lot of work involved in getting that file back to us. I figure you've had enough acronyms for now.

The point is that seemingly simple tasks involve a large number of components, both software and hardware. As time goes on this complexity continues to increase, as users continue to expect new features. Easy-to-use devices, like smartphones, despite their flaws, are doing an excellent job of hiding the complexity in their implementation.