Google I/O 2011: Python@Google


Uploaded by GoogleDevelopers on 11.05.2011

Transcript:

WESLEY CHUN: Hello everybody, welcome to Google IO.
How is it so far?
[APPLAUSE]

WESLEY CHUN: You guys have at least one electronic device
that I don't have yet, so I'm jealous.
That's great.
I'm glad you're here.
I'm kind of surprised you guys aren't going to the Pac-Man
session or the App Engine 2.0 session.
What are you guys here for?
[INAUDIBLE].
WESLEY CHUN: All right.
So some of you guys know that I give Python training
classes, and I'm just going to tell you that hey, I'm going
to give this entire talk in plain text.
Any Vim or Emacs users out there?
Awesome.
Well, I was going to give you guys a demo of a really cool
Python tool that I actually have. I actually did create
this presentation using plain text because I, like you guys,
am a programmer and I prefer to do my
presentations that way.
But sometimes I'm not allowed to do that.
So I have a little PC that I have in my backpack with me
and I actually used that a few minutes ago, just before I
came in here.
And I used that.
I don't know if you guys can see it really clearly.
But I really don't work with tools like
PowerPoint really well.
But I work with Python really well.
And if I can make a Python script to actually help me
build my presentation, then that's a much cooler thing to
do than to have to--
like on a plane kit.
Have you guys tried to do PowerPoint on a plane?
OK, it doesn't work out really well.
So skipping to the end here.

Hopefully it's still going.
Oh, it even does a countdown and it actually starts the
slide show and it turns it into an
IO talk too, magically.
So anyway, that's what my PC does.
But it's dead now.
Because I'm using a Mac.
All right, so welcome to Python at Google.
A few intro stuff.
So some tips on social stuff, if you guys want to be social.
You could also be antisocial and not do anything.
And a feedback link, which I'll also give you guys the QR
code as well as the URL at the end.
OK, so before I start, I just wanted to let you guys know
that this talk is going to be slightly different than any of
the other talks you're going to.
I'm glad that you guys are here.
I'm glad this is at the end of the day.
You guys have gone to pre-technical sessions and I
just want this to be more informal, more relaxed, just
for you guys to wind down the day before the party tonight.
All right, there will be a lot of toys there.
So I'm going to start out with bringing up quotes from three
really well-known people, computer scientists.
And the thing that's very interesting about these three
gentleman is that they are experts in programming
languages that are not Python.
And I think they're giving us some sort of endorsement in
one way or the other.
So we'll start with Larry Wall, he's, as you know, the
creator of Perl.
So 13 years ago somebody else, why is Perl worse than Python?
And that was the answer he gave.
You can take it for what it's worth, but I was pretty happy
when I saw it.
I think the Python community, in general,
appreciates that quote.
The next one is by Bruce Eckel, he's a pretty
well-known author of Thinking in Java, Thinking in C++.
And he came up with these phrases that actually became
so popular that we decided to use them as slogans on
t-shirts at Python conferences.
So they're more cerebral, so you might have to think about
them a little bit more, but I think he's just trying to give
what his feelings were at the time that he made the quotes.
The last one is by Peter Norvig, who's a big member of
the list community.
And he also has nice words to say about Python as well.
And he also works at Google like a couple of us.
All right, so this is a slide.
It's the last time you're going to be
your favorite language.
So just inhale, sigh, and relax because your next
favorite language will be Python.
One line.
All righty, so why are you here?
Well, hopefully you heard some good word of mouth about
Python or you got involved in some open source project or
some development tool that uses a lot of Python, like
Django, App Engine.
Or you found out a lot of big companies use it, like Google
and Yahoo and NASA and Lucas Film and all those companies.
And/or specifically, you want to hear how Google uses it.
Or you had no choice because you were forced by your boss
to come here.
Hopefully that's not the case, otherwise you should be
smiling either way.
Being forced to come to IO?
Yeah, right.
Great.
OK, so I'm going to assume you are a blank slate.
All right, so apologies for all of you guys out there who
are Python veterans.
How many Python veterans out there more
than five plus years?
Wow.
That's pretty good.
Some of you guys have never heard of Python before five
years, right?
So I'm going to get the rest of you guys up to speed, so
you veterans, you guys can go get a drink
and come back later.
OK?
So the rest of the talk is going to be broken up into
four main pieces.
First, I'm going to do the quickie, high level intro to
what is Python.
Then I'm going to show you what other companies have been
doing with it, so that's Python not at Google.
And then I'll dive into specific Google things, and
then lastly, I'll talk about you.
All right, so a little bit of background about me.
I've been a software engineer for the last 20 years.
Currently at work I'm a developer advocate at Google
representing our cloud products, like App Engine.
Outside of work I'm actually a Python advocate.
So I've been teaching for 20, almost 30 years and at least
12 of those are with Python.
So I've been around the block a lot.
I have about 14.5 of Python.
And more about me later.
We have a special guest in the audience.
Up here at the front is Guido van Rossum, or [? Fee-do ?]
if you know how to pronounce Dutch.
He's the creator of Python or the BDFL, Benevolent
Dictator For Life.
[APPLAUSE]

