Explained (2018–…): Season 2, Episode 5 - Coding - full transcript

Explained looks at how computer code now controls how we live. It looks at how computer code is pervasive in how it effects our lives. It looks at the development of machine code first in the textile industry and later binary code in early mechanical computers. It also discusses computer logic, algorithms, computer languages, personal computing, and machine learning.

[telephone rings]

- [woman] 9-1-1, emergency?
- [telephone rings]

[second woman]
911. What's your emergency?

- [man] 9-1-1. What's your emergency?
- [second woman] 9-1-1.

[Karlie Kloss] On April 9, 2014,
9-1-1 service suddenly stopped

for millions of people
across the United States.

It was down for over six hours.

More than 6,000 emergency calls
couldn't get through.

The government traced the problem
to a computer in a call-routing facility

in Englewood, Colorado.

It was a simple coding mistake.



The people in charge
of coding that computer

chose to do it with an upper limit
for the number of calls it could log,

a limit the coders thought
the computer would never hit.

But that night in 2014, it did.

The computer
followed its instructions perfectly.

It hit the limit
and stopped routing calls.

The problem wasn't the computer,
and it wasn't a bug in the code.

It was the coding,
the decision-making process

by which people communicate
with the computer.

This kind of power
comes with great ethical responsibility.

There's nothing like doing it.
There's nothing that substitutes for it.

You know, much the same ways
that builders of a city

determine how your life
is lived in the city,

I-I think code
controls how we live online,



which basically is how we live.

Not just when we go on the Internet,
but when we contact emergency services...

or go to the doctor or get in a car.

We're all so close to code every day.

Yet only around
a third of one percent of us

know how to write it.

To the overwhelming majority,
it's a black box.

But it doesn't have to be.
So, how does coding really work?

And what new world
are we building with it?

[man] The computer.

An ingenious collection
of electronic hardware

was created by man.

[second man] It is not that we do not have
adequate machines to solve our problems,

but rather we lack adequate descriptions
of how to solve our problems.

[woman] When someone says coding,
you think it's really, really hard.

[man] It's very important
to really remember

everything you use on your computer
was created by some human being.

Let's say an alien came, and you're like,
"Okay, what's the importance of code?

What is it? "I'd say," Well, you know,
we live on this sort of physical earth,

and about 50 years ago,

a small group of people
started building another planet.

But it wasn't physical, virtual planet.

Look around the street. You see
all the people walking down the street

with their head bent down
and staring at their phone?

They're actually in that other world.
So, that's what code is.

It's the building blocks
of that other world."

This loom is the ancestor of every
computer and smartphone on Earth.

It was invented in 1804,
and the big innovation was these cards.

The holes in each card
allowed only certain pins to pass through.

With thousands of holes
on hundreds of cards,

weavers could do more complex patterns
than they could before.

Elaborate shawls
became all the rage in Europe.

And woven designs could be so intricate,
they looked like drawings,

like this one of the loom's inventor.

Before these looms, individual strings
had to be selected by hand

by "draw boys."

Math back then was done by hand, too,
by so-called "computers."

The first computers were people.

And the best machines we had to help us
could only do one type of math problem,

like the abacus
for adding and subtracting.

British mathematician Charles Babbage

wanted a machine that could do
any math problem you chose for it to do

or rather "programmed" it to do.

He proposed a machine
he called "The Analytical Engine."

Babbage's idea
would earn him a place in history.

Computers were invented first by Babbage,

a very eccentric British inventor.

Babbage had inspiration
for how it would work.

He kept a copy of this picture
hanging in his house.

Babbage's Analytical Engine,
like Jacquard's loom,

had physical parts... hardware.

And also like the loom,

you could give the hardware instructions
in the form of cards punched with holes.

The holes let pins in,

and the absence of holes
forced other pins backwards,

setting off a chain
of mechanical calculations.

The cards with their different holes,
that's software.

Babbage never finished
his Analytical Engine,

but a young woman working with him

saw its world-changing potential
way beyond just math.

Ada Byron, Countess of Lovelace, wrote,

"The bounds of arithmetic were outstepped

the moment the idea
of applying the cards had occurred."

She saw what Jacquard saw...

The holes could represent
more than just numbers.

They could be patterns, music...

or entire sentences.

You can think of it
kind of as Morse code.

Each letter in the Morse-code alphabet

is expressed as a set
of only two signals...

[short beep] or [long beep].
It's binary.

And with just those beeps,
we can say anything,

