WEBVTT

00:00:00.001 --> 00:00:04.520
Today, you'll learn how Patreon is helping people live their dreams, building amazing

00:00:04.520 --> 00:00:05.860
creations for the rest of us.

00:00:05.860 --> 00:00:07.260
It's time for Talk Python.

00:00:07.260 --> 00:00:09.200
This is show number 15.

00:00:09.200 --> 00:00:15.660
Today, our guest is Albert Hsu, and this episode is recorded Tuesday, January 2nd, 2015.

00:00:15.660 --> 00:00:45.600
Hello, and welcome to Talk Python To Me, a weekly podcast on Python.

00:00:46.040 --> 00:00:48.980
The language, the libraries, the ecosystem, and the personalities.

00:00:48.980 --> 00:00:51.200
This is your host, Michael Kennedy.

00:00:51.200 --> 00:00:55.680
Follow me on Twitter, where I'm @mkennedy, and keep up with the show and listen to past

00:00:55.680 --> 00:00:58.100
episodes at talkpythontome.com.

00:00:58.100 --> 00:01:03.760
This episode, we'll be talking with Albert Hsu from Patreon about migrating to Python.

00:01:03.760 --> 00:01:08.640
I'm really fortunate to have CodeChip and Hired sponsoring the show.

00:01:08.640 --> 00:01:11.020
Let me take just a few seconds to tell you about them.

00:01:12.140 --> 00:01:16.680
CodeChip is a platform for continuous integration and continuous delivery as a service.

00:01:16.680 --> 00:01:19.320
They encourage you to always keep shipping.

00:01:19.320 --> 00:01:24.120
Please take a moment and check them out at codeChip.com or follow them on Twitter, where

00:01:24.120 --> 00:01:25.060
they're at CodeChip.

00:01:25.060 --> 00:01:28.040
Hired wants to help you find your dream job.

00:01:28.040 --> 00:01:31.680
Hired is built specifically for developers looking for new opportunities.

00:01:31.680 --> 00:01:36.880
Check them out and get a very special offer at Hired.com slash Talk Python To Me.

00:01:36.940 --> 00:01:40.860
And you'll find them on Twitter, where they're at Hired underscore HQ.

00:01:40.860 --> 00:01:44.680
Let me tell you how we got to the show.

00:01:44.680 --> 00:01:49.780
It all started with me whining about bandwidth charges on Twitter, saying it was so expensive

00:01:49.780 --> 00:01:50.440
to run a podcast.

00:01:50.440 --> 00:01:51.460
Look at these things grow.

00:01:51.460 --> 00:01:57.780
And then Justin Spain from Chattanooga, Tennessee, who's at JWS Music on Twitter, said,

00:01:57.780 --> 00:01:59.440
why don't you start a Patreon campaign?

00:01:59.440 --> 00:02:03.160
Of course, when I read that, I thought, well, what's a Patreon campaign?

00:02:04.140 --> 00:02:05.920
Then it turns out that Justin was right.

00:02:05.920 --> 00:02:10.840
Patreon is actually perfect for things like podcasts, blogs, frequent videos, and even

00:02:10.840 --> 00:02:11.960
open source projects.

00:02:11.960 --> 00:02:17.760
Listeners, readers, and so on, pledge a small amount to each release, in my case, each episode.

00:02:17.760 --> 00:02:22.560
And when one of these episodes ships, a small amount of money is contributed back to me to

00:02:22.560 --> 00:02:23.960
help keep the podcast going.

00:02:23.960 --> 00:02:29.820
If you want to learn more about my campaign, you can find it at Patreon.com slash mkennedy.

00:02:30.520 --> 00:02:35.220
So fast forward a month, the guys at Patreon noticed my campaign and happened to be making

00:02:35.220 --> 00:02:38.820
a company-wide transition to Python 3 from PHP.

00:02:38.820 --> 00:02:43.120
So they reached out to me on Twitter, and we thought it'd be cool to talk about their port

00:02:43.120 --> 00:02:44.820
of their product to Python.

00:02:44.820 --> 00:02:46.420
And we talk about how that's going.

00:02:46.420 --> 00:02:49.820
In case you don't make it all the way through the whole show, it's going great.

00:02:50.820 --> 00:02:55.940
I also want to take a moment and say a special thank you to the 30-plus patrons who are already

00:02:55.940 --> 00:02:56.680
supporting the show.

00:02:56.680 --> 00:03:00.780
Right now, your contributions are covering a little more than the monthly bandwidth expenses

00:03:00.780 --> 00:03:01.340
for the show.

00:03:01.340 --> 00:03:05.840
This allows me to use my sponsorship money for extra benefits, such as creating searchable

00:03:05.840 --> 00:03:07.380
transcripts and things like that.

00:03:07.380 --> 00:03:12.520
But more importantly, your support has given me the confidence to push hard on making this

00:03:12.520 --> 00:03:14.040
podcast all that it can be.

00:03:14.040 --> 00:03:16.420
And of course, there's still a long way to go there.

00:03:16.480 --> 00:03:17.460
So thank you for the help.

00:03:17.460 --> 00:03:22.580
You might also be interested to hear that Patreon is hiring Python developers and data

00:03:22.580 --> 00:03:23.180
scientists.

00:03:23.180 --> 00:03:29.240
Check out patreon.com slash careers if you want to be part of a sweet team in San Francisco

00:03:29.240 --> 00:03:33.640
who are building out a business and putting a dent in the world using Python.

00:03:33.640 --> 00:03:39.600
At some point during the show, I make a statement that PHP is one of the most dreaded languages

00:03:39.600 --> 00:03:41.320
and technologies of 2015.

00:03:41.320 --> 00:03:45.140
I was quoting from the Stack Overflow 2015 developer survey.

00:03:45.440 --> 00:03:46.720
You'll find the links in the show notes.

00:03:46.720 --> 00:03:48.840
And I have a bit of a correction there.

00:03:48.840 --> 00:03:49.400
Sorry.

00:03:49.400 --> 00:03:54.580
It was Perl that was part of the most dreaded list, not PHP.

00:03:54.580 --> 00:03:57.080
PHP didn't make the top nine.

00:03:57.080 --> 00:04:02.400
However, I suspect maybe it's lingering just off stage at place 10 or 11 or 12.

00:04:02.400 --> 00:04:07.100
And in case you're wondering, what is the most dreaded technology on the list?

00:04:07.100 --> 00:04:08.140
It's Salesforce.

00:04:08.140 --> 00:04:09.920
All right.

00:04:09.920 --> 00:04:14.160
Finally, the Talk Python To Me t-shirt Kickstarter project is still running.

00:04:14.560 --> 00:04:16.340
It will be open for nine more days.

00:04:16.340 --> 00:04:20.900
So be sure to visit bit.ly slash Python shirt to reserve yours.

00:04:20.900 --> 00:04:25.380
It's a cool and comfortable cotton shirt that will tell the world about your unabashed love

00:04:25.380 --> 00:04:25.880
for Python.

00:04:25.880 --> 00:04:30.020
Now let's get to the conversation with Albert and Patreon.

00:04:30.020 --> 00:04:32.180
Albert, welcome to the show.

00:04:32.180 --> 00:04:33.060
Hi.

00:04:33.200 --> 00:04:34.120
Thanks for having me.

00:04:34.120 --> 00:04:34.680
Yeah.

00:04:34.680 --> 00:04:36.680
I'm really glad that you guys contacted me.

00:04:36.680 --> 00:04:38.960
And I'm looking forward to the conversation.

00:04:38.960 --> 00:04:45.720
We haven't really had much talk on moving from one technology into Python.

00:04:45.720 --> 00:04:47.740
And that's our main subject today.

00:04:47.740 --> 00:04:49.000
So thanks for being here.

00:04:49.860 --> 00:04:50.880
Thanks for reaching out.

00:04:50.880 --> 00:04:55.820
And we always, Patreon is a creator-first platform, and we'd always like to support our creators

00:04:55.820 --> 00:04:56.640
in any way we can.

00:04:56.640 --> 00:04:57.560
Yeah.

00:04:57.560 --> 00:05:02.680
So we'll get to Patreon in just a second and sort of how this show came into existence.

00:05:02.680 --> 00:05:08.600
But I always like to start off the show asking my guests who have achieved a lot in their

00:05:08.600 --> 00:05:08.900
careers.

00:05:08.900 --> 00:05:11.020
And how did you get started in programming?

00:05:11.200 --> 00:05:13.680
And how did you come to start using Python?

00:05:13.680 --> 00:05:17.560
So I actually got started with programming pretty early.

00:05:17.560 --> 00:05:23.880
I actually borrowed my brother's computer science A-B textbook when I was really young and just

00:05:23.880 --> 00:05:25.740
went through some of the exercises in C++.

00:05:25.740 --> 00:05:32.160
It wasn't the best way to learn things, but it got me introduced to a lot of really small

00:05:32.160 --> 00:05:35.020
things like how to print things out to a screen, how to do for loops.

00:05:35.020 --> 00:05:40.160
And back then, I was pretty entertained just by doing really simple programs like little small

00:05:40.160 --> 00:05:44.240
games where you can put your name and someone outputs your name right back at you.