WESLEY CHUN: And it's pretty much due to him that set my
entire career.
So I owe him at least that much.
He works as a software engineer at Google on the App
Engine team, where he works on Python libraries, API design,
UI programming, and developer tools.
He has slightly a few more years of Python experience
than I have, so I'm afraid to say.
And so he's here to keep me honest. He'll throw tomatoes
at me if I say something wrong, and he'll also
help out with Q&A.
All right, so what is Python?
In a nutshell, it's an
object-oriented programming language.
Some people like to immediately say, oh, it's a
scripting language.
But you know, I have to say, in the last 14 years, I've
used it for a little bit more than scripting.
All the way to like servers that do back end work that you
don't see, testing, automation frameworks, things like that.
So it's more than just scripting.
Of course, that's one of the things you can do.
Like many other scripting languages, Python is
interpreted, but it's also bytecode-compiled.
So when you run your script the first time, it's got to go
through that compilation phase.
But if you don't change your code the next time you run
your script, it's not going to have that start up penalty.
The syntax is very simple, yet robust. That makes the
language easy to read.
And because it's easy to read, for beginners that makes it
easy to learn.
And if you're working in a group, then it's easy to
maintain because chances are your code is going to outlive
you at your current place of employment.
And one of the last things that people say about Python
is that it is batteries included.
That means that when you download the tarball or the
zip file or the MSI file, you pretty much have everything
you need to actually get a small task done.
Don't really have to go and download anything else.
Another thing that people don't know is that Python just
turned 20 two months ago.
20 years old.
Can you believe that?
It was released on the internet around Valentine's
Day of 1991.
Maybe you haven't heard of it until recently because it's
mostly been word of mouth.
And that includes no word of mouth, so a little bit more
about that later.
But I have to say that in my experience, I've seen Python
take a pretty significant jump in popularity
over the last decade.
Especially when it comes to job listings.
I will have to say that I've been very fortunate in my
career to have been able to work as a software engineer
using Python as a primary development tool to actually
build real products that people use.
But finding those jobs is actually pretty difficult, or
at least it was 10 years ago.
But that's not as much the case anymore.
A couple of years ago Safari Books Online asked me to give
a webinar on Python and it was kind of odd for me because I'd
never been asked.
I've never been approached to do that before.
And I asked, why are you guys asking me to do a talk on
Python now?
And they also said that we've all noticed a jump in
popularity what Python as well.
And I asked them, so what are the top search terms that
people use when they go and look for
another book to download?
And they gave me the list. You can see there, pretty
interesting list. I'm expecting Android and Chrome
to have creeped into this over the last two years.
It's also become a fan favorite.
So for people that actually do discover Python, they have
really good feelings about it.
So TLB is one of those marketing things where you can
either decide you like it or you think
it's complete hogwash.
And so what they do is they sort of take a measurement as
far as, what is the market share
for programming language?
and these things like, how many times has it been
downloaded?
How many books are out there on it?
How many companies are using it?
Things like that.
And so they get this list together and they sort them in
that order.
You'll find at the top there's of course, Java, all of the C
type languages, like C, C++, C sharp, PHP.
And then around six and seven, you kind of see Python
alternating with objective C as you can
probably imagine why.
So hopefully we end up winning overall.
But one interesting factoid is that it's actually won the
language of the year twice.
It's actually the only language that has taken that
honor twice, or at least more than once.
People in the Linux community seem to like it as well, so
it's been winning a lot of awards as of late.
And so you'll probably see that trend continuing.
But Python isn't just restricted to Linux.
You can actually get Python on most every platform.
So if you have a Mac or a Linux box, you actually
already have Python installed.
So the only users that really have to go and
download it our PC users.
But yeah, exactly.
And in all of the exotic platforms that you can't even
imagine, it kind of blew my mind when I was told that the
Sony PlayStation and Nintendo GameCube back then had Python
on it too, or people imported it.
So it's been gaining mindshare.
A couple of announcements that came out over the last couple
of years that have also kind of made people jerk their
heads, do a double-take.
Like, oh, Python.
Now I've heard of it.
One of them was when App Engine came out, three years
ago, believe it or not, Google App Engine is three years old.
And that launch with Python as its first language supported.
And it included some of Django, framework
and it still does.
Another announcement that has been going on over the last
few years, has been a change at MIT.
And their first undergraduate course that incoming freshmen
get exposed to, they have switched their class to
building robotics and doing robotic work.
And the library that they use is written in Python.
And so a lot of people were completely shocked because the
headlines were MIT Switches from Scheme to Python.
And as a computer scientist, I definitely respect Scheme and
I think it's definitely more of a pure, functional
programming language that you should learn before going to
something more practical like Python.
So that's maybe not that big of news, but to the bloggers
and the media, everybody just grabs onto that and says, oh
my gosh, Python must be popular now.
All right, so where did Python come from?
So several decades ago Guido was at the Math and Computing
Research Institute in Holland.
He was working on the Amoeba distributed operating system.
And he wanted a tool to write lots of apps with and to do
system tasks and things like that.
But when you're on an experimental operating system,
there's really not a lot of support.
So his choices were either using C or the Bourne Shell.
Now, doing things in C, can you imagine writing like a
little sys admin script using C?
A little bit of overkill, right?
So before that he actually worked on another language
called ABC, which was going to be like the next generation
educational language to teach kids how to program.
And so what he really wanted to have was something that had
a simple syntax, but had the system capabilities of C.
And so that's sort of the foundation of
how Python got started.
And he started working on it around the holidays in 1989.
Another interesting factoid is that Python is named after the
British Comedy Troupe and not a snake, even though snakes
appear on 85% of all Python books out there.

So I mentioned ABC and Python's place with education.

It is again, heavily inspired by ABC, this simple, yet
robust syntax.
But there is a strong belief in education as well.
One of the essays that Guido wrote back then was computer
programming for everybody.
And this proposal actually ended up
getting funding as well.
But his belief is that programming is a basic skill.
I mean it's something that should be taught to children
at the same time they're learning
how to read and write.
Now the whole purpose is not the turn everybody into
software engineers.
It would be kind of scary if the world was
full of software engineers.
But the thing is, look at how you guys live every day.
When you go home, your everyday life has some sort of
programming.
You've got to cook your dinner in the microwave, you've got
to set your thermostat.
You've got to learn how to use your cell phone.
You've got to program your TiVo to record
your favorite shows.
There's some of programming.
So the main idea is that you should learn programming.
Not, again, to be a software engineer, but the fact that it
is a basic skill that people have to have every day.
There was one great story actually.
I don't know how many of you guys grew up in America.
But in high school there's a computer science advanced
placement exam.
And there was this instructor from Washington D.C.
area, Jeff Elkner.
And he recounted the story of how he has to take two years
of C++ to teach this to high school kids in order to
prepare them for this exam.
Can you imagine how excited the kids were
learning C++ for two years?
So the kids were dropping out, they were losing interest. All
the girls left.

