Moore's Switch

The author Steven Pemberton, CWI, Amsterdam

Contents

About me

Dick GrimsdaleTutored at university by Dick Grimsdale, who built the world's first transistorised computer. He was himself a tutee of Alan Turing.

My second Real Job was coincidentally at Turing's old department, working on software for computer number 5 in the series that he had worked on.

I co-designed the programming language that Python is based on.

I wrote part of gcc

I was the first user on European Open Internet

I organised two workshops at the first Web conference in 1994.

Which led to W3C: I co-designed CSS, HTML, XHTML, RDFa, XForms, and others.

The Life of a Researcher

First they ignore you

Then they ridicule you

Then they fight you

And then you win

               (Attributed to Gandhi)

The Life of a Researcher

First they ignore you (Denial)

Then they ridicule you

Then they fight you (Anger)

And then you win (Acceptance)

               (Attributed to Gandhi)

A typical project meeting

A project meeting

Discussing HTML

Singing with Tim Berners-Lee

Thirty years of Internet in Europe

Thirty one years ago, the open internet started in Europe.

I would contend that we still consider the internet as something new.

But on that day thirty years ago, public computing was also only just over thirty years old.

1957: The first municipal computer (Norwich, UK)

The First Computer in Norwich

Just one of 21 cabinets making up the computer.

2015: The Raspberry Pi Zero

Raspberry Pi in Norwich

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

How do they compare?

The Elliot ran for about a decade, 24 hours a day.

How long do you think it would take the Raspberry Pi Zero to duplicate that amount of computing?

How do they compare?

The Elliot ran for about a decade, 24 hours a day.

How long do you think it would take the Raspberry Pi Zero to duplicate that amount of computing?

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

Compare

The Raspberry Pi is not only one million times faster. It is also one millionth the price.

A factor of a million million.

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?

Compare

The Raspberry Pi is not only one million times faster. It is also one millionth the price.

A factor of a million million.

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?

30,000 years...

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.

Moore's Law: not dead yet

42 years of processors

Pricing of new technology

When a new technology is introduced, it is often priced not on what it costs to produce, but based on what it costs to do the same with the technology it is replacing.

For example, when Edison first introduced electric light into homes, electricity was priced based on what it would cost to produce the same amount of light by traditional means, but now with additional benefits of instant light, and no flames.

Similarly, early computers were priced based on what it would cost to do the same amount of computation using people.

1957

In the 50's, computers were so expensive that nearly no one bought them, but 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!

(1957 median UK male annual income £250; female £125)

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.

Programming in the 50's

TypingIn the 50's the computer's time was expensive. A programmer would:

Why? Because it was much cheaper to let 3 people check it, than use the computer to discover errors.

The design of programming languages

The first programming languages were designed in the 50s:

Cobol, Fortran, Algol, Lisp.

They were designed with that economic relationship of computer and programmer in mind.

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 the first recorded use of the term software crisis.

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

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

Moore's Switch illustrated
Relative costs of computers and programmers, 1957-now

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 (exactly) 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

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
    eps ← 1.19209290e-07
    while abs(x − x') > eps × x: {
        x ← x'
        x' ← ((a ÷ x') + x') ÷ 2
    }
    return x'
}

This is why documentation is so essential in procedural programming: the link between problem description and solution is so weak.

What does 'declarative programming' mean?

A Procedural Clock

A clock in C, 1000+ lines

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 × 6)
   mhand = line(mlength) rotated (m × 6)
   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

A Running Declarative Clock

The Views System

XForms

XForms is a declarative system for defining applications. BBC Sport App

It is a W3C standard, and in worldwide use.

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.

XFormser: I've already programmed it!

Example: NHS

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

Example: NHS

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

One person then created a system using XForms.

XForms

XForms 1.0 was designed for online Forms.

After some experience it was realised that the design had followed HTML too slavishly, and with some slight generalisation, it could be more useful.

So was born XForms 1.1, a Turing-complete declarative programming language.

Implementations from Belgium, France, Germany, NL, UK, USA.

XForms 2.0 is in preparation.

And I am here today to tell you about it.

Form and content

Wikipedia:

"The term form refers to the work's style, techniques and media used, and how the elements of design are implemented.

Content, on the other hand, refers to a work's essence, or what is being depicted."

This is a nearly-perfect description of XForms.

XForms applications have two parts:

  1. the model, describing the data, and its relationships;
  2. the user interface, describing the content, and connecting to the values in the model.

State

XForms is all about state. (Which means it meshes well with REST - Representational State Transfer).

Initially the system is in a state of stasis.

When a value changes, by whatever means, the system updates related values to bring it back to stasis.

This is like spreadsheets, but much more general.

The result is: programming is much easier, since the system does all the administrative work for you.

Example

I've got a position in the world as x and y coordinates, and I want to display the map tile of that location at a certain zoom.

My data:

x, y, zoom

Openstreetmap has a REST interface for getting such a thing:

http://openstreetmap.org/<zoom>/<x>/<y>.png

Map interface

However, the Openstreetmap coordinate system changes at each level of zoom.

As you zoom out, there are in each axis half as many tiles, so there are ¼ as many tiles. And the interface indexes tiles, not locations.

So to get a tile:

  1. You have to know how big a tile is
  2. you have to calculate the correct index using this plus the zoom.

Declarative Example

The data: x, y, zoom

scale = 226−zoom
tilex = floor(x/scale)
tiley = floor(y/scale)
url = concat("http://tile.openstreetmap.org/",

             zoom, "/", tilex, "/", tiley, ".png")

That is really all that is needed (modulo syntax, which looks like this:)

<bind ref="tilex" calculate="floor(../x div ../scale)"/>

That's the form. Now the content:

<input ref="zoom" label="zoom"/>
<input ref="x" label="x"/>
<input ref="y" label="y"/>
<output ref="url" mediatype="image/*"/>

and the tile will be updated each time any of the values change.

Live tile with zoom

Source

Map

Source

Map

Source

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.

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.

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

I believe that eventually everyone will program declaratively: fewer errors, more time, more productivity.