Tip:
Highlight text to annotate it
X
FRANCESC CAMPOY FLORES: Hi, everybody.
Welcome to this video.
We're going to be talking today about Pythonistas experience
learning Go.
So I'm Francesc Campoy Flores.
I'm a developer programs engineer for the Go team
at Google in Mountain View.
BRIAN DORSEY: And I'm Brian Dorsey.
I'm also a developer programs engineer.
But I'm on cloud and don't actually
have much experience with Go.
FRANCESC CAMPOY FLORES: OK, so you
decided to learn Go some months ago.
What brought you to that decision?
BRIAN DORSEY: Gotcha.
So I've been using Python for a long time.
I love it.
And-- but there's a few areas where I think, in particular,
like distributing command line apps and kind
of-- there's-- and so, in particular,
that was the one thing that I was really looking around for.
And I was looking around languages
and Go looked really, really interesting.
And in particular, having a real baked-in concurrency model
was really appealing.
Because I have to admit, I fear threads.
FRANCESC CAMPOY FLORES: Threads are-- yeah--
difficult to understand sometimes.
Yes.
So in are more generic question, why [INAUDIBLE]
Pythonista learn Go?
BRIAN DORSEY: Right.
So definitely, as I mentioned, the concurrency model
is really appealing.
And there's a lot of different options in the Python world
for dealing with currency-- both within one
process and multi-process and async
and all this other kind of stuff.
And pretty much every model is possible.
But I think it's really nice in Go, where there's
one way to do it that's baked in.
And it's a lot easier to get your head around it,
I think, because of that.
So that's one thing.
And then, of course, you've got a compiled language
that's fast.
It feels, honestly, kind of like a Python XE to me,
as a Python person.
And the approach to object orientation,
through what kind of feels like duck typing to me,
is pretty awesome.
FRANCESC CAMPOY FLORES: Yes.
So yeah, maybe it feels like duck typing.
Go doesn't have duck typing though.
BRIAN DORSEY: OK.
FRANCESC CAMPOY FLORES: Duck typing is something
that-- so as you very well know from Pythonage when
if it looks like a duck and quacks like a duck, then
it's a duck.
And if it's not a duck, it will fail at run time.
BRIAN DORSEY: Right.
FRANCESC CAMPOY FLORES: In Go, it
will actually fail at compilation time.
BRIAN DORSEY: OK.
FRANCESC CAMPOY FLORES: So it's not duck typing.
It's called structural sub-typing.
And it's kind of like if you had an explicit statically checked
duck typing.
BRIAN DORSEY: OK.
FRANCESC CAMPOY FLORES: Yes.
BRIAN DORSEY: Right.
So probably that-- yeah, that's a better way to think about it.
So I guess a good example for Python people
might be, we have something that-- we'll
say this object is file-like.
So you can kind of, op, you can read from it,
and you can write to it, and that sort of thing.
And-- but the list of exactly which
methods, can you also open it or close it,
or can you seek on it or things like that?
Which ones are actually included in that?
It's not clearly defined all the time.
And in Go, you might have an interface that is like the--
or you do have an interface.
It's the Read Writer, right?
FRANCESC CAMPOY FLORES: Yeah, there's Reader, there's Writer,
there's Read Writer.
Also, you were saying Seek.
So there's Read Seeker.
BRIAN DORSEY: OK, and so each one of those
is a specific collection of methods
with their exact signature, right?
FRANCESC CAMPOY FLORES: Yes.
BRIAN DORSEY: And so the compiler can know exactly when
[INTERPOSING VOICES]
FRANCESC CAMPOY FLORES: And then you
can write a function that receives as an argument, a Read
Writer.
And you know exactly what you can
do the map-- on that object.
You can do read and write.
BRIAN DORSEY: Right.
So locally, you're reading the code,
and you can tell what it can do.
So that's awesome.
FRANCESC CAMPOY FLORES: Yeah, that's great.
So now that you've been programming
for-- how long have you been programming in Go?
BRIAN DORSEY: I basically did a learning project
for a couple of months.
FRANCESC CAMPOY FLORES: OK.
BRIAN DORSEY: So not a huge amount of experience,
but made one little project.
FRANCESC CAMPOY FLORES: OK, so but after-- yeah,
after these couple of months, what
were the things that surprised you the most?
BRIAN DORSEY: So I think probably
the biggest surprise is error handling.
And I feel like I got surprised by that twice.
One, in that-- I had this initial reaction of,
wait, this is the modern world.
Why am I having to deal with the error from every single call,
right?
FRANCESC CAMPOY FLORES: Yes.
BRIAN DORSEY: And pretty much anything where
there's something that can go wrong-- And it's software,
so things can almost always--
FRANCESC CAMPOY FLORES: Everything can go wrong.
Yes.
BRIAN DORSEY: You get this error [INAUDIBLE] thing
back from the call, and you have to deal with it locally.
And that really surprised me.
And then I feel like working through an actual project
with it, I came to really, really like that.
So take networking as an example.
You're going to open a socket and try
to do some stuff with it.
And there's so many things that can go wrong there.
FRANCESC CAMPOY FLORES: Yes, everything.
BRIAN DORSEY: And it's kind of unclear,
looking at a local piece of Python socket code,
whether-- which errors are handled, right?
Because it could be handled locally.
It could be handled in a wrapped exception somewhere.
You have to kind of know the whole code base
to know where that's at.
And in Go, it's right there in front of you,
on the screen-- page you're looking at.
FRANCESC CAMPOY FLORES: Yes.
BRIAN DORSEY: And of course, you can decide, well,
if anything goes wrong, then I just have to abort,
because I can't continue.
But it'll be written right there.
And if you want to handle all of the various corner cases,
then that's also kind of laid out
right there in front of you.
So I've come to feel like the error
handling is very powerful.
And I almost feel uncomfortable without being
able to see it in front of me.
FRANCESC CAMPOY FLORES: So you think that now,
when you write Python code, that you write kind of ghost style
error handling in Python or not really?
BRIAN DORSEY: I'm a little more careful about the errors
that I consider upfront.
I've-- my tendency, in the past, has been to just write it
and then *** on it, and oh, OK, that happened.
Add a--
FRANCESC CAMPOY FLORES: Gotcha.
Everything that is failing and--
BRIAN DORSEY: Yeah, exactly.
And then you don't--
FRANCESC CAMPOY FLORES: I used to do that too.
BRIAN DORSEY: Yeah, still do.
But-- and I think that's kind of the way to go.
You want to have a test suite that covers all of your cases.
But I guess I feel like it takes me-- yeah, yeah.
FRANCESC CAMPOY FLORES: Yeah, so do
you think that, therefore, since you're
writing all this extra code for handling errors,
do you think that's a good thing, that's a bad thing,
it takes you longer?
Is it worth it?
BRIAN DORSEY: It's absolutely worth it.
And I feel like-- so yes, it takes me longer.
Part of that's because I don't know Go as well.
FRANCESC CAMPOY FLORES: OK.
Fair enough.
BRIAN DORSEY: But also, I think it just
takes me longer to work through the logic of it.
And overall, I feel like that's actually a good thing.
I feel like it takes me longer to work
through this flow and the cases that I need to handle.
And I feel more confident in the result.
FRANCESC CAMPOY FLORES: OK.
Yeah, that's good.
So now that you are almost a Go expert already--
BRIAN DORSEY: Two months of--
FRANCESC CAMPOY FLORES: --what could be your advice to people
that-- probably Pythonistas are curious about Go.
What could be your piece of advice for them?
BRIAN DORSEY: So the main thing, I think, would be, one, try it.
It's absolutely worth your time to learn Go,
because you will get the ability to use a new language that
complements Python really well.
But also, the tooling around Go really
helps you, like from a software engineering standpoint,
write good code more quickly, faster.
There's a whole bunch of things in that area
you can read about.
But it's really true.
And getting in the habit there, I think,
helps your habits writing Python code as well.
So we can do all the same things in the Python world.
We just have dozens of different options for each of them.
So I think it's helpful to have this one path
and get in the habit fo doing things.
FRANCESC CAMPOY FLORES: The good way to do it.
BRIAN DORSEY: Yeah, your code is all formatted this way.
And so Go has Go Format.
And Python, we have PEP8.pi.
And just use PEP8.pi.
And I think there's some good lessons back and forth there.
But the other thing I want to just kind of mention
is there's some things that are going
to feel really awkward-- weird when
you're starting to learn Go.
FRANCESC CAMPOY FLORES: Such as?
BRIAN DORSEY: So one is-- the air handling
is kind of one example of that.
FRANCESC CAMPOY FLORES: OK, yes.
BRIAN DORSEY: And there's a bunch of those throughout.
Or you look at a library, and it doesn't
feel like there's enough code there to really do
what you want to do.
And I really encourage people to give the Go way a try, right?
So give the air handling a shot before knocking it.
Actually really try to write some code
and see how it affects your experience with the code.
And if you have some library that
looks like it just can't possibly work, try it.
And I found over and over again that there was actually
plenty of functionality there.
And I was able to write the stuff I wanted to write.
So I think that has helped me, from a design standpoint,
think about, how little code can we have to make this really--
FRANCESC CAMPOY FLORES: There was this talk that [INAUDIBLE],
a very good one.
It's called "Less is Exponentially More."
BRIAN DORSEY: Ah, OK.
FRANCESC CAMPOY FLORES: So yeah, that's
exactly that point of sometimes having a little less code
is actually a good idea.
Yeah, so thank you very much for sharing your experience.
OK, so what could the Pythonista watching this video
do next if they want to learn Go?
BRIAN DORSEY: So that's easy.
Go to tour.golang.org.
We'll put the link up.
And it's a web-based introduction
walk through to the Go language that's interactive.
You type Go programs, you hit a button, and they run.
And it takes you from the very beginning,
all the way up through concurrency exercises
and everything else.
So when you have a few hours, sit down
and get started with that.
I think it's very worthwhile and really helps you read about Go.
But a couple hours doing that will really
internalize what it feels like to actually use Go.
FRANCESC CAMPOY FLORES: Great.
Well, thank you very much for those pieces of advice.
And thank you very much for watching.
Bye-bye.
BRIAN DORSEY: Take care.