And so what he did was he actually replaced the first
year with Python and the retention was better, the
morale was better, people were able to learn.
The students were able to learn C++ much quicker.
They did better on the exam.
So that was a really inspiring story.
So again, related to teaching kids how to program, people
ask me, so what are some of the programming languages that
people use to teach kids how to program?
So we have Scratch, which is based off of
Squeak from Alan Kay.
I don't know if you guys have seen that, but it basically
teaches you programming by having you build jigsaw
puzzles and snapping pieces together,
which is really cool.
And that came out of MIT.
And then Alice is another popular language that
originally came from University of Virginia.
It was written in Python and it migrated eventually over to
Carnegie Mellon.
Python's in that list of course.
When I learned Basic many, many eons ago, I learned Basic
on Commodore machines.
And some high schools actually also teach kids how to program
using Flash and Action Script.
Now, that may make you kind of think about it, but don't
think too hard about that.
And so when I go to schools and I talk to kids, they ask
me, so, what are the programming languages that you
grown-ups use to get work done every day?
So that list is up on top.
So the usual C family of languages, Java,
PHP, Python, and Ruby.
And of course, it's not as surprising, you must have
already noticed that Python shows up in both lists.
So the conclusion is, if you don't know Python and it was
made for children, and you're a technical professional, I
don't think it's going to be that hard for you to be able
to pick up Python.
So that's the whole point.
If you've never seen any Python code before, here's a
quickie demo.
And again, even if you've never seen one line of Python
before, you should be able to kind of figure out generally
what this is doing.
So the first thing you'll notice is that instead of
using curly braces to delimit blocks of code width, it uses
indentation.
Now for me coming from C and Java and PHP, at first that
made me kind of shiver.
But after four months, I was OK again.
I just needed to kind of recover.
And when you realize that it's an impossible thing to have a
dangling [? ELs ?]
problem, that's when you truly appreciate this because your
[? EL ?]
statement has to belong to one of those two if.
And it's the one that it lines up closest with, or has to
line up exactly with.
So you can see that this is a function.
Def is the keyword the creates a function.
I'm going to create an integer with the value 10.
I don't have to predeclare anything.
It's dynamically typed.
I'm going to open a file for write.
You can already use your imagination and think, oh,
this must be exception handling in case this file
can't be opened--
if this disk didn't exist or I didn't have write permissions,
I'm going to get an error and jump back from this function.
Once everything goes through OK, we have a for loop.
And the for loop uses the range built in function and if
you're coming from a language where the for loop is a
traditional counting loop, you'll be familiar with int i
equals 0, i is less than 10, i plus plus.
So in Python you would rewrite the same thing by just copying
those numbers down into the range function in their
appropriate slots.
And you'll get the same effect.
Now the for loop in Python is more like a shell script for
each statement where you're iterating over
objects, not counting.
So the range function was created to be able to help
Python simulate a counting loop.
And then we just output to the file, i times factor.
And I do a quick check to see if i is divisible by 2.
Is there a remainder?
And if there isn't, then it's an even number.
If not, it's an odd number.
And those of you who are really sharp will probably
notice that if I multiply any number by 10 it's always going
to be even.
So double check that.
And then you close the file at the end.
Fairly straightforward, right?
For those of you who are new to Python, was that OK?
Everybody able to absorb it?
Not too bad.
I mean the code is a little bit more crowded than I wanted
to, but I wanted to show you as many different things and
not make it too overly complex.
All right, so community.
So that's Guido right there in the red if you
didn't guess by now.
OK, so he's a fearless leader.
One of the really good things about a programming language
that nobody ever talks about is the community.
Now when you're learning a language and getting involved
and you have questions, you don't want to get onto a
newsgroup where people are completely yelling at you,
they're criticizing you, they're laughing at you.
That's not really fun.
So in general, the Python community is very open,
welcome to people.
Whether you're a new programmer or you're a refugee
from another programming language like Ruby.

There's one newsgroup, there's an IRC channel, and even if
you still are a little bit timid, there's another mailing
list called Tutor, which is really great.
Sometimes I volunteer on that when I get a chance.
But that's a mailing list specifically made for people
who are not only new to Python, but also perhaps, new
to programming as well.
The general personality of people in the Python
community-- we don't really fight that much, we don't say,
our language is the greatest on earth--
even though it is.
And we do know the flaws of our favorite language.
I think that's very important.
And we do have strong debates.
Hopefully they're mostly non-destructive.

And because the community is so open and welcome, that
means conferences are easily attendable by anybody, by
everybody in this audience.
PyCon is the main one that we have here in North America.
But there are also localized PyCons around the world.
There's also EuroPython, which I would recommend you guys go
to if you can.
It's going to be in Florence next month.
So I'm pretty excited be going there myself.
And then OSCON, The O'Reilly Open Source Convention that
takes place in Portland in July.
I'll be there as well, so if you can't make it to Florence
then go up to Portland so I can see you guys.
If you're a beginner, tutorials are great.
In fact, tutorials are so popular that we actually
started to do two days of tutorials.
I've never heard of that at a conference before.
But it could be because I don't go to enough
conferences.
But all of the PyCons are grassroots efforts; they're
all done by volunteers.
There's even financial aid to help you guys afford to go
there, whether it's paying for hotel, or travel, or what not.
And we also have grants because again, we're a very
open and diverse community and want to keep it that way.
All right, so some of you guys may have heard of some of
these more well-known Python programming projects.
I'm not going to go over them all, but they kind of indicate
to you what types of breadth exist as far as software
support goes.
All kinds of things for numerical processing and
working in different environments, working with
databases, testing frameworks and things like that.
[INAUDIBLE]