00:05:44.240 --> 00:05:45.360
Yeah.

00:05:45.360 --> 00:05:48.180
I think we've all written those types of apps, and they're super fun.

00:05:48.180 --> 00:05:53.740
Just the feeling of satisfaction and accomplishment is surprising for you, right?

00:05:53.740 --> 00:05:54.480
Yeah.

00:05:54.480 --> 00:05:57.080
Especially when you're really young and your standards are lower.

00:05:57.080 --> 00:06:02.220
But as I sort of grew up, I started programming a lot more on calculators, on TI Basic.

00:06:02.220 --> 00:06:05.580
I decided to pursue programming as my major in college.

00:06:05.580 --> 00:06:08.760
And I was still pretty gung-ho about C++.

00:06:08.760 --> 00:06:10.560
I thought it was a hardcore language.

00:06:10.560 --> 00:06:13.780
I thought that all the hardcore programmers would do C++.

00:06:13.780 --> 00:06:20.060
Until freshman year, someone introduced me to Python, and I thought it was kind of a weak

00:06:20.060 --> 00:06:22.300
language because it didn't feel as hardcore.

00:06:22.300 --> 00:06:23.340
Yeah.

00:06:23.340 --> 00:06:27.660
I think that's a common feeling, or maybe misconception is a better way to say it.

00:06:27.660 --> 00:06:32.180
But a lot of people feel like the really tough guys do C++, and they're right down there in

00:06:32.180 --> 00:06:33.320
the memory and on the metal.

00:06:33.320 --> 00:06:38.780
And all you other guys are just fooling around, orchestrating our code or whatever that we write

00:06:38.780 --> 00:06:39.280
in C++.

00:06:39.280 --> 00:06:42.100
But I'm not sure that's really true or fair, is it?

00:06:42.760 --> 00:06:44.200
That was my impression at the time.

00:06:44.200 --> 00:06:49.740
And what really changed me is when I actually had to do a lot of project courses in college,

00:06:49.740 --> 00:06:54.440
I realized I could actually do things correctly and quickly.

00:06:54.440 --> 00:07:02.680
And in terms of performance or the standards of the code, much better in Python than I could

00:07:02.680 --> 00:07:03.220
in C++.

00:07:04.220 --> 00:07:08.440
And I just continued using Python whenever I could all through college.

00:07:08.440 --> 00:07:13.180
I didn't get a chance to use it professionally until about a couple years ago when I started

00:07:13.180 --> 00:07:14.200
at a company called Quora.

00:07:14.200 --> 00:07:17.900
Quora, is that the QA site?

00:07:17.900 --> 00:07:18.940
Yeah, that's right.

00:07:18.940 --> 00:07:20.700
Quora is a question and answer site.

00:07:20.700 --> 00:07:24.920
I started it pretty early and saw a lot of the really cool things that they were doing with

00:07:24.920 --> 00:07:25.400
Python.

00:07:25.400 --> 00:07:29.300
A lot of stuff with generators and with metaclasses and decorators.

00:07:29.300 --> 00:07:33.380
And it really turned me on to Python as a really serious language.

00:07:33.880 --> 00:07:39.180
And part of what I want to do at Patreon is take a lot of those more advanced Python techniques

00:07:39.180 --> 00:07:40.620
and bring it into our infrastructure.

00:07:40.620 --> 00:07:42.760
Oh, that's really cool.

00:07:42.760 --> 00:07:47.440
But when you got to Patreon, it wasn't originally in Python, was it?

00:07:47.440 --> 00:07:48.840
No, it was in PHP.

00:07:48.840 --> 00:07:53.700
It started in PHP because that was the fastest way to bring the product to life in the early

00:07:53.700 --> 00:07:54.140
stages.

00:07:54.140 --> 00:07:59.980
But as the product grew and as the engineering team grew, it started to become pretty clear

00:07:59.980 --> 00:08:03.080
that PHP wasn't going to scale with the team.

00:08:03.540 --> 00:08:09.720
Is that from a performance perspective or from an adding new features and maintainability

00:08:09.720 --> 00:08:10.220
perspective?

00:08:10.220 --> 00:08:13.480
The number one thing was maintainability.

00:08:13.480 --> 00:08:20.360
And it's not 100% like PHP's fault, but rather PHP allows you to do certain things that make

00:08:20.360 --> 00:08:25.620
the code way messier than you want your core code to be.

00:08:25.960 --> 00:08:29.060
A lot of things with PHP just allow you to do things very quickly.

00:08:29.060 --> 00:08:33.560
And when you're adding more and more engineers, when you're going from one engineer to two to

00:08:33.560 --> 00:08:39.160
three to ten, you don't necessarily want to do everything the fastest possible way.

00:08:39.980 --> 00:08:41.800
We did want to do things fast.

00:08:41.800 --> 00:08:45.940
In fact, the concept of shipping quickly is still important to our engineering culture.

00:08:45.940 --> 00:08:50.900
But we want to be able to ship quickly in a way that's maintainable and a way that uses the proper

00:08:50.900 --> 00:08:55.940
abstractions in a way that isn't copy pasting, I guess.

00:08:55.940 --> 00:08:59.220
Let's talk a little bit about what those differences are and stuff.

00:08:59.300 --> 00:09:03.360
But before we do, maybe you could tell everyone, what is Patreon?

00:09:03.360 --> 00:09:04.680
Yeah.

00:09:04.680 --> 00:09:07.640
Patreon is a subscription funding for creators.

00:09:07.640 --> 00:09:12.100
And the way it works is that patrons will pledge a set amount per release.

00:09:12.640 --> 00:09:17.580
Every time a creator publishes a new creation, so like a webcomic, a video, a blog post, a podcast,

00:09:17.580 --> 00:09:21.880
anything, funds are transferred from patrons to the creator.

00:09:21.880 --> 00:09:24.300
We launched in May of 2013.

00:09:24.300 --> 00:09:32.060
And as of summer 2014, we announced that patrons were sending over $1 million monthly to creators

00:09:32.060 --> 00:09:32.840
through Patreon.

00:09:32.840 --> 00:09:34.320
A million dollars a month.

00:09:34.320 --> 00:09:34.840
That's amazing.

00:09:34.840 --> 00:09:35.360
Yeah.

00:09:35.360 --> 00:09:36.200
And we're still growing.

00:09:36.200 --> 00:09:38.840
We just passed $2 million very recently.

00:09:38.840 --> 00:09:41.600
And the company itself is about 24 people.

00:09:42.060 --> 00:09:45.340
We're headquartered in Soma in San Francisco and actively hiring.

00:09:45.340 --> 00:09:46.300
Okay.

00:09:46.300 --> 00:09:47.840
And they're doing Python.

00:09:47.840 --> 00:09:51.700
And I suspect you'll reach a lot of intrigued Python developers out there.

00:09:51.700 --> 00:09:53.100
So that's a good message.

00:09:53.100 --> 00:09:54.120
Yeah, that's the hope.

00:09:54.120 --> 00:09:55.040
Yeah, excellent.

00:09:55.040 --> 00:09:57.400
So I'm personally using Patreon.

00:09:57.400 --> 00:10:00.240
And that's how we got to know each other.

00:10:11.480 --> 00:10:19.500
CodeChip is a hosted continuous delivery service focused on speed, security, and customizability.

00:10:19.500 --> 00:10:25.340
You can set up continuous integration in a matter of seconds and automatically deploy when your tests have passed.

00:10:25.340 --> 00:10:28.580
CodeChip supports your GitHub and Bitbucket projects.

00:10:28.880 --> 00:10:31.340
You can get started with CodeChip's free plan today.

00:10:31.340 --> 00:10:39.860
Should you decide to go with a premium plan, Talk Python listeners can save 20% off any plan for the next three months by using the code TALKPYTHON.

00:10:39.860 --> 00:10:41.560
All caps, no spaces.

00:10:41.560 --> 00:10:48.900
Check them out at CodeChip.com and tell them thanks for sponsoring the show on Twitter where they're at CodeChip.

00:10:52.900 --> 00:11:02.500
I was on Twitter complaining like I do sometimes about paying for bandwidth and stuff for my podcast because it's going up.

00:11:02.500 --> 00:11:04.040
It's kind of like doubling each month.

00:11:04.040 --> 00:11:10.440
And it's, you know, not a huge number now, but doubling a medium-sized number becomes a problem really quick, right?

00:11:10.480 --> 00:11:13.560
So I was saying, well, this is getting pretty expensive, OGs.

00:11:13.560 --> 00:11:19.840
And a guy, I believe his name is Justin on Twitter, says, hey, why don't you use Patreon?

00:11:19.840 --> 00:11:21.420
And that's the first I heard of you guys.

00:11:21.420 --> 00:11:24.920
So I'm like, wow, let me go create an account or a campaign on Patreon.

00:11:24.920 --> 00:11:26.980
I thought of other ways to kind of do this.

00:11:26.980 --> 00:11:28.680
Like maybe Kickstarter might be an answer.

00:11:28.680 --> 00:11:35.000
But to me, Kickstarter is the wrong thing because it's like you fund this thing once and there's like a big bang creation.