like this distress call
sent out by the Titanic in 1912.

SOS doesn't stand for anything.

It's just incredibly simple
to send in Morse code.

[Andy] You can equally well think
of every letter

could be expressed as a combination
of zeros and ones.

[Kloss] Look familiar?
This is binary code.

And it's how we bridge the gap
between machines and human language.

Each one or zero
is a binary digit or "bit."

These are the atoms of modern computing.

You may know them by another name...
Eight bits is a byte.

So, you know that picture on your computer
that's 1.1 megabytes?

That's 8,800,000 ones and zeros.

Like Morse code's dots and dashes
are just a way to write down

[long beep] and [short beep],

binary code's ones and zeros
are just the way we write down

what's really happening
in a modern computer...

Charge or no charge.

This is a simple electrical circuit.

Imagine millions of these
all working together.

That's a computer today.

On an electric circuit, this is a bit.

Is the light bulb off? Zero.

On? One.

Computers only understand electricity,

so everything coders do with computers
is, in the end,

just a series of on-or-off charges.

It all works because,
strung together in just the right way,

those charges can represent logic.

[man] Basically, logic is
a predictable series of facts or events,

such as closing this switch...

and this one to ring the bell.

[bell rings]

In fact, computer people call this
a logic AND circuit.

[Kloss] Or a logic gate.

Let's see if I can do this
without burning a hole through this table.

In an AND gate, both circuits
need to be closed for the light to go on.

And there are OR gates,

where the light goes on
if just one of the circuits is closed.

You can put this another way.

If one of these circuits is closed,
then turn on the light.

That kind of if/then statement,
that's an algorithm.

In pop culture today, the word "algorithm"

causes lots of confusion.

We've seen this before,
uh, where the algorithms go haywire.

The way algorithms work
is something of a mystery to most people.

What the heck is an algorithm, anyway?

[Kloss] But an algorithm
is really just a set of directions.

Imagine walking to the store.

You could take a left
and then take a right.

Or you could just take a right,
then turn left.

Or you could also take four lefts,

run around the park, cross a highway,

and then take four rights again.

Just like there are different directions
to get to the same place,

in coding, there can be
many different algorithms

to solve the same problem.

The goal is to find
the most elegant, efficient one.

Beautiful code doesn't repeat itself.

It's very elegant. It's powerful.

Computers running algorithms
just did what we told them to do,

but so much faster,
which made people so much more powerful.

When scientists first began to develop
the fusion bomb,

they primarily used human computers.

But then they turned to this one...

The ENIAC computer ran
thermonuclear calculations for six weeks.

Its results contributed directly to this...

The first successful test in 1952

of a bomb hundreds of times more powerful
than the atomic fission bombs

dropped on Hiroshima and Nagasaki
during World War II.

The power to code
amplified people's ability to do

what they chose to do.

But in the 1940s,
it was still a lot of work.

[Andy] Writing programs in zeros and ones
clearly doesn't scale.

[Kloss] People wanted more
of the power coding gave,

but they wanted an easier way to code.

The story of coding since then

has been the story of making code
closer and closer to human language

by inventing what nearly all coders today
actually use... programming languages.

Compared to ones and zeros,
these languages are pretty abstract.

Abstraction's a word
that's tough for people.

More abstract languages
boil down to the same ones and zeros.

We've just found better ways
to organize them.

You can think of it in terms of biology.

Humans are incredibly complex,

but 99% of our bodies
are made up of only six elements.

[Alan] And you can
work your way up to large molecules.

Between that layer of organization

and the one that is
the simplest living thing

is actually a bit of a jump.

[Kloss] And humans have brains
which do things so advanced,

it's hard to believe
they're still made of the same stuff.

Computers actually are rather like that,
but are much simpler.

So that is the good news.

The story of coding
is the story of moving this box up,

moving away from binary
to give ourselves easier, faster,

more powerful ways to code

without having to deal with
or really even understand

the binary and logic gates beneath.

That's what allows coders to make
the products we're all familiar with.

The first step to get there was...

[Andy] "Assembly language,"
which is much easier to read and write,

where you say
instead of 0-1-0-0-0-1-1-1,

let's call it "add,"

and then have a program
called the assembler

translate the letters A-D-D

to the appropriate
equivalent zeros and ones.

[Kloss] At this level, binary
is organized into letters and numbers,

just like atoms
are organized into molecules.

But coding in assembly language
still wasn't exactly easy,

because all these computers
used different assembly languages.