WESLEY CHUN: It's in white font.
So yeah, so that's the only problem.
What you should really should be asking is, where are all
the web frameworks?
I couldn't put them on this page, so they had
to have their own.
Because Python is a language that has more web frameworks
than keywords.

And that quote is old.
There's at least twice as many now than he realized.
So yeah, lots of different things.
And so based on all the things that I just showed you, you
can use Python for all of these things and many things
that are not listed here.
I mean, I have a list of things that
completely blew my mind.
When you go to a Python conference and you hear about
these things, it really makes you wonder like how we didn't
hear about these things.
So Python is used to map sparse galaxies with, it's
used to analyze weather patterns, to control
underwater robots.
And here's a really good one, to help interpolate damaged
musical scores from the 19th century.
Crazy stuff.
And the good news is that most of these types of apps can be
done just by downloading Python because it
is batteries included.
Yes, in certain cases you'll have to go and download third
party stuff, but most of the time you don't have to.
At least you can get started without the third party stuff.
All right, so now that I've told you a lot about the
language, let's talk about some
places that do use Python.
Not at Google first. I've used it at lots of places.
Because like I said, I've been doing
Python for like 14 years.
And I've done all kinds of crazy stuff.
So one of the first things I've done was
while working at Yahoo.
And now, a lot of people don't realize this but we actually
built Yahoo Mail using Python about 14 years ago.
Two-thirds of it was Python, the back end mail store was a
little bit of C++.
But all of the middle ware and all of the front end, we
actually custom made our own web framework before that term
even existed.
And there are only about 9 or 10 of us and we built the
whole thing in about half a year.
And you're probably wondering about the image.
The original version was called Rocket Mail.
Does anybody remember that?
OK.
Who still uses their Rocket Mail account?
Not the refresh of it a couple of years that Yahoo did.
OK, that's great.
We were working there and then Yahoo decided they liked web
based email and they acquired us instead of Hotmail because
we focused on having a better user experience than Hotmail.
So another thing that I've done is I've worked at another
company called IronPort, which was acquired by Cisco.
And they built a hardware appliance that filtered email
for spam and viruses.
And we used the custom made version of Python and we were
able to process 500,000 email messages per hour.
So it was a pretty cool thing.
It's not exactly this box.
I can't show you a picture of the real box.
But I have some ex-coworkers in the audience here that can
vouch for this.
So that's a little bit different than--
well, I guess it's related to email as well.
But more on the hardware side.
Before I came to Google, I worked at Slide.
So we do Facebook games.
So my career has been internet and networking and all that
stuff so far, but then the craziest thing that I've never
done with Python is to write software for doctors to help
analyze patients with spinal fractures.
Very different.
I learned a lot about medicine and I was always curious why
they hired me.
Because I told them I had no medical background.
And said, well, you know what?
It's a lot easier to find a Python person and teach them
medical stuff than it is to find a medical person and
teach them programming.
So I go OK.
So anyway, if you need to know anything about osteoporosis
and your spine, come talk to me afterwards.
We also have some other software that I wasn't
responsible for that [? thioridazine ?]
knee cartilage stuff.
So as a software engineer, I'm not that great at
documenting my code.
So Python had to do something really crazy to my brain in
order make me want to write a book.

Yeah, it just completely changed my life.
When I was learning Python, I never had--
there were only two books on the market.
And none of them were what I was looking for because I was
a software engineer.
I knew how to program in C and Java and Tikal and Perl and I
wanted to learn Python really well.
So that's the motivation.
One of the books I wanted to highlight is the Django book
that I worked on with two other authors.
The thing that's interesting about that book is that there
were three of us.
We had never been together physically, when
writing this book.
We did the whole thing in plain text.
We used version control.
We used a make file.
We used markdown.
And then we had Python drive the whole book.
We used Python to compile the book, to suck in the source
code, and even to run unit tests across the source code
before it embedded it into the book.
And then, we used Python to generate the HTML and PDF that
we eventually sent to the publisher.
So that's another use case for Python that's very
interesting.
Python's used at lots of other companies.
Animation, it's pretty big apparently because Disney,
Pixar, and Dreamworks uses it.
All of the Lucas companies use it.
Hardware oriented companies, like VMware, Broadcom, QNX,
they use it.
Social companies use it.
Linux companies use it.
And of course, the government uses it.
And you can tell this is the government because they're all
acronyms. So the National Oceanic and Atmospheric
Administration, they run the National Weather Service.
So they're also a primary user.
And then we think that the NSA uses it, but
they won't tell us.

