7. Big, Hairy Ass Goals
Rewrite the platform incrementally
Provide a world-class customer API
Reexamine every tool
Quadruple the tech team
Lead instead of follow
8. Opportunity
Major push from the business for new features more
often and the freedom to make that happen
Team growth
Stability and agreement in other areas: infrastructure,
strategic planning, etc.
Developer desire - we simply wanted more.
Necessity with regards to current codebase
9. Code Unity / Management
Lots of background, server processes managing parts
of our application. Desire for code in background
processes to more closely resemble application code
Threading, decoupling, and queueing.
Third-party mailer integration.
Several small teams working on a single project.
10. Modernizing Our Toolset
Homegrown PHP Web Framework -> Django
PEAR_DB -> SQLAlchemy
Apache -> WSGI
No Testing/Docs -> nose and Sphinx
CVS Update -> Fabric Deploys of Git Repo
11. Why Python?
Maturity and capability
Ease of use / Powerful / Low learning curve
Rapid development
Future of the technology
Ecosystem of tools
13. Revolution or Evolution?
Stop for a full rewrite and not have something
compelling when you reboot
No new features while the rewrite occurs
Inability to really beta test new stuff
Fairly entrenched customer base
Competition is innovating quickly
14. Service API
Scalability, Speed, Fault-tolerant, Easy Deployment
Collection of Python WSGI Apps
Delayed processes, log readers, and queue consumers
New structure for all business logic
Smaller, tighter codebase - Easier to build on
Public API is just a wrapper
Heavy use of Redis
17. Testing! Testing! Testing!
nose, WebOb, WebTest
Rapid iteration
Distributed team
No testing of the Django app piece
18. Session Handling
Let PHP continue to handle session authentication
Teach Python how to read/write PHP serialization using
Scott Hurring’s code: http://hurring.com/scott/code/
python/serialize/
Django has built-in memcache support, so we make
PHP save sessions in memcache
19. Gotta Get That Data
PEAR_DB handled all queries and the database
connection with hand-written SQL
Moving to multi-database, sharded model - handle
connections seamlessly
Handle different types of encoding seamlessly
Rewrite all queries in SQLAlchemy from straight SQL
20.
21.
22. The Campaign Edit Example
2600 lines of code to 700
Exact same functionality including some additional stuff
Number of database queries stayed close to the same
Very Javascript heavy, so changes might not be as
extensive as other sections
26. What We Learned
We don’t really need a web framework
Django is awesome, so is Flask, so is WSGI
git is invaluable for distributed teams on big projects
Easy deployment is vital
Data encoding sucks and is hard
Timezone handling sucks and is hard
27. What We Learned
PHP frameworks (CakePHP and Symfony) have come
a long way and are on par with Django
The shift to sqlalchemy has provided lots of challenges
Django template parsing can be slow in certain
situations
Hiring Python developers can be tough, especially in
Nashville
Juggling multiple systems is fraught with danger
28. What We Learned
Incremental rewrites are technically more difficult
Starting from scratch would have left us lost in the
marketplace
Many of our problems had nothing to do with language
choice or tools or frameworks
29. Learning a New Language
Porting is bad
Bad habits are easy to break in Python, though not
unavoidable
Python’s interactive interpreter makes tinkering easy
Every developer learns in unique ways and at different
rates
Reading great code
32. Positives
Codebase is becoming more standardized
Developer energy is high
Features we have implemented have turned out well
and been easy to add functionality to
Python’s standard library offers powerful, quality add-
on modules for free
Developers we have hired have been able to contribute
quickly and be impactful
33. Many of us crucify ourselves
between two thieves - regret for
the past and fear of the future.
- Fulton Oursler
35. Contact Me
Email: alex@myemma.com
Twitter: @aezellisdead or @emmaemailtech
36. We Are Hiring at Emma
Happy Hour Tonight at Eddie
George’s Grill from 6-8pm
http://myemma.com/tech-jobs/
Email: alex@myemma.com
Twitter: @aezellisdead or
@emmaemailtech
37. Photo Credits
Nixon - BusinessWeek: http://images.businessweek.com/ss/07/04/0426_dow/
source/5.htm
Change - http://www.flickr.com/photos/spursfan_ace/2328879637/
Kofi Annan - http://www.gambianow.com/news/Open-Forum/Have-Your-Say/
Many_Give_Annan_High_Marks_as_UN_Chief_Despite_Flaws.html
Butterflies - http://21stcenturylearning.typepad.com/blog/2009/01/why-
change.html
Sad boy - http://www.psychologytoday.com/blog/ulterior-motives/200806/will-i-
regret-it-in-the-morning-how-about-when-im-64
Hinweis der Redaktion
- while there will be some comparison of languages, this isn’t a talk about which language is better, it’s more about why we chose to switch from PHP to Python\n\n
Name, Title, Experience?\n
- because knowledge is power, I know more about this than you know about that\n- because success begets success, why change what you’re good at?\n- because language, even computer language, is a very personal human construct\n
4 topics for the preso\n
\n
- software development, especially web, is centered around change\n- business health demands change, mostly growth, but also strategic\n- personal growth demands change, not necessarily language, but new challenges\n
\n
- Looking at a complete rewrite of code for PHP 5/6 compliance\n- Current framework was showing its age: older templating system, older database access layer, maintenance was becoming a chore, adding new features was really difficult\n
- yes, php can run from the command line -- environment, database connection, etc.\n- python is more general purpose from its inception\n- reuse code in scripts\n- threading in mailer processes, yay!\n
- evaluation really began with looking at available Frameworks\n- What’s the most mature and can be used right now?\n- What has some capabilities to change where we might need change?\n- Who has a favorite framework? Name the thing you like most about it.\n
- maturity/capability - who’s using it now? will it integrate with our other tools (database)?\n- use/learning - can we learn it? do we want to?\n- django’s user base is growing exponentially\n- python’s standard library - lots of quality modules\n\n
Talk about timeline\n
- tipping point where retrofit changes sides\n
\n
\n
\n
\n
- added some code to the session stuff\n- wanted to pave the way for Django user management, because it’s nice\n
- multi-database needs to shift on the fly\n- special encoding types: Latin 1, ASCII, Unicode\n- speed of sqlalchemy or the Django ORM - objects vs. arrays\n- writing queries was a big learning curve\n
PHP response. Lots of tables. Many queries. Bad structure forcing bad code.\n
sqlalchemy version of the same query. Better database structure begets better code.\n
- code includes html, db access, javascript, everything\n- queries are interesting because they don’t change much and might actually be more code\n
\n
\n
\n
- do something: internal tools, one-off fun project\n- direction: concurrency, speed, etc.\n