00:11:35.000 --> 00:11:45.600
And that doesn't really work for things like ongoing podcasts or sort of steady state stuff, like you're saying, like web comics or things like XKCD type stuff, right?

00:11:45.600 --> 00:11:46.880
Yeah, that's right.

00:11:46.880 --> 00:11:51.900
Our goal is that people who want to create things are able to make a living off those creations.

00:11:51.900 --> 00:12:05.420
And to do that requires sort of mimicking the structure that I guess like a job sort of has or mimicking the idea of having like ongoing support for your ability to create things.

00:12:05.420 --> 00:12:11.900
And I think it's a lot of the reason why I joined Patreon is because I believe in the mission.

00:12:11.900 --> 00:12:15.000
And a lot of the people who work here as well also believe in the mission.

00:12:15.000 --> 00:12:16.900
I think it's a really great mission.

00:12:16.900 --> 00:12:20.120
And it definitely makes having my podcast simpler.

00:12:20.120 --> 00:12:25.200
And I just want to say thanks to everyone out there who's contributed to my campaign so far.

00:12:25.200 --> 00:12:27.440
And I think what you guys are doing is really great.

00:12:27.440 --> 00:12:29.700
So I was super excited about it when I first heard of it.

00:12:29.700 --> 00:12:31.020
It just I hadn't heard of it before.

00:12:31.020 --> 00:12:34.100
So let's talk about PHP a little bit.

00:12:34.100 --> 00:12:35.640
So it was originally written in PHP.

00:12:35.640 --> 00:12:39.680
And to be honest, I don't have a ton of experience personally with PHP.

00:12:39.680 --> 00:12:43.580
But what are some of the pain points that you're solving with Python?

00:12:44.900 --> 00:12:47.260
A lot of organization of code.

00:12:47.260 --> 00:12:52.560
I think with namespaces, I think it's just I mean, it's a very simple feature.

00:12:52.560 --> 00:13:00.640
But being able to segment our code out into separate modules allows different teams to work on different aspects of the site.

00:13:00.640 --> 00:13:09.120
Secondly, with decorators or with like a sort of single points of entry for application.

00:13:09.700 --> 00:13:15.020
The way we're currently using Flask and the way the Flask does routing is like through decorators.

00:13:15.020 --> 00:13:30.480
And because we're doing everything through this standardized way, if we want to change something like if we want to say start recording response times and graphing that on a chart, we can just do that by modifying decorator rather than trying to input that into each individual PHP script.

00:13:31.260 --> 00:13:31.620
Right.

00:13:31.620 --> 00:13:31.680
Right.

00:13:31.680 --> 00:13:33.560
The way they do decorators with what is it?

00:13:33.560 --> 00:13:37.300
App.route as a decorator on all the methods that power the views.

00:13:37.300 --> 00:13:38.380
Yeah, that's right.

00:13:38.380 --> 00:13:39.640
Yeah, that's really cool.

00:13:39.640 --> 00:13:43.480
We just had Armin on the show for the previous show.

00:13:43.480 --> 00:13:45.020
So people hear more about him.

00:13:45.020 --> 00:13:45.960
I'm assuming it's pretty cool.

00:13:45.960 --> 00:13:47.640
But yeah, I'm a big fan of Flask.

00:13:47.640 --> 00:13:50.260
And you guys said you're doing Python 3, right?

00:13:50.980 --> 00:13:51.440
That's right.

00:13:51.440 --> 00:13:54.420
That was sort of one of the small risks that we took.

00:13:54.420 --> 00:14:01.300
Most of the other technologies that we use are pretty boring or at least like pretty standard like Flask or SQLAlchemy or Jinja 2.

00:14:01.300 --> 00:14:09.040
But we decided that we would go with Python 3 going forward because we wanted to make sure that our code base is going to be future proof.

00:14:10.420 --> 00:14:12.960
I think that's a really nice choice.

00:14:12.960 --> 00:14:15.600
And I see more and more people moving to Python 3.

00:14:15.600 --> 00:14:18.760
There's still a lot of folks doing Python 2.

00:14:18.760 --> 00:14:25.000
But it just seems a little wrong is not the word I'm looking for.

00:14:25.000 --> 00:14:32.500
But it just seems like something is out of balance where there's a lot of people working on Python 3 to push the future of Python.

00:14:32.500 --> 00:14:35.160
And then there's so many people who are actually not using it.

00:14:35.160 --> 00:14:40.220
Some of the biggest users of Python are not using kind of where the community is focusing its effort.

00:14:40.220 --> 00:14:48.500
And so I personally think any time you get a chance to use Python 3 is kind of helping the community move along, let's say.

00:14:48.500 --> 00:14:59.140
The way we went about it, actually, we took a look at the wall of superpowers and just saw what are the modules that we need to actually build our application.

00:14:59.140 --> 00:15:02.840
Most things that we needed are already implemented.

00:15:02.840 --> 00:15:05.000
The one thing that was missing was MySQL DB.

00:15:05.000 --> 00:15:08.200
And that was pretty easily replaceable by PyMySQL.

00:15:08.200 --> 00:15:11.740
And so it's been actually a really, really simple switch for us.

00:15:11.740 --> 00:15:19.740
The biggest sort of hump that we ran into is that, like, Stack Overflow or Google defaults to Python 2.7 in terms of its help.

00:15:19.740 --> 00:15:22.240
But it's been a dream for us to work with.

00:15:22.240 --> 00:15:23.900
Yeah, that's really great.

00:15:23.900 --> 00:15:25.160
So let's see.

00:15:25.160 --> 00:15:26.140
You're using Flask.

00:15:26.140 --> 00:15:28.140
It sounds like you're using MySQL.

00:15:28.140 --> 00:15:29.820
It's the back end.

00:15:29.820 --> 00:15:31.600
SQLAlchemy.

00:15:31.600 --> 00:15:33.220
SQLAlchemy is really fantastic.

00:15:33.220 --> 00:15:34.060
What else are you using?

00:15:34.280 --> 00:15:36.460
Any other cool parts of Python or libraries?

00:15:36.460 --> 00:15:42.020
Our starting point was just to mimic as much of PHP as possible.

00:15:42.020 --> 00:15:49.100
And so in terms of complicated technologies, we actively chose against using any of them.

00:15:49.800 --> 00:15:52.980
A lot of really standard modules like requests or Jinja 2.

00:15:52.980 --> 00:15:55.140
But nothing too out there yet.

00:15:55.140 --> 00:15:56.880
That makes perfect sense.

00:15:56.880 --> 00:15:59.540
Let's talk a little bit about the whole porting concept.

00:15:59.540 --> 00:16:06.860
Porting your code is basically a rewrite when it's this divergent of a technology, right?

00:16:06.860 --> 00:16:08.320
And so that's a pretty big risk.

00:16:08.320 --> 00:16:11.120
How did you guys decide that that was the path forward?

00:16:11.780 --> 00:16:13.360
Yeah, it was a pretty big risk.

00:16:13.360 --> 00:16:16.060
In fact, I've been burned by a lot of ports in the past.

00:16:16.060 --> 00:16:20.040
A previous project I've had was porting something from Python to Scala.

00:16:20.040 --> 00:16:27.760
And I think that's a much, much more difficult process to go through because you're putting basically a dynamic language into a static language.

00:16:27.960 --> 00:16:31.100
And that just adds a lot of weight to the process.

00:16:31.100 --> 00:16:38.740
We decided pretty early on that PHP wasn't going to be how we wanted to go forward with engineering.

00:16:39.780 --> 00:16:48.520
The decisions we had to make were, like, given the current PHP code base, could we refactor it into something that's more workable using, like, a modern framework?

00:16:48.520 --> 00:16:54.880
Should we port it to Python or should we port it to, like, I guess a crazier language like Scala or Java?

00:16:54.880 --> 00:17:01.840
We didn't want to, like, the ecosystem of PHP was, we found, much weaker than that of Python.

00:17:01.840 --> 00:17:10.160
I think a lot of the main consumers of PHP has mostly revolved around Facebook and a little bit around, like, the Wikimedia Foundation.

00:17:10.160 --> 00:17:12.220
But besides that, not a lot of support.

00:17:12.220 --> 00:17:17.300
Whereas Python has what feels like a more active developer community, a more active ecosystem.

00:17:17.300 --> 00:17:21.880
It lends us a lot more legitimacy for hiring engineers.

00:17:21.880 --> 00:17:24.340
It is more consistent of a language.

00:17:24.340 --> 00:17:34.480
And it was just different enough from PHP but close enough that, like, we felt comfortable doing a one-to-one translation from PHP to Python.

00:17:34.480 --> 00:17:35.260
Right.

00:17:35.260 --> 00:17:39.660
It was different, but it wasn't completely alien to make that transformation, huh?

00:17:39.660 --> 00:17:40.420
Yeah.

00:17:40.420 --> 00:17:45.820
The other option we had with Scala was just too different and, like, too many unknowns.

00:17:45.820 --> 00:17:51.620
And when it comes to ports, I think there's usually a pretty high probability that a port will fail.

00:17:52.500 --> 00:17:55.060
I've seen a lot of port projects just, like, fail in the past.

00:17:55.060 --> 00:18:02.600
And in order to prevent that from happening, I think we as a company decided we want to take as few risks as possible.