So as you can kind of get a sense, Python is pretty
popular with startups.
We've got many y-combinator companies use it.
I think for one main reason: very, very fast development.
And when you're running on finite time, you need to be
first to market.
So they're the ones that are helping adopt whatever the web
framework of the day is.
And a lot of companies sort of have an
anti-marketing campaign.
They're really reluctant to admit they used Python.
These days you can't really do that that much because you're
actually looking for engineers.
So you actually have to put them in your job listings.
But back in the old days, when we were at Yahoo Mail, which I
was going to give a talk at how we use Python to build
Yahoo Mail with, but management
pretty much said no.
Because there's too much competition out there.
Like Info Seek, Lycos, Excite, and we just don't want them to
know we use it.
So I was not allowed to say anything back then.
Of course since our acquisition by Yahoo, we have
since ported it to C++ and PHP and all that stuff.
But back in the old days, it was just like well, it gave us
a strategic advantage over the competition.
So we don't want to say anything.
And you would do the same too, if you had a startup.
All right, so now we get to what you guys
actually came here for.
What do you want to hear about Python and Google?
So it is recognized as an official
language at the company.
And what that means is that you can deploy Python code to
production servers.
C++ is the primary development language, but there also needs
to be some sort of tools and scripting language that gets
paired with C++.
You can't do everything in C++.
Java actually came later, so Python and C++ were a nice
pair back in the early days.
In fact, believe it or not, Python was used at Google
before the company even existed.
So back in the original paper that Larry and Sergey did,
they actually mention in their original paper that their
original web crawlers and the URL servers
were done in Python.
So you can get access to the paper there.
But it's very interesting to know that Python has been
around before the company existed.
Another quote, as the company was growing, Peter Norvig
again, he made a quote.
And that was that, "Python has always been an important part
of Google." Actually, he even told me in person, I was
talking to him the other week, and he said, yeah, Python was
here before I got here.
And I look at his employee ID number, it's pretty low.
I'm like wow.
That's pretty incredible.
So another thing is that a lot of the Python community
members are also Googlers as well.
Besides myself and Guido, Alex Martelli.
You may know that he's the author of Python in a Nutshell
and The Python Cookbook.
He also works at Google.
Jim Hugunin, he created Jython and Iron Python.
Fredrik did the current version of the regular
expression engine and the PIL, Python Imaging Library.
So many members of the community
actually work at Google.
So Google has a strong relationship with the language
and the Python software foundation.
And Google is also committed to the language because it's
always sponsoring Python conferences of various types.
And even if we're not sponsoring, we're always
sending speakers to these conferences.
And of course, we also employ the BDFL.

Like Guido, like myself, like Python, Google also believes
in education.
In fact, the internal training course--
internal Python training course that some of us give--
has been externalized for the general public.
So if you guys want to get access to the labs, lectures,
videos and lessons of this class that we take inside the
walls at Google, you can go and check it out at
that link up there.
And there are also a bunch of tech talks that have been
given at Google about Python over time, and you can get
access to those over there too.
All right, so what are some of the products that use Python?
So there's Google, App Engine, there's YouTube, there's
code.google.com, and a bunch of open source libraries.
So these are all the things I can say.
There's of course, plenty of things that I can't say.
But let's start at the bottom, take a look at some of these
open source libraries.
So Protobufs is a pretty well-known library.
If you've never heard of it before, just think of is as
being able to serialize structured data.
Kind of like XML and JSON, but more efficient.
We use it a lot for communicating to and from
client and server.
And you can go and check out the library at that
link at code site.
We also have the Google Data Protocol client library
written in Python, as well as other languages like Java and
C++ and .net and a bunch of other clients.
But there's also one specifically for Python that
let's you access your Google data.
You know, such as what you have in analytics, calendar,
maps, contact, spreadsheets.
Even other Google properties, like
Blogger, Picasa and YouTube.
And you can get access to the GDP library there.

Code.google.com.
If you're not familiar with it, you should all be because
you guys are here at IO.
So you guys are all Google developers.
This is the main website for all of you guys.
This is where all the documentation is, all the
tools, downloads, all the code samples.
And code.google.com also has a source code project hosting.
App Engine.
So I mentioned earlier that App Engine launched with
Python back in 2008 as the first supported language.
One of the reasons why Python was chosen was because it has
a simple VM and it was easily wrappable in C++ and be able
to put in a sandbox.
Also, it's easy to get started.
You know, App Engine's goal is to take a lot of complexity of
creating apps and hosting apps away from you.
And so one of the ways of doing that in addition to all
of the hardware and the infrastructure stuff that we
try to take away from you, is having to spend a lot of times
building apps.
So Python again, really encourages rapid development.
So that's another way that we're trying to help out at
having you be able to create and deploy apps quicker.
And when it came out, it caused quite a shock in the
Python and Django communities.
We were all blown away; it was incredible.
And one of the last things I wanted to point out is that it
really does not require you to have a CS or an engineering
degree in order to be effective in the language.
I think that's part of the open to all type of mentality
that the language has.
Normally I would give a demo.
I'm going to run out of time today, so I'll skip the demo.
But if you guys don't know App Engine at all, just go to
code.google.com/appengine and you'll be able to download the
stuff and be able to play with.
There's an online tutorial as well.
All right, so let's talk for a few minutes about YouTube,
They're also, a very being user of Python.
In fact, they're such a big user of Python, almost the
entire YouTube site as see by you, uses Python.
Whether you're viewing a video or whether you have software
that controls a front end and templates for the website, or
when you're administrating your videos, all the back end
API servers, the batch tools, all the test utilities, or if
you have to access any of the YouTube canonical data, that's
all done with Python.
And even if something is not Python, the glue code to put
that thing together is Python.
So Python is everywhere at YouTube.
In fact, like Google, Python was around at YouTube before
YouTube was at Google.
There was a small team, they really loved Python.
Ironically, when I was at IronPort, we actually worked
across the street from YouTube.
So two hardcore Python companies next to each other
in San Bruno, right off of 380.
Yeah, it was a small team that loved Python.
They felt that it gave the engineers a sense of
discipline and honor without having the compiler police
there to monitor them.
Their early architecture, they used Apache with
Mod_python and MySQL.
Kind of similar to when I did Yahoo Mail, we actually also
had Apache.
But we used the old [? POI ?]
Apache module back then.
And this actually lasted them for quite a while and it would
survive longer than one would think.
Until the user base grew and they started to
need to scale more.
The way they scaled was, every time they would run into a
bottleneck, they would either somehow work around it, or fix
it, or get rid of it.
They believe in using good components, good open source
tools that have been tried and tested, and to further improve
on them, to optimize them.
They learned really well how to balance machine resources
and they did a lot of caching and they had to scale MySQL in
a horizontal way that I don't know too much about.
So I'll defer you to go talk to a YouTube
engineer about that.
But they did do a lot of Python optimization.
And anytime they ran into any type of performance issues
with Python, they would port that code directly into C.
So one of the examples is they used to do a lot of hashing
using Python.
Well, you just take that out, replace it with a few lines of
C and that's not an issue anymore.
Next road bump.
They simplified algorithms that should have been not as
complex and they did thinks to help improve how efficient
that the developers were.
When they do all of these optimizations for scale-aware
code, they actually push all this stuff under the covers so
that the regular software engineer doesn't always have
to know everything about scaling.
They get a simple call like this that's very easy to code,
very easy to understand, and that's great.
However, the thing is this doesn't give you a right to go
and be sloppy and become a memory hog.
You still have to be aware of what you're doing.
Sometimes I always tell people that, you need to really
program in a low-level language like C or C++ in
order to really appreciate all of the memory management that
Python and Java give you.
So just don't be too loose with your morals.

