HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
Rules for Radicals: Changing the Culture of Python at Facebook

Next Day Video · Youtube · 81 HN points · 2 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention Next Day Video's video "Rules for Radicals: Changing the Culture of Python at Facebook".
Youtube Summary
Jason Fried
http://pyohio.org/schedule/presentation/212/
Today, services built on Python 3.5 using asyncio are widely used at Facebook. But as recently as May of 2014 it was actually impossible to use Python 3 at Facebook. Come learn how we cut the Gordian Knot of dependencies and social aversion to the point where new services are now being written in Python 3 and existing codebases have plans to move to Python 3.5.
HN Theater Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
> Serious answer (seriously): because Python 3 didn't break enough stuff.

I could also be because there was another choice (which is what you also said). Ruby 1.8 -> 1.9 was annoying, but you weren't going to keep using 1.8 given e.g. the speed improvements of 1.9. (Also, who adds breaking changes in minor version numbers?)

There's a great talk about changing the culture around Python3 at Facebook[0], I highly recommend it. Technically, it isn't so hard. Culturally, it can be pretty hard. Calling Python2 "Legacy Python" helped at my $work. My boss agreed that continuing 2.x development wasn't a good investment for the future, given the minor technical challanges involved with moving over a few years.

[0] https://www.youtube.com/watch?v=nRtp9NgtXiA

Aug 28, 2016 · 81 points, 31 comments · submitted by sandGorgon
yeukhon
> - Python 3 is the default for new projects

What teams are using Python at Facebook now? So far job requirements seem to be mainly C++ and PHP.

Do they use Cython to speed up? What about PyPy?

rb2k_
The Production Engineering org at Facebook uses a lot of Python. Check out https://code.facebook.com/posts/1040181199381023/python-in-p...
fbreduc
not many, just some op-y type jobs
peterjlee
Instagram uses django
sandGorgon
one of the interesting things in this video is that Facebook pretty much invented an equivalent of Flatpak/Zeroinstall/Click-packages to deploy their python apps.
justinsaccount
See also https://github.com/pantsbuild/pex

I've had great success using pex to bundle up tools that use a few dependencies. It's a lot simpler than tools that try to bundle a full python distribution.

voltagex_
I wonder why someone hasn't built a simple loader for Windows that wraps pex in an exe with pythonxy.dll. You'd pretty much solve distribution of Python scripts on Windows.
sandGorgon
there are lots of projects that do this - we had a QT app with embedded cherrypy that we bundled using cx_freeze.

Worked in production at a hundred different merchants

voltagex_
https://sourceforge.net/p/cx-freeze/mailman/message/34695906...

And PyInstaller is quite complicated.

xapata
The speaker says, "dependencies are associated with the application (as they should be) rather than with the system"

That's certainly a practical strategy, but it reduces flexibility/modularity. Go-lang shares the same strategy for deployment. Perhaps it was inspired by Java-users.

tedd4u
There's good and bad there, if you need to patch a security vulnerability you may need to redeploy tons of packages on each host (each package that contains a copy of the bad lib code) versus patching it once. Depending on how you deploy that might be no big deal or it might be.
rb2k_
Then again, patching it 'once' usually involves restarting all processes that are dynamically linked anyway (and really hoping that it loads the new lib). If deployment is fully automated and scales well, the only painful thing is the restart to begin with :)
krakensden
It's actually not super hard, Unix has pretty good support for this, and a lot of companies have something like this internally. The gulf between "good enough for a company" and "good enough for the world" is pretty huge.

Plus, the extent to which people can't do this because they have no/have a terrible build system is generally underestimated.

None
None
sctb
We've changed the link from https://youtu.be/nRtp9NgtXiA. Please submit the full URL, since HN kills links from shorteners as they break the referential integrity of the post.
sandGorgon
interestingly, this is because of mobile apps. I used the share function in the youtube app, coupled with the "copy link" intent on android that pops up. This is the link that was given to me and i pasted it here.

On a mobile device using a native app, it is quite hard/impossible to get a different url. Could you whitelist the youtu.be url ? because I'm guessing this will start to happen more frequently.

throw_away
Or, perhaps hn could just auto-dereference the links to a whitelist of the most popular shorteners & then everyone can be happy?
sctb
Thanks, that's a good idea that has come up before. We've got it on our list to look at.
jimminy
Part of the reason Youtube provides the youtu.be link is that their systems disambiguate between mobile and desktop websites.

Mobile versions have the 'm.' subdomain, and provide a less optimized experience for desktop.

I would also argue that the youtu.be link is a canonical form, since the identifiers are identical to the source. It is just an optimized canonical proxy.

kirkdouglas
I haven't seen the video yet, but did they mention contributing back to the community?
xapata
The punchline:

- Python is popular at Facebook

- Python 3 is the default for new projects

- Changing to Python 3 needed an internal advocate to update build and dev tools to push the change

- Facebook is a big user of the new ``asyncio`` module

Perhaps the most subtle point of the talk is that Facebook managed to change from 2 to 3 from the efforts of just one person. Of course there were more folks changing code than just the speaker, but it appears he was able to heavily influence the culture change. Enabling 3 for the build tools probably made a big difference.

makmanalp
Plus, teaching new hires to use py3 as default, putting in linter warnings to get rid of old bad habits, adding in 2to3 compat layer libraries by default and switching to 3 as default after that seems to have helped.
xapata
All stuff that can be done by 1 person at your company. Go forth and live in the __future__!
ludamad
The cost of 1 person varies heavily though :P
Animats
Changing Python versions is hardly a "culture change". Changing to Go or Rust might be.

The main problem is library support, not the language changes. A large company like Facebook can afford to put someone on library compatibility to make this happen.

xapata
Apparently that wasn't even necessary. The big change for library compatibility was simply changing the settings of the build system. According to the speaker.

In my own experience, most libraries are 3-compatible.

FT_intern
I used to have issues with machine learning libraries and python 3. Were they fixed recently?
alextheparrot
For the most part new projects have been doing a good job of either working with Python 3 out of the gate or making it a main priority (Issue #1 on Tensorflow was Python 3). In general, you'll be fine with Python 3 now. Some older, academic-type packages are still only Python 2.7 (Though might be easy to port).
xapata
For those still stuck on 2, the most likely culprit is not paying attention to the difference between text and bytes. The required change will be using decode when you want text and encode when you want bytes. Not too much trouble for most projects. But it is a tedious change that cannot always be find-replace'd away.
sandGorgon
I'm not sure if you watched the entire video, but I seem to have gotten the impression that all through 2014.. he fixed hundreds of libraries that did not work with Python 3.
None
None
xapata
I watched it while working on other stuff. Must not have noticed that part.

But note that a small company will have correspondingly fewer dependencies. So I'm not sure a small company would need a dedicated upgrade engineer.

cx1000
The size of the company doesn't dictate the number of libraries used. The scope of the work does.
xapata
Size of engineering team and scope of work are correlated, in my experience.
HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.