Here are my live notes on Alex Martelli's keynote "Permission for Forgiveness".
Edit: Here is the video: https://www.youtube.com/watch?v=lEtyYEKqUlk
He starts with a joke about the font in his presentation which looks like Comic Sans but is actually Apple's Chalkboard.
We learn about Grace Hopper who ironically won the first "CS man of the year" award in 1969. Alex talks a lot about her many achievements, one remarkable story is how she caught the first computer bug in the Mark I.
This is fantastic! I always knew about the story why bugs are called bugs but I never knew about this image of the actual first bug being filed.
EAFP means "Easier to ask forgiveness than permission" and it was Hopper's secret recipe for being successful and innovative inside a huge and bureaucratic organization (the Navy). Now that I found this reference in the Python glossary I'm beginning to understand why this is a good keynote for a Python conference :)
Alex gives a nice example of reading files. Many people (me included, shame on me) would first check if the file exists and then access the file. However, this is really stupid because one second after your check another process might just delete the file and renders your check worthless. Better just read the file and capture any exception. Or in other words, ask for forgiveness.
Another common example is the
hasattr call. Python often has defaults,
so you could just as well just call
getattr and return a default if
the attribute cannot be found.
Interesting example. Optimistic concurrency: Instead of creating blocks of code that are protected by locks (asking for permission), just do it, but have means to detect if the object you are working on, has been changed while working, also make sure that your work is in a transaction that can be reversed. Now, if the object changes while you are working on it, just rollback and try again. This is very common with relational databases and I really wonder how this could be implemented when working with Python objects.
Source control is another example. In most modern version control systems you can just push your code and the system will try to just do it and ask for your help if someone else pushed just before you. Ironically Microsoft's Visual Source Save locks files (at least a few years ago when I last worked with it). How fitting for a large bureaucratic organization.
At least for modern tech startups, the agile approach has clearly won. Just launch a beta of your software as quickly as possible and see what happens. When I think about it, Facebook clearly follows this model and shoots first, asks for forgiveness later. Well... actually they never really ask for forgiveness, I think :)
You shouldn't do EAFP everywhere and all the time. Where there are rules that make sense and that have protocols attached to them that make it possible to actually work with the rules, you should, obviously, follow them.
Highly security relevant systems might be an example where EAFP would be rather harmful.
EAFP is not a license to do evil and ask for permission later.
Great keynote for a PyCon. I like the general theme and idea to just go ahead and do things, as long as you don't do evil. It's also kind of encouraging to try to stand out even when facing seemingly impossible to overcome bureaucratic barriers.
Slides can be found here