The author

Programming: We're doing it wrong!

Steven Pemberton, CWI, Amsterdam

Abstract

Contents

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 general-purpose computer that was so cheap, it was given away free on the cover of a magazine...

Which is faster?

Want to guess which is faster, the Raspberry Pi or the Elliott, and by how much?

Which is faster?

The Raspberry Pi is about one million times faster than the Elliott...

But it is also about one million times cheaper!

A factor of a million million (billioen in Dutch, trillion in English).

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...

In other words

Since the 50's, computers have become incredibly cheap and powerful, and yet we are still programming them with programming languages that were designed to save the computer work.

In fact most computers spend most of their time idle. Here is my computer as I write these slides. The bump at the end is caused by taking the screen shot.

A computer idling

What we need to do is take the load off the programmer, and put more of it on the computer. Use some of that spare power!

The fifties

In the 50's, computers cost in the millions. 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!

Nearly no one bought computers, nearly everyone leased them.

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

Programmers were essentially free (in comparison with the cost of the computer).

The programmer

TypingIn 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 verify that it had been typed correctly the first time.

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.

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.

Moore's Switch

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

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

Moore's Switch illustrated

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.

Example

1960: Algol60

procedure bottles(n); value n; integer n;
begin
    if n < 1 
    then outstring(1, "no more ")
    else outinteger(1, n);
    if n = 1
    then outstring(1, "bottle")
    else outstring(1, "bottles");
    outstring(1, " of beer");
end;

integer i;

for i := 99 step -1 until 1 do begin
   bottles(i); outstring(1, " on the wall, ");
   bottles(i); outstring(1, "\n");
   outstring(1, "take one down and pass it around, ");
   bottles(i - 1); outstring(1, " on the wall.\n");
    end;
end

Now: Python

for quant in range(99, 0, -1):
   if quant > 1:
      print quant, "bottles of beer on the wall,", quant, "bottles of beer."
      if quant > 2:
         suffix = str(quant - 1) + " bottles of beer on the wall."
      else:
         suffix = "1 bottle of beer on the wall."
   elif quant == 1:
      print "1 bottle of beer on the wall, 1 bottle of beer."
      suffix = "no more beer on the wall!"
   print "Take one down, pass it around,", suffix
   print "--"

Descriptive programming

A new way of programming: Descriptive programming.

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

Is an order of magnitude quicker to program.

Saves 90% of the costs.

The first descriptive definition

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

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 Descriptive 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 Descriptive Clock

The Views System

XForms

XForms is a modern descriptive programming system that lets you define applications.

It is a W3C standard, and in worldwide use.

Example: 150 person years becomes 10!

A certain company makes BIG machines (walk in): user interface is very demanding

Traditionally needed 5 years, 30 people.
With XForms this became: 1 year, 10 people.

10 people years instead of 150

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.

(Two days later)

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

XForms person: I've already programmed it!

Example: NHS

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

One person then created a system using XForms.

(Some) Implementations

CM Pro (Netherlands)

Inventive Designers (Belgium)

BetterForm* (Germany)

XSLTForms* (France)

Jadu (UK)

Orbeon* (USA)

XForms is also part of OpenOffice* and LibreOffice*

*=open source

Conclusion

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 descriptive programming.

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

Descriptive 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.

Advert: XForms Day at CWI in May (watch my homepage).

Slides are online.