So the bottom line at YouTube is that Python provides a lot
of flexibility.
It gave them rapid development as well.
You'll hear rapid development over and over
again in this talk.
And simplicity.
And their secret to success is just-in-time optimization.
You run as hard as you can.
When you have to optimize, you go and do it, and then you
move onto the next thing.
They like to take reliable open source software and
customize and optimize as they need.
So people always question, can Python really scale?
So some stats to think about from YouTube.
They get over 2 billion views a day.
200 million of those are mobile views.
And there are about 35 hours of video
uploaded every minute.
And actually, the real numbers are
actually bigger than these.
These are just the numbers that we can say.
So if you're curious, more curious about how Python at
YouTube scaled with Python, then take a look at that talk
given by one of the engineers at YouTube.
It's a very, much more in-depth technical talk.
So if you want to kind of dig a little deeper, I suggest you
go and check that out.

So as I kind of already alluded to on the previous
slide, proceed with caution.
Yes, I'm enthusiastic, now you should be enthusiastic about
Python because I made you so.
But you can't just drop it in where C++ and Java are.
You can't just like swap those out and expect everything to
stay the same.
Because in general, interpreted languages just
don't compare to compiled languages.
Of course, one exception is PyPy.
I don't know if you guys have heard of that.
But that is the Python interpreter written in a
restricted statically-typed version of Python.
And believe it or, no it, actually beat C Python in most
benchmarks.
So keep an eye on that project because that's probably going
to be another shocking thing that comes down the line if
you've never heard of it before.
So anyway, yes, Python has big strengths and they are
flexibility and rapid development.
Those things are the key things.
Performances and scalability are also important too, but
that's not the point.
The point is to be first to market.
You get there, then you port or optimize as necessary in
order for you to succeed.
Other places that Python shows up, originally the Google
Build system was done in Python.
There are a gazillion system administration tools that I
can't even begin to count that are written in Python.
The code review tool that engineers use to do review and
then check-ins, that's also done in Python.
QA and testing, automation, lots of SWIG.
If you don't know what SWIG is, that's the library that
helps you wrap C and C++ code in Python.
And of course, there's lots of App Engine apps.
Many of you guys are external App Engine developers, but
believe it or not, there's a lot of App Engine use within
Google as well.
And so I invite you guys to come see Ben Fried's talk
tomorrow, Coding for the Cloud.
And there, he and his team will explain how they use
Google App Engine to build apps to help
run Google, the company.
I think that's tomorrow morning.
So the last part of the talk, Python and You.
So if you're new to Python, you want to get started, of
course python.org is the main website.
Don't go to python.com.
I think some porn site took it over at some point.
But maybe that domain has finally been reclaimed by
something else.
But all of the docs, downloads, and
tutorials are there.
Book suggestions.
Of course, I recommend Core Python.
Not just because I wrote it, but the main purpose of that
is to give you the most
comprehensive dive into Python.
I want you to learn it quickly and as
comprehensively as possible.
If you don't have time for that, my colleague, Mark
Pilgrim, he's written a book called Dive into Python.
And that's what I call a quick dive into the language.
So I don't think he's here, but Mark, you can jump up if
you're here.
And if you have kids or you're a beginner and you want to
learn how to program, take a look at that
book, which is great.
It's called Hello World and it's a book written by an
engineer and his eight year old son, so it's got a kid's
perspective, which is really cool.
Lots of online videos.
The show me do videos are just one set.
But if you look around, there's all kinds of tutorials
and videos that you can use.
And for community, there's a newsgroup like I said, the
Tutor mailing list. As well as take a look at the upcoming
PyCon conferences.
Like I said, the most recent ones coming up are
EuroPython and OSCON.
And I think PyCon in Asia Pacific is coming
up in June as well.
So if you want to go to Singapore, hit up a Python
conference.

So now I have to give you a warning.
We are at the crossroads of Python.
So you guys have arrived at just the right time, I think.
There are actually two versions of Python.
There's a Python 2, which is the current version that
everybody's using.
There's also Python 3, which is the next generation.
And it is evidence that Python is continuing to evolve.
Now, one of the things that people note and people say and
all of the FUD comes up is that it's
backwards-incompatible.
Yes, that's really scary because of the two big words.
But the thing is, the language isn't changing so much that if
you learn Python 2 you can't do 3, or vice versa.
It's not like that.
It's not like the changes are so big that it's causing the
community to fragment.
It is new.
It's still a little rough on the edges,
but it's usable now.
And so, just don't freak out.
So on the earlier slide I showed you Hello World, but I
need to show you Hello World in Python 3 now.
So obviously, if you're going to change print from a
statement to a function, that's going to break like 95%
of all the code up there, right?
So of course, it's backwards-incompatible.
But is it that hard?
Is that really earth-shattering?
Not really.
Of course, I'd have to tell you there's a third way of
doing it and that's more lower level if you want to really
use standard in, standard out, standard area
you can do that too.
But you've got to import the sys module to do that.
So there's three different ways of doing Hello World.
Python's philosophy is there should be only one right way
of doing things.
So this is just one minor exception.
In other words, don't freak out.
Whether you learn Python 2 or Python 3, it
doesn't really matter.
Just pick one.
Which one should you pick?
So yeah, instead of panicking, get excited and do stuff.
We don't have time to panic.
So if you want to know where to start, if you're completely
new to the language, you don't have any dependencies, you
should start with Python 3 because that is going to be
the future.
If you have existing software or you have existing books and
tutorials, most books and tutorials are
still in Python 2.
So if you have some baggage, then stick with Python 2.
Like I said, doesn't matter.
Either one is fine.

