Google I/O 101 Q&A: Ruby on Rails for YouTube for Education


Uploaded by GoogleDevelopers on 19.06.2012

Transcript:

LOUIS GRAY: Good afternoon.
Louis Gray here from Google Developers Live in Mountain
View, Googleplex.
I want to talk here with JJ Behrens.
He's a developer advocate for YouTube APIs.
Welcome, JJ.
JJ BEHRENS: Thanks.
Nice to see you, Louis.
LOUIS GRAY: Good to see you.
I love this new studio.
We're just kicking off today.
JJ BEHRENS: It's pretty exciting.
LOUIS GRAY: So you're the first one to talk about this.
We're getting prepped for Google I/O next week, running
through our tutorials.
And you went ahead and did a talk on Ruby on Rails, and
specifically how it applied to YouTube and education.
JJ BEHRENS: That's right.
LOUIS GRAY: So what I want to do is go ahead and have a
quick conversation with you and explain, how does Ruby on
Rails involve with YouTube and education?
Maybe you can walk through that for us.
JJ BEHRENS: Yeah, so I talked about this a little bit in the
talk itself.
It's a little bit strange talking about
Ruby on Rails at Google.
Because if you look at our jobs postings, oftentimes
they'll mention Java or C++ or Python.
But not very often will they mention Ruby.
And definitely, I don't think I've ever seen
them mention Rails.
And then, if you look at Ruby on Rails talks, oftentimes
they're talking about Heroku and Amazon EC2.
But they don't spend as much time talking
about Google APIs.
And since I kind of straddle the fence--
I do a little bit of Python, a little bit of Ruby on Rails--
I wanted to change that.
I know that our YouTube APIs work perfectly well in Ruby.
And so I wanted to show people how it's done.
LOUIS GRAY: Now, one of the questions I know a lot of
people run into with YouTube, because they have a certain
expectation of what that site represents--
people look at it as for entertainment or for news.
What does it have to do with education?
Because you took a very specific approach to this.
JJ BEHRENS: Yeah, well, strangely enough, YouTube
actually can be used for things other than just cats.
LOUIS GRAY: Although we like the cat videos.
JJ BEHRENS: Not that cats aren't--
yeah, we like the cats.
The cats are important.
Those are a staple of our business.
But education's important.
I actually have six kids.
And so education is really important to me and especially
scalable education.
I want good, high-quality, scalable education.
And I think that video makes that possible, scalable.
You have a great lecture.
You get it on video.
And you know you can reuse it over and over again.
One of my favorite examples are the lectures by the MIT
guys, Structure and
Interpretation of Computer Programs.
These are like a staple of good computer science
from the MIT guys.
And I watched those videos all the way through.
And I feel like I got just a little bit of an MIT education
out of those.
LOUIS GRAY: And that's something--
I don't know if you can put it on the resume--
but it sounds like a good place to find out [INAUDIBLE]
[? education ?] and expand your [? world ?]
knowledge.
What do you think about TDD?
When we went through your talk, you
talked a lot about TDD.
And I know people are curious about this.
Does Google use it?
How does it get involved?
JJ BEHRENS: So test-driven development is a way of
developing software in which you write the test first.
And then you watch it fail.
And then you try to write the code so that it
makes the test pass.
And then, once you're passing, then you refactor the code so
that it works better.
And Google's a big place.
And we have a lot of engineers.
We have the saying that, you get two Googlers in a room,
and you'll have three opinions.
And so of course, not all of them are going to agree on one
particular way to develop software.
But testing at Google is incredibly important.
And so a lot of people do use test-driven development.
And even those people who don't use test-driven
development find that writing comprehensive tests is an
incredibly important part of their job.
And so I wanted to talk about how to do test-driven
development with web APIs.
Because that's hard.
If you've ever used the YouTube API, the responses
that it gives you are very complex.
They're large.
And so it's hard to figure out, what response
am I going to get?
I don't know ahead of time until I actually try it.
And so a part of the talk is showing people
how to get the response.
So that they can play with it and then integrate it into
their tests.
So that they can do test-driven development with
realistic responses from YouTube without actually
requiring a network connection in order to run your tests,
LOUIS GRAY: Test-driven development sounds a lot like
Google's approach to launching and iterating.
Yeah, you get it out the door, and you continue to improve.
For me, at least, when I took something
resembling computer science--
I didn't get the kind of BS degree that most of us have
around here--
but my tests always seemed to fail.
And I couldn't ever understand.
You would look at creating content and creating code.
And writing it on a sheet of paper didn't make sense.
It was always about putting it in the machine, and trying and
trying, and seeing where did it break.
Is that something that you see fits in with the corporate
culture in terms of testing and iterating and accepting
something that needs some iteration going forward?
JJ BEHRENS: Well, it's funny that you mention that your
tests always fail because I have the opposite problem.
I like to spend tons of time writing code.
And then I code review it.
And it's perfectly polished.
All my tests pass.
And then the first time I give it to a user, it blows up in
front of me.
And so definitely, test-driven development is a way so that--
the programmer who's writing the software codes
it to be one way.
And the tests verify that it behaves that way.
But then when you need to change it, the tests protect
you from breaking software that used to work.
And when you get code that's as large as it is at Google,
that becomes really important.
We have just a couple engineers around here.
And so we have to be able to work together.
And so we have to be able to extend software written by
someone else without breaking it.
LOUIS GRAY: Absolutely.
Now, when you were talking, you mentioned version 3 of the
YouTube APIs.
What can you tell us about version 3?
Why is it significant?
I know a lot of times you look at iterations and they have
point releases.
What's going on in version 3 that made this the one you
want to talk about?
JJ BEHRENS: Oh, well, you're always trying to get me to
leak information.
That's how we make these videos sell, isn't it?
LOUIS GRAY: Absolutely.
JJ BEHRENS: So currently, the YouTube API is at version 2.1.
And version 2.x has been out for a long time.
But we have some interesting talks going on at Google I/O.
I will say that much.
And another thing that's kind of interesting is that if you
look at a lot of the newer Google APIs, such as the
Google+ APIs, they have this very, very nice client API.
What do you call that?
A driver, whatever--
client library that's really nice and that the client
library automatically updates itself to match the API so
that the client libraries don't go out of date.
And so this is a problem that we've had in the YouTube world
for a long time.
And that sometimes we'll make changes in our API, and the
REST API will be very well-documented, very, very
functional, super, super stable.
But the client libraries sometimes lag a little bit
behind, especially since we have to support so many
programming languages.
So this problem kind of goes away with the
newer client libraries.
They will automatically adjust themselves to whatever the API
currently is.
And so I really look forward to a future with up-to-date
client libraries.
LOUIS GRAY: [? Now, Jerek ?] actually had a question.
You were getting close to this issue.
We were talking about dynamic languages a little bit ago.
So [? Jerek ?] was saying, he's told the time save with
dynamic languages such as Ruby can be invested in better test
coverages, which leads to better software.
Do you think that that's true?
Or do developers usually take that time savings and just go
watch more YouTube videos?
JJ BEHRENS: Well, it's tough because I try to do a little
bit of both.
I do want to watch those YouTube videos, but--
yeah, this is a way of thinking that's been popular
in the programming world for a while.
I think it was Bruce Eckel.
I forget.
The guy who wrote Thinking in Java, who first
pointed this out.
And I think that this idea is popular in the Python world,
but it's even more popular in the Ruby on Rails world.
The Ruby on Rails world--
of all the programming communities out there, they
seem to be the most devoted to testing and test-driven
development.
And so Ruby on Rails lets you program
software incredibly quickly.
And yet it could turn to mush pretty quickly if you don't
keep a hold of it.
And so using test-driven development with a very, very
strong test suite is how you keep the wheels from coming
off the cart that's flying down the road
at 70 miles an hour.
LOUIS GRAY: And is that why you use a debugger to code how
to do this?
JJ BEHRENS: So the debugging trick is
kind of a funny trick.
And I did this even before I was a Ruby on Rails developer.
When you're coding in a very dynamic programming language,
there's so much stuff that's going on at runtime, you just
can't statically analyze the code in order to figure out
what's going on.
So much stuff is being injected and metaclasses, and
all kinds of funky stuff--
metaprogramming happening at runtime.
And so sometimes the only way, the only source of truth, is
the actual running program.
And so I discovered years ago that the best way to write
software is fire up the program, get it going, and
then dump yourself into the debugger in the middle of the
running program.
And then look around.
Play around with what variables you have.
And the debuggers for Python and Ruby aren't like the
debuggers for C, where it's just a way
to inspect the state.
Rather, they're shells.
So you could write code in them.
And I use this trick to write lots of code in the debugger,
get it all working, and then copy and
paste it into my program.
Great trick.
LOUIS GRAY: Now, I'm going to get you back to version 3.
See, I was trying to get you to leak stuff before.
But if I continue to ask you, you'll keep leaking.
And so we were talking about client libraries before.
What do the client libraries have to do with version 3 of
the YouTube API?
JJ BEHRENS: So the big key here is we're going to be
talking about version 3 coming out.
And it's based on the new API infrastructure.
And Google has this new API infrastructure that's used by
some of the newer Google APIs.
And because we now have this common API infrastructure, we
have things like consolidated developer keys.
But this new API infrastructure is also what
makes it possible for all the APIs at Google
to behave the same.
We'd like it if we could get to the point where a developer
knows how to develop with Google APIs.
And when he needs to use a new API, it just
kind of makes sense.
Because it works like everything else.
And he doesn't need a new client library
for every new API.
He could just use his existing client library because that
client library should just automatically know how to work
with that API.
And that's the goal.
It's slowly taking place at Google.
Some of the products have already moved over, and I
think we're going to see a lot more of that.
LOUIS GRAY: Now, [? C Truman ?]
from LA was having a question, fired it over the moderator.
Beyond education, what are some other app ideas that
could be implemented using YouTube APIs
with Ruby on Rails?
JJ BEHRENS: Oh, that's a great question.
So it's funny.
When I first did this talk, it's like I had this goal.
I wanted to talk about education because I wanted to
spend a little while devoted to education.
And I wanted to talk about Ruby on Rails.
And I was like, how the heck do I do these two things at
the same time?
Because I only have a fixed amount of time to write some
software, give some talks.
How do I do these things at the same time?
So I was like, whatever.
I'll just do both of them at the same time.
But the fact of the matter is, you could write educational
apps in Python.
And you could write non-educational
apps in Ruby on Rails.
It doesn't matter.
By having the one talk, I address the two different
things at the same time.
But mix and match.
There's lots of different ways to do education and lots of
different programming languages.
And there's lots of different things that you could do with
Ruby on Rails other than education.
LOUIS GRAY: I'm going to ask you a different question.
Now, you've been at YouTube for about a year.
How would you say YouTube is a little bit different,
possibly, than the rest of Google?
What's really unique about being a developer there and a
developer here?
JJ BEHRENS: It's funny.
It's a subtle thing.
We like to say that it's a ghetto in the good way.
My grandmother came from a Russian ghetto.
And it was a nice place for her, according to her.
She says, everyone knew each other.
Everyone liked each other.
YouTube, that's definitely the case.
We are a little bit of a niche.
My key card does still work in all the
different places in Google.
And that's good because I like to eat at all
the different cafes.
We do have a lot of the same--
we have pretty much all the same process.
We use all the same tools.
But there's a little bit of a different focus.
I watch a couple videos a day at Google.
I don't know if it's as well-accepted in other parts
of Google to just chill out for 20 minutes
and watch some YouTube.
But it's definitely the case--
LOUIS GRAY: You can chill out, watch some YouTube videos, and
say, no, I'm working.
In case the boss comes by, you say, I'm troubleshooting.
JJ BEHRENS: Oh, yeah, that's definitely like--
although the normal trick of being a software engineer and
saying, my code's compiling, that does not work at YouTube.
Because most of our software is written in Python.
So there's no compiling.
LOUIS GRAY: That's too bad.
JJ BEHRENS: Yeah, really.
So.
LOUIS GRAY: Well, anything else we should tell everybody
before we head off and start working to get ready for I/O?
JJ BEHRENS: Oh, jeez.
Is it time to go to sleep yet?
I mean, I'm exhausted.
LOUIS GRAY: I know.
There's time for that.
That's the July 4 week, I believe.
JJ BEHRENS: Oh, is that right?
Yeah, this Google I/O stuff, wow.
It's a busy time.
I'm super excited about it.
I know we have a lot of great talks coming up at Google I/O.
A lot of great YouTube talks because I've been watching all
the rehearsals.
And I know that we're leaking as many things as we possibly
can to get people excited about it.
LOUIS GRAY: So there's lots of news coming up.
I'm sure we don't have time to cover all of it.
JJ BEHRENS: I know.
I know.
But I'm super excited.
I'm excited to see that [? keynote ?]
because even I don't know what's going to happen.
LOUIS GRAY: I won't tell you.
All right.
Well, thanks a lot, JJ.
JJ BEHRENS: Thanks a lot, Louis.
LOUIS GRAY: Thanks for spending time with us.
I appreciate it.
JJ BEHRENS: Very nice.
LOUIS GRAY: Thanks.