00:18:02.600 --> 00:18:04.580
Yeah, that makes a lot of sense.

00:18:04.580 --> 00:18:10.960
You'd mentioned, like, sort of developer happiness and things like that.

00:18:11.960 --> 00:18:27.760
There's a really interesting yearly developer survey by Stack Overflow that comes out, and they sort of rank technologies, what's growing, what are the jobs, what are technologies people love, and what are technologies people strongly dislike, let's say.

00:18:27.760 --> 00:18:31.080
It's a concern that they're working with it.

00:18:31.640 --> 00:18:38.540
And I think Python was on the list of the beloved technologies, and PHP might have been on the list of the ones to kind of stay away from.

00:18:38.540 --> 00:18:46.980
So you think it's easier to hire people because you can say, hey, come work on this cool Python 3 Flask project than it is to say, come work on this PHP project?

00:18:47.420 --> 00:18:58.360
When it comes to PHP, PHP has been really easy to develop new things, but it makes it extremely difficult to maintain that code after it's been developed.

00:18:59.140 --> 00:19:07.640
And I think that the gains you get with PHP are also seen a lot in Python, but the maintainability of Python is so much greater for us.

00:19:07.640 --> 00:19:16.900
Engineers, I think, rank maybe a little bit unfairly, certain languages as more hardcore than others.

00:19:16.900 --> 00:19:18.280
I think PHP ranks pretty low.

00:19:18.280 --> 00:19:28.360
I think there's a lot of unfair feelings towards PHP, especially since it's been developed and it's been actively used by companies like Facebook.

00:19:28.360 --> 00:19:30.900
Yeah, and things like WordPress, right?

00:19:30.900 --> 00:19:33.460
And there's some pretty amazing stuff out there.

00:19:33.460 --> 00:19:34.160
Yeah.

00:19:34.160 --> 00:19:51.760
But there's a lot of parts core to the language, a lot of inconsistencies, a lot of things like global namespacing, a lot of things like having to worry about security or magic quotes or PHP ionized that worked well in the past, but don't really hold up against the modern language.

00:19:51.760 --> 00:19:52.460
Sure.

00:19:52.460 --> 00:19:53.160
That makes sense.

00:19:53.160 --> 00:20:01.520
So you chose Python over the other options that you listed and obviously the ones that you didn't list as well, like over all the other possibilities.

00:20:01.520 --> 00:20:07.720
Does that mean that a lot of the people there had lots of Python experience and that's kind of what they wanted to move to?

00:20:07.720 --> 00:20:09.480
Or how did you as a group decide?

00:20:19.620 --> 00:20:22.240
This episode is brought to you by Hired.

00:20:22.240 --> 00:20:28.720
Hired is a two-sided, curated marketplace that connects the world's knowledge workers to the best opportunities.

00:20:28.720 --> 00:20:37.880
Each offer you receive has salary and equity presented right up front and you can view the offers to accept or reject them before you even talk to the company.

00:20:37.880 --> 00:20:44.240
Typically, candidates receive five or more offers in just the first week and there are no obligations ever.

00:20:44.240 --> 00:20:46.340
Sounds pretty awesome, doesn't it?

00:20:46.620 --> 00:20:48.380
Well, did I mention there's a signing bonus?

00:20:48.380 --> 00:20:52.460
Everyone who accepts a job from Hired gets a $2,000 signing bonus.

00:20:52.460 --> 00:20:56.820
And as Talk Python listeners, it gets way sweeter.

00:20:56.820 --> 00:21:04.380
Use the link Hired.com slash Talk Python To Me and Hired will double the signing bonus to $4,000.

00:21:04.380 --> 00:21:06.100
Opportunity's knocking.

00:21:06.100 --> 00:21:09.720
Visit Hired.com slash Talk Python To Me and answer the call.

00:21:09.720 --> 00:21:10.280
Yeah.

00:21:10.280 --> 00:21:23.820
As a group, we actually have a lot of really disparate skills.

00:21:23.820 --> 00:21:28.920
Some in Java, some in Ruby, some in JavaScript, and some only in PHP.

00:21:28.920 --> 00:21:34.840
There was no language that everyone was going to be really favored on.

00:21:35.640 --> 00:21:37.760
And as a result, we just had to make a decision.

00:21:37.760 --> 00:21:40.820
We chose Python because we knew it would be pretty safe.

00:21:40.820 --> 00:21:46.180
And we knew that, like, Python is a really easy language to just pick up over a weekend.

00:21:47.020 --> 00:21:53.680
Like, it's the tutorial on Python or the way that most people, like, learn Python is usually over a weekend.

00:21:53.680 --> 00:21:56.780
Getting the very basics of it are pretty easy.

00:21:56.780 --> 00:22:00.260
And getting into the depth is, like, a gradual learning curve.

00:22:00.260 --> 00:22:02.620
I think it is a super easy language to learn.

00:22:02.620 --> 00:22:08.440
Where the real work is learning all the standard libraries and all the popular packages, right?

00:22:08.520 --> 00:22:11.600
Like, really mastering things like SQLAlchemy and Flask.

00:22:11.600 --> 00:22:13.720
And, right, that's the real learning curve.

00:22:13.720 --> 00:22:15.240
But it's kind of unavoidable.

00:22:15.240 --> 00:22:16.660
Yeah, that's totally right.

00:22:16.660 --> 00:22:17.700
Nice.

00:22:17.700 --> 00:22:22.760
So you guys sort of chose Python because it would more or less make everybody happy.

00:22:22.760 --> 00:22:24.920
And it was a really good, safe choice.

00:22:24.920 --> 00:22:26.900
I think that's a pretty fair characterization.

00:22:26.900 --> 00:22:33.000
I've heard somewhere, I can't remember if it was when I was talking to the guys at PayPal or if I heard it from LinkedIn.

00:22:33.000 --> 00:22:41.200
But, you know, as people said, other places that they've chosen Python because it was everybody's second favorite language.

00:22:41.200 --> 00:22:43.740
Like, a lot of people really, really like Ruby.

00:22:43.740 --> 00:22:46.760
I've also worked with Ruby professionally.

00:22:46.760 --> 00:22:48.180
I like it as a language.

00:22:48.180 --> 00:22:54.540
But sometimes, like, yeah, we had to pick something that's good for everyone, not necessarily great.

00:22:54.540 --> 00:22:55.580
Right.

00:22:55.580 --> 00:23:00.240
Somebody's got their pet language that they're super happy about, but, you know, other people dislike it.

00:23:00.240 --> 00:23:04.020
And so, yeah, I think Python fits really well in those situations.

00:23:04.020 --> 00:23:17.180
What really helped us with Python also or making that decision was that the amount of movement in terms of data science or, like, with, like, SciPy or NumPy has been, like, much greater than a lot of other languages.

00:23:17.320 --> 00:23:35.720
And we knew that eventually if we wanted to do sort of like a data-driven approach to our projects or a data-driven approach to our roadmap, that getting our stuff in Python would lead to a lot of – would allow us to hire a lot more data science people or, like, allow them to onboard a lot quicker as well.

00:23:35.720 --> 00:23:37.800
Yeah, and crossover as well.

00:23:37.800 --> 00:23:40.180
So you might know the whole spectrum even better.

00:23:40.580 --> 00:23:49.260
There was a really interesting PyCon presentation from Fernando Perez, the guy who started IPython, at PyCon 2014.

00:23:49.260 --> 00:23:56.000
And he talked about how the adoption of Python and IPython and data science is so taking off.

00:23:57.220 --> 00:23:58.940
Maybe I'll link to that video in the show notes.

00:23:58.940 --> 00:24:06.100
But basically he said, you know, if you look at the technologies used in the stuff that's submitted to Strata, the big data conference, I think, in your town.

00:24:06.100 --> 00:24:17.140
And the data he had was basically showing that people used to be doing things like R and to a large degree that's been replaced by IPython, NumPy, SciPy, Matplotlib, all those types of things.

00:24:17.140 --> 00:24:18.340
It's really amazing.

00:24:19.140 --> 00:24:21.340
So are you guys thinking of using some of those technologies?

00:24:21.340 --> 00:24:23.300
You said NumPy for sure.

00:24:23.300 --> 00:24:25.140
Yeah, definitely.

00:24:25.140 --> 00:24:31.760
As we start bringing on – like, at this stage, we're just collecting a lot of data, like, with our – like, our page views.

00:24:32.700 --> 00:24:47.540
But we are pretty comfortable that, like, it's a well-trodden path of putting – or, like, integrating NumPy or, like, Matplotlib into our data once we have someone who's, like, working full-time on data science.

00:24:47.540 --> 00:24:51.260
It's a language that I think, like, sort of has, like, broad appeal outside of engineering.

00:24:51.260 --> 00:24:53.440
And that's, I think, really important to us.

00:24:53.440 --> 00:24:58.360
And I think having the data science component there really is powerful for you guys.

00:24:58.480 --> 00:25:04.420
I mean, you've got all these people who are creators, and you've got all these patrons that are supporting them.

00:25:04.420 --> 00:25:09.100
And just helping those people align better will just help your business.