If you wrote a program for one computer,
it wouldn't work on any of the others.

Very quickly,
people started thinking about,

"Well, what we really
want to give the computer

are things in terms
that we actually use every day."

You have programming languages

that we built using the assembly language,

and then from those programming languages,
we build more programming languages.

You've probably heard their names.

- LISP.
- BASIC.

- Java.
- C++.

- [man] Python 3.
- HTML 5.

PEARL. PHP. A little bit of C.

Just like how spoken languages
are different ways

of expressing the same idea
to other people,

programming languages

are just different ways of expressing
the same idea to computers.

[Andy] We have more than one
high-level language,

because, first of all,

different languages
address different needs.

[Kloss] Take a look at these two.

This one, COBOL,
was created in the late 1950s

to make it easier for businesses
to use code.

It looks a lot like English,

except if every conversation
ended with "STOP RUN."

This one, CPL, was developed in the 1960s

and included more scientific computing.

It's like biological evolution.

As organisms get more complex,
they develop features

that make them better adapted
to their specific environments.

And, frankly, it's also a matter of taste.

People like different tools
for expressing themselves.

For example, the language C++.

Elon Musk... n-not a fan.

You could make one up.

This is a real high-level language
made entirely of the word "moo."

Seriously. It's called COW.

This one is made of
Arnold Schwarzenegger movie quotes.

Every time I think,
"Okay, we must be done by now,"

somebody else comes up with a new language

and it develops a group of devotees.

So I don't see any end in sight
to the invention of new languages.

And all of these languages
are still based around logic.

For example,
a coder at Netflix could say,

"If you've been watching
longer than two hours,

then display this."

But for code
to impact most people's lives,

most people had to be using computers,

which meant computers
had to be easier, friendlier,

and that required another big leap,
which started here,

in a demo given by Doug Engelbart in 1968.

[Doug] In a second,
we'll see the screen he's working

and the way the tracking spot moves

in conjunction with
movements of that mouse.

People nowadays don't program

by writing out statements
on a piece of paper

and then handing them off to somebody
who types it in.

You sit down at a screen.
You have a graphical user interface.

Today, we call them GUIs.

With GUIs, people can code
without typing at all.

Or they can just use code more easily.

You're typically operating in
a programming environment

of the type that Alan and his companions

created so beautifully

at Xerox Palo Alto Research Center
in the early '70s.

Alan. This Alan.

I think of him
as the father of personal computing

because he was the first
to really articulate that vision.

And I have to confess, at the time,
I thought it was science fiction.

When big things really get done...

there's usually a whole community.

And, boy, Park was fantastic at it.
It was just like magic.

The graphical user interface
allowed millions more people

to use computers in a way
that is natural to them.

When Xerox
first advertised GUIs in 1979,

they showed how code
could change daily life.

[man] You come into your office,

and a Xerox machine
presents your morning mail on a screen.

Soon, Xerox systems like this

will help you manage
your most precious resource...

Information.

There were people like me,

and a lot of the people
in this research community

wanted to make the world better.

They had an idea that was deeply related
to human augmentation.

Something that would interact with us,

you know, the-the public,
the-the normal person,

and make us capable of
doing more than we were before.

It did make us capable of doing more.

GUIs were a big jump up this spectrum.

And then came
the next world-changing innovation.

[dial-up drone]

A new way to distribute everything
that we could make with code.

On TV, people started predicting

what sudden access to all this code
would mean.

Imagine, if you will,
sitting down to your morning coffee,

turning on your home computer
to read the day's newspaper.

Imagine a world
where every word ever written,

every picture ever painted,

every film ever shot
could be viewed instantly in your home.

I think we're actually on the cusp of
something exhilarating and terrifying.

- It's just a tool, though, isn't it?
- No, it's not.

The most impactful software products today
make use of all these innovations.

One college student used
a high-level programming language, PHP,

to make something
shared over the Internet,

to be used on computers with GUIs.

He described it
in his first ever TV interview in 2004.

It's an online directory
that connects people

through universities and colleges
through their social networks there.

Now we're at a hundred thousand people,
so who knows where we're going next?

Where we went
was more than 2,000,000,000 people

on Facebook monthly.

Today, coders shape
literally billions of people's lives.

How they work, shop, eat, date, and chill.

What are you doing right now?

You're watching me
in a Netflix web browser.

So Netflix itself is code,

and it's being run in a web browser
that is code,

which is being run on a computer
that was designed using code.