What did I go over in the talk?
I mentioned that Python's a great first language for
people to learn how to program with.
Two of its greatest features are that it encourages rapid
development because of the simplistic syntax.
It's very flexible, there are many applications that are
written in Python that are out there already.
Specifically at Google, as well as not at Google.
Python is pretty popular and will continue to be.
There are many libraries and tools that are written in
Python and when you go and download--
when you go and look at the archives and repositories of
all the software, there's a lot of variety of things that
are out there.
And Python has a really strong relationship with education,
and same goes from Google as well.
And of course, a big plug.
Google's always hiring strong developers.
So if you're looking for work, then come talk to one of us.

I'd love to meet users.
Come talk to me.
I'm going to be speaking at these conferences, I also have
a Python training course in May or later this month.
But generally, I'm accessible at lots of conferences.
I'm either talking about Python and/or App Engine.
If you're curious about the slide generator, I wrote that
using the os, sys, time, and Tkinter modules.
I also used the Python extensions for Windows, so
that I could actually connect to PowerPoints.
People have been asking for this for years, so I promise
it will be in the third edition of my book.
And I'll also put it out as open source as well.
All right, thank you very much.
[APPLAUSE]

WESLEY CHUN: Feel free to come up to the mics.
Feel free to ask a question.
Yes, sir.
Hi.
So let's pretend there's a hypothetical startup with a
hypothetical team of smart developers who are quite split
on using Python or Ruby for a software as a service, high
availability, whatever, whatever product.
What are some words of wisdom you could give to grant weight
to the Python decision there?
GUIDO VAN ROSSUM: Oh dang, I was going to be completely
impartial about that.
You can be impartial.
GUIDO VAN ROSSUM: And say with the dynamic language
you can't go wrong.
That's good as well.
It's all hypothetical.
Maybe.

WESLEY CHUN: I don't know.
Do you like Rails or Django?

That's a good question.

I know a good number of engineers in the community, a
lot of my colleagues actually know Python and Ruby.
So they're actually a really good audience to ask, but many
of them will say, I'm pretty flexible but most of the time
I'll lean towards Python because there isn't anything
that I can't do in Python.
And they're flexible.
But they feel a little more at ease with Python and they say
the syntax is a little bit easier.
Some people have really strong feelings
against Ruby's syntax.
I don't think it's that bad.
But some people do.
I will just say prototype a medium-sized project in both
and gather feedback.
Thank you.
GUIDO VAN ROSSUM: Another thought about that topic is if
you ever imagine doing something that is not web
programming and you imagine maybe using some other third
party software in addition to the language, there is a very
wide array of software for Python that I think is--
Python is used in many areas besides web programming and
Ruby is a little bit of a one-trick pony in that sense.
Ruby on Rails is pretty much synonymous with Ruby.
So as long as you're sure that you're never going to do
anything besides web programming, it probably
doesn't matter which language you choose.
WESLEY CHUN: Good point.
Yes sir.
So you've probably heard of the Scripting Language for
Android project, which has been around for a little
while, which allows for Python apps to be made for Android.
But currently, obviously not nearly as much you can do with
that as with standard Java apps.
So I was wondering if Google has any plans of extending
that or integrating it into to Android SDK at all, or
anything like that?
WESLEY CHUN: That's a tough question because we don't
represent the Android.
GUIDO VAN ROSSUM: Yeah.
You should really ask the Android people about that.
WESLEY CHUN: We would love for that to happen, though.
Then you should try to do it.
Thanks.
WESLEY CHUN: Sure.
Who's next?
I think you're next.
Yeah, will App Engine support Python 3 at some point?
WESLEY CHUN: Will App Engine support
Python 3 at some point?
At some point, yes.
GUIDO VAN ROSSUM: Most likely yes.
I mean unless the App Engine product is going to go under
in the next five years, it will support Python 3.
When?
Well, we're looking at Python 2.7 first at the moment, which
is actually quite a huge step in the right direction.
WESLEY CHUN: It is.
One thing that I didn't mention in this talk is that
starting with Python 2.6, they're rolling in a lot of
Python 3 features.
They're back porting these features.
So 2.6 and 2.7 are really good tools to actually coding in a
more Python 3 flavor.
Why the delay?
WESLEY CHUN: Pardon?
Why the delay?
WESLEY CHUN: Why the delay?