00:25:09.100 --> 00:25:11.960
And it sounds like big data type stuff would be perfect for that.

00:25:11.960 --> 00:25:12.620
Yeah, totally.

00:25:12.620 --> 00:25:13.840
Okay.

00:25:13.840 --> 00:25:17.560
So you're doing this port to Python on Flask and Python 3, and that's cool.

00:25:17.560 --> 00:25:18.720
When did you guys start on it?

00:25:18.720 --> 00:25:24.400
We started as of late November in 2014.

00:25:24.400 --> 00:25:25.700
Okay.

00:25:25.860 --> 00:25:30.400
So at the time of this recording, it's June 2nd, so that sounds about, like, seven, eight months?

00:25:30.400 --> 00:25:31.300
Yeah, that's right.

00:25:31.300 --> 00:25:35.400
The first thing that we did was just getting to the first page.

00:25:35.400 --> 00:25:45.720
I think in our porting process, we wanted to have, like, immediate deliverables and, like, immediately put Python in front of users as soon as possible.

00:25:46.120 --> 00:26:00.220
So in terms of, like, the project, we just picked one page, a fairly low-risk page, which is our slash-about page, and just made it our only one goal just to see how fast we could get that page rendering in Python to production.

00:26:01.080 --> 00:26:02.800
That's a really interesting way to do it.

00:26:02.800 --> 00:26:07.100
So you're kind of taking a vertical slice instead of trying to, like, horizontally going through it.

00:26:07.100 --> 00:26:09.340
So you can get some piece of functionality shipped straight away.

00:26:09.340 --> 00:26:14.840
It seems like that would help a lot with mitigating the risk of, like, will this port ever be done?

00:26:14.840 --> 00:26:16.700
When it goes live, will it ever work?

00:26:16.700 --> 00:26:18.040
Things like that, right?

00:26:18.600 --> 00:26:19.460
Yeah, that's totally right.

00:26:19.460 --> 00:26:34.040
We were really afraid that if we took a horizontal approach, like, we built all the infrastructure around the web framework, we built all the infrastructure around the models, built the infrastructure around controllers, that at some point we would have to just, like, flip a switch.

00:26:34.040 --> 00:26:42.400
And that was really scary because there's, like, a lot of risk that we can't necessarily detect with, like, just unit testing or integration testing.

00:26:42.400 --> 00:26:48.040
Sometimes we just want things to be as close to production as possible.

00:26:48.040 --> 00:26:52.200
And as close to production as possible is sometimes just production.

00:26:52.200 --> 00:26:53.340
Yes.

00:26:53.340 --> 00:26:55.100
That's pretty close to production.

00:26:55.100 --> 00:26:59.200
So you had a pretty interesting approach.

00:26:59.200 --> 00:27:04.060
So you started with the something simple, and you're like, let's get this whole thing out there.

00:27:04.060 --> 00:27:05.400
How did that go?

00:27:05.400 --> 00:27:09.120
You had to get the app written, which is not a really big deal.

00:27:09.120 --> 00:27:11.740
But then you had to do kind of DevOps, database stuff.

00:27:11.740 --> 00:27:13.060
What was the process?

00:27:13.060 --> 00:27:14.240
How smoothly did this go?

00:27:14.240 --> 00:27:15.040
Right.

00:27:15.500 --> 00:27:24.940
The complicated part here was getting our existing site, which is still running on PHP and Apache, to work well with the Python Flask infrastructure.

00:27:24.940 --> 00:27:30.660
And the way we handled that was in Apache, we used a proxy pass on particular routes.

00:27:30.660 --> 00:27:37.240
In this case, for the about page, we used proxy pass slash about to our Python backend.

00:27:38.080 --> 00:27:38.140
Okay.

00:27:38.140 --> 00:27:44.580
And so you could just sort of bypass your main app and send it straight over to whatever WSGI server you got running Flask, right?

00:27:44.580 --> 00:27:45.600
Yeah, that's right.

00:27:45.600 --> 00:27:53.200
We started up at an entirely different tier using Nginx, Gunicorn, Flask, but pointing to the same data sources.

00:27:53.200 --> 00:28:00.540
And we were able to flip a switch just on and off of whether or not we wanted a particular page to go to PHP or to Python.

00:28:01.680 --> 00:28:02.660
Wow, that's really cool.

00:28:02.660 --> 00:28:05.720
So I guess you just flipped that switch at the proxy pass level.

00:28:05.720 --> 00:28:09.100
And it was still living in the original PHP site.

00:28:09.100 --> 00:28:11.880
And then you started adding features to the Python version.

00:28:11.880 --> 00:28:16.760
And would you flip it on and off to see how it would flip it on for a little bit, see if it's okay, and then flip it back?

00:28:16.760 --> 00:28:18.360
What was that like?

00:28:19.420 --> 00:28:22.660
We tried to just flip it on and just keep it there.

00:28:22.660 --> 00:28:33.080
Although, you know, in terms of like mitigating risk, it is really comfortable to have, to know that you can always flip back and forth between a correct version and like the Python version.

00:28:33.080 --> 00:28:37.820
Having this, we also did a lot of things with having the separate architecture.

00:28:38.060 --> 00:28:45.220
And so one way we actually did testing was, and this isn't our comprehensive test, but we would open up the site in PHP.

00:28:45.220 --> 00:28:54.180
We'd open the site directly by bypassing Apache completely and going directly to our Python infrastructure and just like tabbing back and forth between the two.

00:28:54.180 --> 00:28:57.220
And it makes a lot of differences really obvious.

00:28:57.220 --> 00:28:59.520
Just kind of a visual diff, if you will, huh?

00:28:59.520 --> 00:29:00.260
Yeah, exactly.

00:29:00.260 --> 00:29:01.180
That's cool.

00:29:01.180 --> 00:29:07.860
So you went through a whole process of like choosing the next page and so on, and we talked a little bit about that before the show.

00:29:07.860 --> 00:29:08.940
Can you maybe talk about that?

00:29:08.940 --> 00:29:11.300
You start with the About page, and then where do you go from there?

00:29:11.300 --> 00:29:22.140
Yeah, so the discipline that we tried or like the process we tried to go by was to start with low traffic, low complexity pages.

00:29:22.140 --> 00:29:32.400
And this just let us make sure that our web framework was the way that we wanted it to be, that we wanted like, you know, we could register the correctness of the site without a lot of risk.

00:29:32.400 --> 00:29:34.400
And that was like what the About page was about.

00:29:34.400 --> 00:29:34.920
Right.

00:29:34.920 --> 00:29:37.460
That almost tests your infrastructure more than anything, right?

00:29:37.460 --> 00:29:38.880
That everything's hanging together.

00:29:38.880 --> 00:29:40.400
Yeah, exactly.

00:29:40.400 --> 00:29:42.080
Made sure our proxy password correctly.

00:29:42.080 --> 00:29:43.760
Made sure we did session handling correctly.

00:29:43.760 --> 00:29:50.240
We just wanted to start with like, you know, rigorously testing like one small thing at a time while we were rolling this out.

00:29:50.820 --> 00:29:52.380
Okay, so after About?

00:29:52.380 --> 00:29:59.580
So after About, like we, and we were comfortable with, you know, for example, like logged out and logged in traffic being correct.

00:29:59.580 --> 00:30:03.760
We started going and just porting to high traffic and low complexity pages.

00:30:03.760 --> 00:30:07.060
So the stuff like our index page is pretty low complexity.

00:30:07.060 --> 00:30:08.480
It's mostly just featured artists.

00:30:08.480 --> 00:30:12.300
Our featured page is also like featured creators in our search page.

00:30:12.300 --> 00:30:17.220
This let us make sure that our scalability was in order.

00:30:17.940 --> 00:30:23.880
The complexity of this page is like, we didn't have to write a lot of additional code to make those pages correct.

00:30:23.880 --> 00:30:30.120
But we did have to like make sure like we need, how many servers do we need in order to support a certain amount of traffic?

00:30:30.120 --> 00:30:37.240
How much do we need to like mirror the amount of performance that the PHP side was having in Python?

00:30:38.040 --> 00:30:40.000
So performance, that's an interesting question.

00:30:40.000 --> 00:30:42.360
Have you noticed a difference in performance?

00:30:42.360 --> 00:30:48.420
It's actually slightly faster in Python because we're doing certain things a lot more efficiently.

00:30:48.880 --> 00:30:59.560
like we have, you know, one entry point into our DB as opposed to doing like MySQL underscore, MySQL underscore query or like MySQL, like a lot of the MySQL underscore functions in PHP.

00:30:59.560 --> 00:31:03.400
That goes along with also cleaning up the code base.

00:31:03.400 --> 00:31:10.340
But like certain things with refact, like with making things correct in Python, just had the side effect to make things faster.

00:31:10.920 --> 00:31:13.140
Yeah, that's really interesting because it's a simpler language.

00:31:13.140 --> 00:31:18.160
You might not, it might be easier to write it correctly or more optimally.

00:31:18.160 --> 00:31:18.820
Yeah.

00:31:18.820 --> 00:31:30.660
One thing that we did run into was that because the default state of PHP is to just stream all the data as it comes out into standard, like from standard out directly to the client's browser.

