# Software: What are we doing wrong?

## 2018: 30 years of Internet in Europe

Set up by the CWI in Amsterdam.

I was the 5th person on the internet.

Speed then: 64kbps

Current speed: 5.5Tbps (approaching 100M times faster)

## 1988: Public computing was only about 30 years old

We think of the internet as new, but when it was introduced, public computing was only about the same age as the internet is now.

The computer era is really not that old.

I was tutored at University by Dick Grimsdale, the man who built the first ever transistorised computer.

He had been tutored himself by Alan Turing.

I later went and worked at Turing's old department, alongside people who had worked with him, on the 5th computer in the series he had worked on.

## 1957: The first municipal computer (Norwich, UK)

Just one of 21 cabinets making up the computer.

## 2015: The Raspberry Pi Zero

The first computer so cheap that they gave it away on the cover of a magazine

## How do they compare?

What do you think the relationship is between the speeds of the two computers?

## How do they compare?

What do you think the relationship is between the speeds of the two computers?

The Raspberry Pi is about one million times faster...

## How do they compare?

What do you think the relationship is between the speeds of the two computers?

The Raspberry Pi is about one million times faster...

Which means: If they had run the Elliot 24 hours a day for 10 years, it would have done the amount of computing you can do on a Raspberry Pi Zero in about 5 minutes!

## Compare

So the Raspberry Pi is:

• One million times faster
• One millionth the price

A factor of a million million (billion for Europeans, trillion for Anglo-Saxons).

A terabyte is a million million bytes: nowadays we talk in terms of very large numbers.

Want to guess how long a million million seconds is?

## A million million seconds

Is 30,000 years...

In other words, a really big number...

## Moore's Law

In fact a million million times improvement is about what you would expect from Moore's Law over 58 years.

Except: the Raspberry Pi is two million times smaller as well, so it is much better than even that.

## Happy Birthday Moore's Law!

In 2015 Moore's Law turned 50 years old.

Or less prosaically: Moore's Law was 33⅓ iterations of itself old.

## The reports of Moore's Law's death have been greatly exaggerated

The first time I head that Moore's Law was nearly at an end was in 1977. From no less than Grace Hopper, at Manchester University.

Since then I have heard many times that it was close to its end, or even has already ended. There was a burst of such claims in 2015, which caused a wag to tweet:

"The number of press articles speculating the end of Moore's Law doubles every eighteen months."

## A data point: The Raspberry Pi

As an excellent example, in February 2015, almost exactly three years after the announcement of the first version, version 2 of the Raspberry Pi computer was announced.

• Six times faster
• Four times as many cores
• Four times as much memory
• Twice as many USB ports
• Same size
• Same price

## Moore's Law

So Moore's Law has been doing its work, and computers have been getting exponentially faster.

In 1988 my laptop had a power of 800. My present one has a power of nearly 30M. That is 15 doublings!

More amazing still: my current mobile phone has a speed of almost 115M!

## Exponential change

This is November 2006:

Six years later, the cheapest 4GB stick cost €2.99.

## What exponential growth really means

Often people don't understand the true effects of exponential growth.

A BBC reporter: "Your current PC is more powerful than the computer they had on board the first flight to the moon". True, but oh so wrong.

Take a piece of paper, divide it in two, and write this year's date in one half:

## Paper

Now divide the other half in two vertically, and write the date 18 months ago in one half:

## Paper

Now divide the remaining space in half, and write the date 18 months earlier (or in other words 3 years ago) in one half:

## Paper

Repeat until your pen is thicker than the space you have to divide in two:

## Paper

This demonstrates that your current computer is more powerful than all other computers you have ever had put together (and way more powerful than the computer they had on board the first moonshot).

## Let's go back to 1957

In the 50's, computers cost in the millions. Nearly no one bought them, nearly everyone leased them.

To rent time on a computer then would cost you of the order of \$1000 per hour: several times the annual salary of a programmer!

When you leased a computer in those days, you would get programmers for free to go with it.

Compared to the cost of a computer, a programmer was almost free.

## The design of programming languages

In the 50's the computer's time was expensive.

So a programmer would:

• write the program,
• copy it to special paper,
• give it to a typist,
• who would type it out,
• then give the result to another typist
• who would then type it out again to check it.

Why all this extra work? Because it was much cheaper to let 3 people do this work, than to let the computer discover the errors for you.

## The design of programming languages

And so programming languages were designed around the needs of the computer, not the programmer. It was much cheaper to let the programmer spend lots of time producing a program than to let the computer do some of the work for you.