It's-It's turtles all the way down, right?

Great code is like being
the architect of a museum

that millions of people think of

and go and walk around
and use every day.

I think there's nothing like writing code,
because it feels like pure creation.

You have an idea
for how something should work,

and then you try to sit down
in front of a computer

and make that a reality.

I think there's a lot of responsibility
for that role.

You know, you have a speed limit.

No more than 60 miles an hour.

Fine. But what if you had a car,
and the computer said...

"Well, this car is not gonna go faster
than 60 miles an hour"?

That's a different way
of controlling your behavior.

Often by controlling our choices...

code in our live exerts
an almost more profound regulatory effect,

uh, than the law can ever hope to.

And that might be a great thing.

There are around 6,000,000 car crashes
in the U.S. every year,

and one analysis
found 94% are caused by the driver.

Advancements in coding
could save millions of lives.

But they can also put lives in danger
in new ways.

I have something called
hypertrophic cardiomyopathy,

um, which is the medical term
for the fact that I have a big heart.

My heart is literally a big heart.

It is about three times the size of
a normal person's heart.

I found out when I was about 30,

and so my risk of suddenly dying by 40
was just very large.

And the electrophysiologist said,
"Well, this is no problem at all

because you can get
a pacemaker defibrillator."

This device runs on code.

A couple years ago, when I was pregnant,

my heart was palpitating.

About a quarter of all women
have palpitations.

It's perfectly normal.

But my device thought that I was in
a dangerous rhythm, and it shocked me.

Device manufacturers have no interest
in pregnant ladies getting shocked.

It is literally the last thing they want.

They just... haven't considered it.

There is this huge set of decisions...

and the people who do the programming
will be making them.

And inevitably, there will be
some combination of circumstances

that they will not have anticipated.

So, what we try to teach
when we teach the craft of programming

is how you think about
all these different conditions.

How you try to be exhaustive
without becoming paralyzed

by the number of things
that you might have to consider.

And that will only become more true,

because we've started coding
in a completely new way.

In traditional coding,
you write instructions for a computer.

But we're now able to give a computer
a bunch of inputs and a bunch of outputs

and get it to write its own instructions.

What you do is you give the computer...

a lot of examples,

and you say, "This is a party,
this is a party, this is a party." Right?

And then you have other things.
A dentist's office... not a party.

A classroom... not a party.

So then the computer looks at these

and tries to build
a classification system.

This is machine learning.

These days, if somebody says
artificial intelligence,

this is what they mean.

That's a whole different
kind of abstraction

and way of doing things,

because it doesn't really fit into the way
we stack these things up.

We call them machine-learning algorithms

because the computer is creating
its own set of directions to follow.

But, of course, in the end,

they too get translated into
tiny little instructions.

Google Translate used to be
more than a million lines of code.

That's people writing
million little instructions.

Currently, Google Translate
is about 500 lines of code

- that just calls in the machine learning.
- Suppose, because of an oversight,

none of the photos of parties you put in
included any black or Hispanic people.

The computer could decide
that a rule of parties

is only white and Asian people
are invited.

There's a lot of white
and Asian guys who program.

We should absolutely expand
who gets to be in that design room

for a million reasons.

They will ask better questions
if there is more life experience.

But, in the end, if you're feeding
your machine-learning system data,

say, criminal-justice system that has
structural racism built into that data,

and let's say
your machine-learning programmers

look like a Benetton ad,
different races, different sort of faces,

different social backgrounds,

that machine-learning system
is still gonna learn from the data.

Without people
actively correcting for that,

historical data will lead us
to repeat the mistakes of the past.

The story of coding
is one of human ambition and creativity.

[man] Liftoff of the Falcon 9 rocket.

We have seen
what we thought was unseeable.

A black hole.

We're building a new world
with more and more intuitive tools

that a greater number of people can use
to help make sure that world is better.

We have been on a journey

to make computers more accessible
to human beings

and to a greater set of human beings.

We're seeing this revolution play out
before our eyes in the past 50 years,

and that's why it's so exciting
to be alive today.

It's very important to really remember

everything you use on your computer
was created by some human being.

You can be one of those people, actually,

and it's really important
you become one of those people.

You can actually change the world
in a really fundamental way.

There's a world that's gonna be run

using machine learning
and data and traditional coding

in more and more ways.

And what we have to do
as a society is say,

"Okay. We've got this
potent new technology,

and in some ways, it could be great,
but it's not gonna be great by itself."

[closing music playing]