00:31:30.960 --> 00:31:36.100
And so on the PHP pages, you would see like stuff coming in right away.

00:31:36.100 --> 00:31:39.140
With Python, we, we used Jinja2.

00:31:39.140 --> 00:31:43.560
And so like we needed an entire template to render before we sent it down to the user.

00:31:43.560 --> 00:31:53.760
So we had to do a little bit of a things to make the performance feel as fast in Python as it did in PHP, like using generators instead of like sending down like one large HTML block.

00:31:54.240 --> 00:31:59.760
That's really the problem you experienced with almost any of the template, HTML template style things, right?

00:31:59.760 --> 00:32:04.200
As you're not streaming directly to the browser, they execute and then send it down.

00:32:04.200 --> 00:32:06.340
It's, it's a perception thing, right?

00:32:06.340 --> 00:32:11.420
Like it feels slower, even if in the end, the same amount of stuff is on the page in the same time.

00:32:11.420 --> 00:32:12.100
Yeah.

00:32:12.100 --> 00:32:23.400
Like for example, our creation pages in PHP took six seconds to render, but you didn't feel it because you would still see the, like the embed.

00:32:23.400 --> 00:32:27.400
Or you would see like the becoming a patron flow right away.

00:32:27.400 --> 00:32:32.200
And it ended up like the slow part of the page was rendering the comments.

00:32:32.200 --> 00:32:36.300
And that was also do like number of inefficient things we were doing with the data fetches.

00:32:36.300 --> 00:32:42.720
But when we reported that straight up from PHP to Python, we just wouldn't see a page load for six seconds.

00:32:42.720 --> 00:32:43.840
And that's too long.

00:32:43.840 --> 00:32:45.040
That's definitely too long on the web.

00:32:45.040 --> 00:32:45.660
Yeah.

00:32:45.760 --> 00:32:55.060
And so we just like, we implement our own version of like lazy loading and like made sure the comments would come in after all the really relevant parts of the page came in.

00:32:55.720 --> 00:33:03.640
And we also made some like, I mean, after we got that first part through, we started making some efficiency, like, like optimizations with the performance.

00:33:03.880 --> 00:33:14.980
But we decided that like, you know, finishing the thing was first, like finishing the correctness of the, finishing the correct page was the first thing we'd go for and optimize the data calls later.

00:33:14.980 --> 00:33:15.960
Right.

00:33:16.040 --> 00:33:16.220
Okay.

00:33:16.220 --> 00:33:21.280
Maybe we come back to some of the optimizations, but I'm, one of the questions that's coming to mind is, are you guys done?

00:33:21.280 --> 00:33:32.240
so we are 98% of the way through and, that's not necessarily an ideal situation, but we're about halfway through the project.

00:33:32.240 --> 00:33:38.660
We realized that like we could actually start implementing new things on top of the base that we, produced.

00:33:38.840 --> 00:33:52.980
So after we implemented the user page, the creation page, and, a lot of the other sort of high, like one of the, some of the higher complexity pages with higher traffic, we had most of the models in place that we could start actually building new things.

00:33:52.980 --> 00:34:01.640
The first thing we implemented was a, a really simple, feature for migrating, sub-able users from sub-able onto Patreon.

00:34:02.520 --> 00:34:15.380
And we've been launching, we've been developing an API service layer for, the web client and the mobile app to be, to, to be unblocked and allow them to, they, reach some amount of progress.

00:34:15.380 --> 00:34:23.040
where we're stuck right now in terms of the Python port is the long tail of like really low traffic, but like sort of high complexity pages.

00:34:23.040 --> 00:34:27.700
So like stuff like, like the settings page or stuff like with, like patron manager.

00:34:28.340 --> 00:34:28.740
Yeah.

00:34:28.740 --> 00:34:37.200
Are there a bunch of like internal pages that you guys have that are complex dashboards that from the outside we don't really see, but have to be moved over eventually?

00:34:37.200 --> 00:34:37.940
Yeah.

00:34:37.940 --> 00:34:40.200
We have a lot of internal dashboards.

00:34:40.200 --> 00:34:41.940
A lot of them have like a varying complexity.

00:34:41.940 --> 00:34:49.580
those are lower priority because we wanted, you know, the production pages to be out first, but eventually those will need to be ported to Python as well.

00:34:49.580 --> 00:34:50.160
Yeah.

00:34:50.160 --> 00:34:55.480
So at some point you'll want to turn off the PHP site if possible and only manage one thing, right?

00:34:55.480 --> 00:34:56.160
Yeah.

00:34:56.160 --> 00:35:02.700
Our, like our number one dream, like with the Python port is to be able to completely delete the PHP repo entirely.

00:35:02.700 --> 00:35:07.820
And that just means like number one, like the PHP is not running in production, obviously.

00:35:07.820 --> 00:35:13.020
But secondly, it means that like the Python reference is what we're going with going forward.

00:35:13.020 --> 00:35:15.600
So you're already doing new features on top of Python.

00:35:15.600 --> 00:35:17.880
So it's, it's already serving you pretty well.

00:35:18.360 --> 00:35:26.660
One of the hard cells with doing a port is that while the port is going on, you can't do a lot of ongoing feature development.

00:35:26.660 --> 00:35:30.400
And the product itself will seem to stagnate for a while.

00:35:30.400 --> 00:35:35.960
And it has to be like sort of understood from like everyone that like, that's the way it has to happen.

00:35:35.960 --> 00:35:41.580
Like it can't do development in PHP and then like sort of backport that into Python later.

00:35:41.580 --> 00:35:44.540
It's going to slow down development of both, both systems.

00:35:44.540 --> 00:35:45.080
Yeah.

00:35:45.080 --> 00:35:47.220
And you guys came out, you said what, 2013?

00:35:47.220 --> 00:35:48.240
Yes.

00:35:48.240 --> 00:35:49.340
That's May, 2013.

00:35:49.340 --> 00:35:49.960
Yeah.

00:35:49.960 --> 00:35:57.500
And so if you're going to do this in 2014, you've got a year old product and you're saying, we're not going to change this for six months.

00:35:57.500 --> 00:35:59.040
That's kind of crazy in web time.

00:35:59.040 --> 00:36:00.540
So you had to do something, right?

00:36:01.120 --> 00:36:01.400
Yeah.

00:36:01.400 --> 00:36:04.220
It was kind of painful at like trying to sell that at first.

00:36:04.220 --> 00:36:11.980
But the idea is like we're going for long-term value and our long-term value depends on like engineering feeling like they're working with a language that makes them happy.

00:36:11.980 --> 00:36:13.240
Yeah.

00:36:13.240 --> 00:36:14.560
And that's, that's worth a lot, right?

00:36:14.560 --> 00:36:16.600
I mean, that means keeping the good developers.

00:36:16.600 --> 00:36:18.300
People are excited about their projects.

00:36:18.300 --> 00:36:20.160
Like it's, it's really a big deal.

00:36:20.160 --> 00:36:23.080
Probably easier to fix bugs as well.

00:36:23.080 --> 00:36:24.160
Yeah, definitely.

00:36:24.500 --> 00:36:40.300
We use an external service called Rovar that just like lets us identify like, well, any error that happens in production just immediately goes to that service and produces like a stack trace and like, you know, as much information as we can about the request and the headers.

00:36:40.300 --> 00:36:42.500
And it just lets us debug really quickly.

00:36:42.500 --> 00:36:45.000
What other infrastructure have you put in place?

00:36:45.000 --> 00:36:47.140
You guys have like automated tests and stuff like that?

00:36:47.140 --> 00:36:49.660
Yeah, we do the simple things like unit testing.

00:36:49.660 --> 00:36:51.020
We have a staging environment.

00:36:51.020 --> 00:37:04.960
We do some of the more creative things we do is like we have this concept of a walk test where for every page that we, or every route that we implement on the site, we just have a bunch of users of different profiles.

00:37:04.960 --> 00:37:10.360
Like we have a dummy patron account or a dummy creator account and just have them load the page.

00:37:10.360 --> 00:37:13.980
And that just makes sure that like the page loads with the 200.

00:37:13.980 --> 00:37:24.260
It's a really lightweight way of testing if like every code path or like every possible view, every possible viewer of a page will actually render.

00:37:24.260 --> 00:37:27.680
But it is like it's a really high leverage test.

00:37:27.680 --> 00:37:29.320
It's for the amount of effort.

00:37:29.320 --> 00:37:33.100
That's surprisingly effective because if something goes wrong, a lot of times it's a 500.

00:37:33.100 --> 00:37:34.240
Yeah, exactly.

00:37:34.240 --> 00:37:37.280
It ends up being about like 40 lines of code to actually implement that.

00:37:37.280 --> 00:37:39.580
But it catches a surprising amount of bugs.

00:37:39.580 --> 00:37:40.200
Yeah.

00:37:40.820 --> 00:37:43.520
You don't want people to see 500s on your site.

00:37:43.520 --> 00:37:46.040
That doesn't encourage confidence.

00:37:46.040 --> 00:38:00.600
The second thing that we did was we did this thing called dark moding, which was while the PHP service was still running or while the PHP website was still running, we would take all the requests for the Python pages that we were reporting.