Programming languages were designed so that you tell the computer exactly what to do, in its terms, not what you want to achieve in yours.

## 1968

A short ten years later, there was already talk of a software crisis.

Programs being written that weren't functional, and/or weren't delivered on time.

## Back to now

It happened slowly, almost unnoticed, but nowadays we have the exact opposite position:

Compared to the cost of a programmer, a computer is almost free.

I call this Moore's Switch.

## Moore's Switch

Relative costs of computers and programmers, 1957-2017

But, we are still programming in programming languages that are direct descendants of the languages designed in the 1950's!

We are still telling the computers what to do.

## Declarative programming

A new way of programming: declarative programming.

This describes what you want to achieve, but not how to achieve it.

Let me give some examples.

## The first declarative definition

Declarative approaches describe the solution space.

A classic example is when you learn in school that

The square root of a number n is the number r such that r × r = n
• Simple
• short
• obvious
• understandable.

This doesn't tell you how to calculate the square root; but no problem, because we have machines to do that for us.

## Procedural code

```function f a: {
x ← a
x' ← (a + 1) ÷ 2
epsilon ← 1.19209290e-07
while abs(x − x') > epsilon × x: {
x ← x'
x' ← ((a ÷ x') + x') ÷ 2
}
return x'
}```
• What does it do? Under what conditions?
• How does it do it? What is the theory behind it?
• Is it correct? Can I prove it?
• Under what conditions may I replace it, or a part of it with something else?

## A Procedural Clock

1000 lines, almost all of it administrative. Only 2 or 3 lines have anything to do with telling the time.

And this was the smallest example I could find. The largest was more than 4000 lines.

## A Declarative Clock

```type clock = (h, m, s)
displayed as
circled(combined(hhand; mhand; shand; decor))
shand = line(slength) rotated (s × 60)
mhand = line(mlength) rotated (m × 60)
hhand = line(hlength) rotated (h × 30 + m ÷ 2)
decor = ...
slength = ...
...
clock c
c.s = system:seconds mod 60
c.m = (system:seconds div 60) mod 60
c.h = (system:seconds div 3600) mod 24```

## XForms

XForms is a declarative system that lets you define applications.

It is a W3C standard, and in worldwide use.

• KNMI, The Dutch Weather Service
• Many Dutch (e.g. Onderwijs, Kadaster?) and UK government websites
• BBC
• UK NHS
• US Department of Motor Vehicles
• the British Insurance industry,
• the US Navy (in submarines),
• NASA (Jet Propulsion Laboratories),
• Verifone - a payment company, for configuring petrol pumps,
• Xerox
• Yahoo
• Remia
• EMC
• ...

## Example: 150 person years becomes 10!

A certain company makes one-off BIG machines (walk in): user interface is very demanding — traditionally needed 5 years, 30 people.

With XForms this became: 1 year, 10 people.

Do the sums. Assume one person costs 100k a year. Then this has gone from a 15M cost to a 1M cost. They have saved 14 million! (And 4 years)

## Example: Insurance Industry

Manager: I want you to come back to me in 2 days with estimates of how long it will take your teams to make the application.

## Example: Insurance Industry

Manager: I want you to come back to me in 2 days with estimates of how long it will take your teams to make the application.

[Two days later]

Programmer: I'll need 30 days to work out how long it will take to program it.

## Example: Insurance Industry

Manager: I want you to come back to me in 2 days with estimates of how long it will take your teams to make the application.

[Two days later]

Programmer: I'll need 30 days to work out how long it will take to program it.

## Example: NHS

The British National Health Service started a project for a health records system.

• It involved 70 people
• It cost £10M.
• The hardware costs alone were £5 per patient.
• It failed.

## Example: NHS

The British National Health Service started a project for a health records system.

• It involved 70 people
• It cost £10M.
• The hardware costs alone were £5 per patient.
• It failed.

One person then created a system using XForms.

• Hardware costs are 1p per patient
• It runs on Raspberry Pi's
• It is now running in 5 NHS hospitals.

## Conclusion

For historical reasons, present programming languages are at the wrong level of abstraction: they don't describe the problem, but only one particular solution to the problem.

Once project managers realise they can save 90% on programming costs, they will switch to declarative programming.

I believe that eventually everyone will be programming declaratively: less errors, more time, more productivity.

Declarative programming allows programmers to be ten times more productive: what you now write in a week, would take a morning; what now takes a month would take a couple of days.