Well, when you have a backwards-incompatible future
release, it takes a lot of time to do this porting.
You know, I'm going to call a decade.
That's 10 years.
That's a lot of time.
So Python 3.0 came out in 2008.
So I don't think the entire world will be--
I'm sure he wants it faster.
But I don't think the entire world will be on Python 3
until 2018.
So the thing is, it's not Python 2 is end of light.
So the idea is that even 2.6 and 3.0 were
developed in parallel.
So there are actually two teams that are working on it
simultaneously.
It's not like 2.7 been cut off and it's dead now.
That's not the case.
So it's not as much of a delay as it is ease of migration.
Thanks.
WESLEY CHUN: Go ahead.
In a couple areas of the Python community, I see that
there's a lot of not invented here syndrome.
My two biggest gripes are in web
frameworks and event loops.
We already have Twisted, but we still felt the need to
invent Diesel and Tornado.
Frameworks I think are even worse.
People are inventing new web frameworks every week, simply
because they don't like the way that
the other one templates.
What do you guys think of that?
GUIDO VAN ROSSUM: I think it's great because it just shows
how easy it is to develop one of those things.
And so I think, let there be competition.
Let lots of people try different ways of doing the
same thing.
Something like Twisted is the effective 800-pound gorilla of
event handling frameworks.
Anyway, it's never going to be in the standard library
because it's just a completely different level of coding.
I mean Twisted is a project with its own release cycle
that would be very hard to be adjusted to the core Python
release cycle.
So it will always be its separate thing.
There's no worry that the core will sort of take over the
market for, the niche for an event programming framework.
At the same time.
it's good that there's competition that people try
different ways of sort of doing the same thing.
I say let there be more choice.
WESLEY CHUN: Right.
The market winner will show up eventually.
Isn't [INAUDIBLE]
still in the 3.0 standard library?
WESLEY CHUN: I think so.
And I think it's been maintained.
Somebody's been patching it recently I believe.
GUIDO VAN ROSSUM: That is the only reason that is in the
standard library.
Is that there are some people who use it and we don't want
to sort of be gratuitously backwards compatible.
But that is certainly not what we recommend people use.
OK.
Thank you.
WESLEY CHUN: It was also created by one of our ex
IronPort co-workers too.
Yeah, I know.
WESLEY CHUN: Great, thanks.
Go ahead.
So clearly, Python is the superior language and has
seniority at Google.
How is it that Java ended up in Android and GWT and many
other projects as opposed to Python?

GUIDO VAN ROSSUM: Is that a serious question?
Personally, I don't prefer to develop in
Java, but I love GWT.
It was kind of a serious question.
WESLEY CHUN: There's Pyjamas.
Well, it doesn't work well with the GWT compiler, right?
GUIDO VAN ROSSUM: Well, sort of the reality is that the
choice of language is often a very sort of
non-rational choice.
And people tend to go with where it's easiest to hire
lots of programmers.
And that in many cases, has sort of forced the choice for
Java in many specific projects.
OK, fair enough.
Thank you.
WESLEY CHUN: Sir.
Yeah, hi.
So with an ecosystem of Python interpreters emerging with C
Python versus PyPy and then Unladen Swallow, whatever is
going on with that.
How long is the core development going to be still
done with C Python where like PyPy is really pulling ahead
in a lot of benchmarks?
I know it's not future complete yet, but are there
any plans of incorporating these other interpreters in
the core development so new features come out on them at
the same time as other interpreters?

GUIDO VAN ROSSUM: That's not really how it works.
Sort of core Python development as we currently
think of it is really C Python development.
It is a group of people who choose to work on C Python.
What might eventually happen is that more and more
individuals choose to contribute to PyPy instead of
to C Python.
We have a fair number of developers who split their
time between those two versions.
Some who started out as C Python developers are now PyPy
developers.
What I'm still sort of waiting for, I mean personally, I am
like the opposite of a speed freak.
I don't care particularly how fast it runs.
So I'm not ever going to contribute to something whose
focus is on making it run faster and extremely, insanely
smart [INAUDIBLE]
optimizations.
It turns out that quite a few users of Python sort of
currently still seem to think the same way because C Python
is still more popular than PyPy.
On the other hand, we do see sort of some users move over
and I think that I don't want the development
team to drive that.
I want the users to drive that.
So if the users sort of start showing a clear trend towards
PyPy, then it's possible that eventually PyPy will sort of
compete head to head with C Python at some point.
We may say, OK, there's no need for both C Python and
PyPy because they are both sort of feature complete.
Let's focus on one of them.
And then sort of the one that is more modern and runs your
code faster would be preferred.
Until then--

again, it's the same answer as with the web frameworks.
Hooray for competition, hooray for diversity, let's see where
it all leads.
WESLEY CHUN: Great.
Sir.
What insight can you give us on the choice of Django for
App Engine as the web framework that was chosen?
GUIDO VAN ROSSUM: I think it was a coincidence.

Anything else?
GUIDO VAN ROSSUM: I mean it was a fine coincidence.

OK.
Cool.
GUIDO VAN ROSSUM: We didn't do a very careful comparison of
available web frameworks.
We probably would have decided to write our own.
Which sort of for 50%, we actually did.

Does Google use Psycho for any of your projects, and do you
consider it safe?
Is it still being actively developed?
It seemed like it kind of got abandoned there.
GUIDO VAN ROSSUM: I think there may be small pockets in
Google that still use Psycho.
I don't think that it's very popular anymore.
For App Engine I certainly would not consider it safe.
WESLEY CHUN: Same goes for YouTube.
YouTube used to be a big user of Psycho and that has kind of
wind down as well.
The lead developer of Psycho has actually
gone on to do PyPy.
He's a lead developer for PyPy now.
Yes sir.
We learned that this morning App Engine will
also support Go.
So would you like to comment on these [INAUDIBLE]
efforts within Google?

WESLEY CHUN: Are there any Go App Engine
developer members here?

GUIDO VAN ROSSUM: I didn't hear the-- understand the last
half of the question.
WESLEY CHUN: He was just asking, so Go was announced as
a third run time, what were the decision making process
into deciding that?

GUIDO VAN ROSSUM: Oh, what led to the decision to offer Go as
the third language in App Engine?
That what actually purely the Go team being really gung-ho
and doing it.

App Engine has lots of sort of different parts of
infrastructure that the core App Engine team takes care of.
And it sort of turns out that language run times are
typically pushed by people who are somewhat peripheral to the
App Engine team.
So the Java run time also was initially developed by people
who weren't part of the core App Engine team.
Now they are.
I wouldn't be surprised if some Go people would also
become full-fledged members of the App Engine team.
But currently that's sort of wow, people
contribute to run time?
Great.
A new language, more choice.
That's the mantra again.
WESLEY CHUN: All right, that's all we have time for.
So if you guys have any other questions, just come see us
after the talk.