00:38:00.600 --> 00:38:08.220
So like if we were reporting over the slash user page, we would record all the requests that were coming into slash user.

00:38:08.380 --> 00:38:14.160
And then we would just replay all of those, all that traffic onto a detached Python instance.

00:38:14.160 --> 00:38:29.040
And so before we flip the switch or before we flip the proxy pass from Apache to point slash user at the actual Python backend, we would sort of run dummy traffic through our Python code base with a read only database user.

00:38:29.160 --> 00:38:36.220
And just make sure that like no matter, like we would take real traffic and make sure at least that they all rendered.

00:38:36.220 --> 00:38:37.000
Wow.

00:38:37.000 --> 00:38:37.660
That's pretty cool.

00:38:37.660 --> 00:38:44.300
So another super lightweight way to do testing, but you just take all the traffic and you feed it over there.

00:38:44.300 --> 00:38:47.520
And again, it had better not return 500 and things like that.

00:38:47.520 --> 00:38:47.700
Right.

00:38:47.700 --> 00:38:50.820
Like these are the actual types of query string parameters we're seeing.

00:38:50.820 --> 00:38:54.520
These are the, you know, the route data that's coming in, that kind of stuff.

00:38:54.520 --> 00:38:54.760
Right.

00:38:54.760 --> 00:38:55.680
Yeah, exactly.

00:38:55.680 --> 00:38:56.620
Like this is the cookie.

00:38:56.620 --> 00:38:57.720
This is the logged in user.

00:38:57.720 --> 00:38:58.540
These are the headers.

00:38:58.540 --> 00:39:03.820
A lot of these things were like, we were able to leverage our existing system.

00:39:03.820 --> 00:39:08.440
And like, if we didn't have an existing user base, we would have had a harder time with that.

00:39:08.440 --> 00:39:16.880
But because we did have an actual live product, it gave us a lot of confidence that when we ship something live, that it would, you know, comfortably stand up to the traffic.

00:39:16.880 --> 00:39:17.520
Yeah.

00:39:17.520 --> 00:39:18.120
Nice.

00:39:18.120 --> 00:39:21.380
Did you have to do anything special for scaling to handle the load?

00:39:21.380 --> 00:39:23.880
Surprisingly, no.

00:39:23.880 --> 00:39:34.560
A lot of the scalability can be handled, or we found that scalability could be handled nowadays just by ups, like vertically scaling our MySQL instance.

00:39:34.560 --> 00:39:38.820
It was kind of a little bit disappointing to me because I really like performance tuning.

00:39:38.820 --> 00:39:47.160
But it actually, like we're on AWS and we're on using RDS for our database and it made things like extremely easy.

00:39:47.160 --> 00:39:47.600
Right.

00:39:47.600 --> 00:39:48.200
Right.

00:39:48.600 --> 00:39:54.380
And I haven't used RDS on Amazon too much, but that's relational database as a service, right?

00:39:54.380 --> 00:39:59.420
And so you can go over there and can you just turn a knob, just say, I need more database and you get it?

00:39:59.420 --> 00:39:59.920
Yeah.

00:39:59.980 --> 00:40:04.580
If you want to upgrade something from four cores, 16 cores, like basically one switch does it.

00:40:04.580 --> 00:40:06.120
Yeah.

00:40:06.120 --> 00:40:07.240
The cloud is awesome, isn't it?

00:40:07.240 --> 00:40:07.780
Yeah.

00:40:07.780 --> 00:40:14.840
Do you guys have it like geo-replicated anywhere or is it in one particular data center?

00:40:15.380 --> 00:40:20.120
We haven't replicated across availability zones, but not across regions right now.

00:40:20.120 --> 00:40:20.740
Sure.

00:40:20.740 --> 00:40:21.040
Okay.

00:40:21.040 --> 00:40:21.640
Makes sense.

00:40:21.640 --> 00:40:27.320
Are there any special techniques or things you've learned porting PHP to Python?

00:40:27.820 --> 00:40:31.900
Any tips and hard-earned things you can share with the listeners?

00:40:32.640 --> 00:40:41.100
Well, when it started out, we, so again, we didn't have a lot of Python experience or a lot of like deep Python experience within the company.

00:40:42.080 --> 00:40:48.540
So the first thing we had to do was sort of like, or the first thing like I did was try to get people really excited about Python.

00:40:48.540 --> 00:40:59.400
And when I started programming in Python, the thing that turned me on like the most to it was Peter Norvig's writing a spelling corrector in 21 lines.

00:40:59.400 --> 00:41:09.260
That, and I think like it was a really good sort of like intro to the advanced features of Python or what like sort of canonical Python looks like.

00:41:09.500 --> 00:41:16.760
Granted, there are a lot of tricks that like are also used in that that like aren't necessarily the most maintainable, but it's actually, it's a really cool demo.

00:41:16.760 --> 00:41:20.020
It's a really cool demo of the language and of like all the features.

00:41:20.020 --> 00:41:21.380
Yeah, that's really cool.

00:41:21.380 --> 00:41:26.700
And I'll put that in the show links, the norvig.com slash spelling dash corrector dot HTML.

00:41:26.700 --> 00:41:28.480
Yeah, I'll put that, I'll put that in the notes.

00:41:28.480 --> 00:41:35.660
In terms of like what tricks we use from porting from PHP to Python,

00:41:36.360 --> 00:41:41.120
Because people were still picking up Python as they were building out the different ported pages,

00:41:41.120 --> 00:41:49.240
we built out a lot of different things to sort of mimic the behavior of PHP in Python, but in a more correct way.

00:41:49.240 --> 00:41:56.380
So for example, like the context globals in Flask would mimic the sort of globals that you would see in PHP.

00:41:57.140 --> 00:42:04.140
Ternary operators, we just wrote a separate function that mimicked the structure of ternary operators in PHP,

00:42:04.140 --> 00:42:06.580
but using a function in Python.

00:42:06.580 --> 00:42:12.980
And like whatever we could do to like lower the cognitive load of going from PHP to Python,

00:42:12.980 --> 00:42:15.260
made things go like a lot simpler.

00:42:15.260 --> 00:42:16.740
Yeah, that makes sense.

00:42:16.740 --> 00:42:18.400
That seems like a really good idea.

00:42:18.820 --> 00:42:27.260
Did you do anything like PyFlakes or any of the sort of PEP 8 type checking tools to see how people are doing there?

00:42:27.260 --> 00:42:33.340
We use, pretty extensively, we use PyCharm inside the company that does the PEP 8 checking for us.

00:42:33.340 --> 00:42:39.860
And it's actually, I usually did development, I mean, I've usually done development on just like Vim or Emacs,

00:42:39.960 --> 00:42:42.100
but I actually really like PyCharm.

00:42:42.100 --> 00:42:47.360
I think it does a pretty good job of things that it wouldn't have caught with a normal text editor.

00:42:47.360 --> 00:42:49.900
I can't agree more.

00:42:49.900 --> 00:42:52.400
I use PyCharm all the time.

00:42:52.400 --> 00:42:53.280
I love PyCharm.

00:42:53.280 --> 00:42:58.400
And I used to use Emacs, but it's all about PyCharm for me these days.

00:42:58.400 --> 00:43:02.560
You know, if it takes an extra second to load, there's a whole lot more goodness on the other side of that, right?

00:43:02.560 --> 00:43:04.320
Yeah, it really saves a lot of time.

00:43:04.320 --> 00:43:09.240
Yeah, you know, if it saves you one bug a week, it's probably saved you an immense amount of time.

00:43:09.240 --> 00:43:13.820
We're actually going to have the PyCharm guys on the show here pretty soon, so excited about that as well.

00:43:13.820 --> 00:43:14.720
Really cool.

00:43:14.720 --> 00:43:17.680
Yeah, they're doing good work, and they have a free version.

00:43:17.680 --> 00:43:22.000
I don't know if everyone knows, but they've got like a community version and a pro version.

00:43:22.000 --> 00:43:23.600
It's pretty affordable, that thing.

00:43:23.600 --> 00:43:25.500
The pro version is definitely worth it.

00:43:25.500 --> 00:43:26.720
Yeah, it's definitely worth it.

00:43:26.720 --> 00:43:30.020
But if you're not convinced, you know, the free version is hard to say, well, I can't try that.

00:43:30.020 --> 00:43:31.280
It's too expensive.

00:43:31.280 --> 00:43:32.480
Nice.

00:43:32.480 --> 00:43:36.680
So overall, you feel like you've made a good choice?

00:43:36.680 --> 00:43:39.120
Looking back, you've got eight months of experience.

00:43:39.120 --> 00:43:40.060
You've got a running site.

00:43:40.060 --> 00:43:41.740
You've had to live with the thing for a while.

00:43:41.740 --> 00:43:42.740
What are your thoughts?

00:43:42.740 --> 00:43:50.000
Yeah, I think one thing that I do wish is that the site were 100% ported right now.

00:43:50.000 --> 00:43:55.720
It would make certain aspects of the operations in architecture much simpler.

00:43:56.260 --> 00:44:01.280
But I'm not unhappy, like I'm actually pretty happy with the place that the port is in right now.

00:44:01.280 --> 00:44:04.620
I think the number one thing is always going to be developer happiness.

00:44:04.620 --> 00:44:09.380
Like if our developers are happy, then that just makes things a lot easier.

00:44:09.380 --> 00:44:11.100
Yeah, I think you're totally right.

00:44:11.100 --> 00:44:14.860
It's very hard to undervalue enthusiasm.

00:44:14.860 --> 00:44:21.560
Being excited about something can really affect the way that you work when you're doing creative things like programming.

00:44:22.020 --> 00:44:27.060
And think just like small things like onboarding new users onto Python or new engineers onto Python.

00:44:27.060 --> 00:44:31.180
It's much easier because it's a much more consistent language.

00:44:31.180 --> 00:44:37.460
PHP has a bunch of really small quirks that are increasingly becoming very specialized knowledge.

00:44:37.460 --> 00:44:40.100
A lot of inconsistencies with the standard library.

00:44:40.100 --> 00:44:47.000
And very small things are easy to learn, but all these sort of active cognitive load of onboarding to a new language.

00:44:47.180 --> 00:44:50.240
And Python has been much, much better with that, especially with Python 3.

00:44:50.240 --> 00:44:52.900
Yeah, Python 3 feels pretty cleaned up.

00:44:52.900 --> 00:44:54.180
I think that makes a lot of sense.

00:44:54.180 --> 00:44:57.600
All right, Albert, I think that might cover it.

00:44:57.600 --> 00:45:01.120
Anything else you want to add on this whole adventure you've been on?

00:45:01.120 --> 00:45:03.220
Not much.

00:45:03.220 --> 00:45:05.320
I think we pretty well covered it.

00:45:06.280 --> 00:45:12.520
So, you know, I'm sure there's a lot of people out there with PHP sites that have considered moving to Python.

00:45:12.520 --> 00:45:14.980
And I'm sure this conversation will be helpful.

00:45:14.980 --> 00:45:16.140
Yes.

00:45:16.140 --> 00:45:19.860
I want to reiterate, of course, it was a very, very serious choice for us.

00:45:19.860 --> 00:45:22.920
We spent a lot of time, like, thinking about it.

00:45:22.920 --> 00:45:28.680
But, like, once we made the decision, or, like, once we decided that that was the right place to go, we just got started right away.

00:45:29.560 --> 00:45:33.060
Were people pretty excited once you kind of decided to do it and start going?

00:45:33.060 --> 00:45:37.120
I think there was a lot of burnout from PHP, and I think there's a lot of excitement around Python.

00:45:37.120 --> 00:45:38.280
So, yes, definitely.

00:45:38.280 --> 00:45:39.540
Yeah, very, very cool.

00:45:39.540 --> 00:45:47.020
All right, before I let you out of here, there's a couple of questions, one of which you've actually answered already, that I always ask my guests at the end.

00:45:47.320 --> 00:45:54.100
One is, what's your favorite PyPI package or sort of thing out there that you want to tell people, like, hey, you should go check out X?

00:45:54.100 --> 00:45:59.160
I'll have to think about that.

00:45:59.160 --> 00:46:05.000
Like, I don't want to say requests, because I think that's a pretty difficult answer.

00:46:05.000 --> 00:46:07.960
Request is pretty amazing.

00:46:07.960 --> 00:46:12.620
I learned from the show with Kenneth Reitz that requests have been downloaded 40 million times.

00:46:12.620 --> 00:46:14.720
I mean, that's unbelievable to me.

00:46:14.720 --> 00:46:14.980
Yeah.

00:46:15.400 --> 00:46:21.780
Oh, I think for us, RoeVar has been, like, amazingly good and, like, amazingly easy to set up.

00:46:21.780 --> 00:46:22.680
Okay, awesome.

00:46:22.680 --> 00:46:24.520
And RoeVar, that's R-O-V-A-R.

00:46:24.520 --> 00:46:27.120
R-O-L-L-B-A-R.

00:46:27.120 --> 00:46:33.220
And it's, like, I think this is probably the startup that has, like, only a few people working on it, somewhere and so on.

00:46:33.220 --> 00:46:39.240
But, like, it just, like, saved us so much time in having to, like, build out a sort of error-detecting infrastructure.

00:46:39.240 --> 00:46:39.880
Excellent.

00:46:39.880 --> 00:46:47.920
And it's just always watching, always got your back, which seems like a really powerful thing when you're doing a port like this.

00:46:47.920 --> 00:46:52.240
And you're just probably a little nervous all the time in the beginning.

00:46:52.240 --> 00:46:53.020
Yeah.

00:46:53.140 --> 00:46:59.080
It's, like, very, very comprehensive and that, like, you know, maybe a bit noisy, but, like, really gives us a lot of confidence.

00:46:59.080 --> 00:46:59.720
Yeah.

00:46:59.800 --> 00:47:00.360
That's fantastic.

00:47:00.360 --> 00:47:03.160
The other question I always ask is, what's your favorite editor?

00:47:03.160 --> 00:47:05.460
But we already had our PyCharm conversation.

00:47:05.460 --> 00:47:07.040
Yeah, definitely PyCharm.

00:47:07.040 --> 00:47:07.940
I, like, highly recommend.

00:47:07.940 --> 00:47:08.980
Yeah.

00:47:08.980 --> 00:47:12.720
So, I definitely recommend people go and check out Patreon.

00:47:12.720 --> 00:47:15.080
Albert, you guys have done a fantastic job.

00:47:15.080 --> 00:47:27.460
And if you're out there creating any sort of thing that has short, multiple release cycles, like, even if you're doing an open source package, it seems like that's something you could create a Patreon campaign about and put up there.

00:47:27.460 --> 00:47:32.580
If people want to support it, they can sort of, hey, every time you ship a new version, you know, here's five bucks or something.

00:47:32.580 --> 00:47:33.220
Yeah.

00:47:33.220 --> 00:47:39.100
We have people supporting creators that do anything from, you know, making YouTube videos to making Dwarf Fortress.

00:47:39.100 --> 00:47:41.700
And so, like, we welcome any creator who wants to use us.

00:47:41.700 --> 00:47:42.760
That's great.

00:47:42.820 --> 00:47:45.120
Yeah, it's been a great experience for me, and I definitely recommend.

00:47:45.120 --> 00:47:50.940
If this is the type of thing that would help with your project, then definitely check them out at Patreon.com.

00:47:50.940 --> 00:47:53.700
Albert, thanks for being on the show.

00:47:53.700 --> 00:47:54.320
It's been great, man.

00:47:54.320 --> 00:47:55.140
Yeah, thank you.

00:47:55.140 --> 00:47:56.040
Yeah, bye.

00:47:56.040 --> 00:48:00.360
This has been another episode of Talk Python To Me.

00:48:00.360 --> 00:48:04.920
Today's guest was Albert Hsu, and this episode has been sponsored by CodeChip and Hired.

00:48:04.920 --> 00:48:06.940
Thank you guys for supporting the show.

00:48:06.940 --> 00:48:12.280
Check out CodeChip at CodeChip.com and thank them on Twitter via at CodeChip.

00:48:12.660 --> 00:48:14.440
Don't forget the discount code for listeners.

00:48:14.440 --> 00:48:15.100
It's easy.

00:48:15.100 --> 00:48:16.220
Talk Python.

00:48:16.220 --> 00:48:17.580
All caps, no spaces.

00:48:17.580 --> 00:48:20.760
Hired wants to help you find your next big thing.

00:48:20.760 --> 00:48:26.740
Visit Hired.com slash Talk Python To Me and get five or more offers with salary and equity right up front

00:48:26.740 --> 00:48:30.080
and a special listener signing bonus of $4,000.

00:48:30.960 --> 00:48:38.720
Also, don't forget, awesome t-shirts await you at bit.ly slash Python shirt or just visit the website and click on shirt in the footer.

00:48:39.060 --> 00:48:45.580
You can find the links from the show at Talk Python To Me.com slash episodes slash show slash 14.

00:48:45.580 --> 00:48:48.480
And be sure to subscribe to the show.

00:48:48.480 --> 00:48:51.220
Open your favorite podcatcher and search for Python.

00:48:51.220 --> 00:48:52.660
We should be right at the top.

00:48:53.220 --> 00:48:57.640
You can also find the iTunes and direct RSS link feeds in the footer of the website.

00:48:57.640 --> 00:49:00.140
This is your host, Michael Kennedy.

00:49:00.140 --> 00:49:01.400
Thanks for listening.

00:49:01.400 --> 00:49:03.580
Smix, take us out of here.

00:49:03.580 --> 00:49:05.400
Stating with my voice.

00:49:05.400 --> 00:49:07.180
There's no norm that I can feel within.

00:49:07.180 --> 00:49:08.380
Haven't been sleeping.

00:49:08.380 --> 00:49:10.020
I've been using lots of rest.

00:49:10.020 --> 00:49:12.840
I'll pass the mic back to who rocked it best.

00:49:12.840 --> 00:49:16.220
First, develop, first, develop, first, develop, first.

00:49:16.220 --> 00:49:21.940
First developers, developers, developers, developers.

00:49:21.940 --> 00:49:25.140
developers, developers, developers, developers, developers.

00:49:25.140 --> 00:49:25.640
you