PHP to Python with No Regrets

22,238 views

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
22,238
On SlideShare
0
From Embeds
0
Number of Embeds
1,553
Actions
Shares
0
Downloads
56
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • - 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
  • \n
  • \n
  • - bad habits: brute force loops vs. generators\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • PHP to Python with No Regrets

    1. 1. PHP to Python:No RegretsThe Grass Is Always Greener Alex Ezell Emma July 31, 2011
    2. 2. the on e on th e left.Hi, I’m
    3. 3. The bloodiest wars in history have been religious wars. -Richard M. Nixon
    4. 4. Why did we change? How did we change? Would I do it all again? What did we learn?
    5. 5. Why did we change?
    6. 6. Change Is What We Do
    7. 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. 8. OpportunityMajor push from the business for new features moreoften and the freedom to make that happenTeam growthStability and agreement in other areas: infrastructure,strategic planning, etc.Developer desire - we simply wanted more.Necessity with regards to current codebase
    9. 9. Code Unity / ManagementLots of background, server processes managing partsof our application. Desire for code in backgroundprocesses to more closely resemble application codeThreading, decoupling, and queueing.Third-party mailer integration.Several small teams working on a single project.
    10. 10. Modernizing Our ToolsetHomegrown PHP Web Framework -> DjangoPEAR_DB -> SQLAlchemyApache -> WSGINo Testing/Docs -> nose and SphinxCVS Update -> Fabric Deploys of Git Repo
    11. 11. Why Python?Maturity and capabilityEase of use / Powerful / Low learning curveRapid developmentFuture of the technologyEcosystem of tools
    12. 12. How did we change?
    13. 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. 14. Service APIScalability, Speed, Fault-tolerant, Easy DeploymentCollection of Python WSGI AppsDelayed processes, log readers, and queue consumersNew structure for all business logicSmaller, tighter codebase - Easier to build onPublic API is just a wrapperHeavy use of Redis
    15. 15. Module Fiesta accounts tantuclient tantu audiencequeueworkers jumper dbsession logparser graffiti
    16. 16. Learn the Python Ecosystem Fabric==1.1.2 meld3==0.6.7 Jinja2==2.5.5 nose==1.0.0 Pygments==1.4 paramiko==1.7.7.1 SQLAlchemy==0.7.0 psycopg2==2.4.1 Sphinx==1.0.7 pycrypto==2.3 Tempita==0.5.1 redis==2.0.0 WebOb==1.0 requests==0.5.0 WebTest==1.2.2 setproctitle==1.1 coverage==3.4 supervisor==3.0a10 decorator==3.3.1 wsgiref==0.1.2 distribute==0.6.16 yoyo-migrations==4.1.0 docutils==0.7
    17. 17. Testing! Testing! Testing! nose, WebOb, WebTest Rapid iteration Distributed team No testing of the Django app piece
    18. 18. Session HandlingLet PHP continue to handle session authenticationTeach Python how to read/write PHP serialization usingScott Hurring’s code: http://hurring.com/scott/code/python/serialize/Django has built-in memcache support, so we makePHP save sessions in memcache
    19. 19. Gotta Get That DataPEAR_DB handled all queries and the databaseconnection with hand-written SQLMoving to multi-database, sharded model - handleconnections seamlesslyHandle different types of encoding seamlesslyRewrite all queries in SQLAlchemy from straight SQL
    20. 20. The Campaign Edit Example2600 lines of code to 700Exact same functionality including some additional stuffNumber of database queries stayed close to the sameVery Javascript heavy, so changes might not be asextensive as other sections
    21. 21. What did we learn?
    22. 22. What We LearnedWe don’t really need a web frameworkDjango is awesome, so is Flask, so is WSGIgit is invaluable for distributed teams on big projectsEasy deployment is vitalData encoding sucks and is hardTimezone handling sucks and is hard
    23. 23. What We LearnedPHP frameworks (CakePHP and Symfony) have comea long way and are on par with DjangoThe shift to sqlalchemy has provided lots of challengesDjango template parsing can be slow in certainsituationsHiring Python developers can be tough, especially inNashvilleJuggling multiple systems is fraught with danger
    24. 24. What We LearnedIncremental rewrites are technically more difficultStarting from scratch would have left us lost in themarketplaceMany of our problems had nothing to do with languagechoice or tools or frameworks
    25. 25. Learning a New LanguagePorting is badBad habits are easy to break in Python, though notunavoidablePython’s interactive interpreter makes tinkering easyEvery developer learns in unique ways and at differentratesReading great code
    26. 26. Would I do it all again?
    27. 27. www.wordle.net
    28. 28. 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
    29. 29. Many of us crucify ourselvesbetween two thieves - regret forthe past and fear of the future. - Fulton Oursler
    30. 30. We’re Launching It Sept.1
    31. 31. Contact Me Email: alex@myemma.com Twitter: @aezellisdead or @emmaemailtech
    32. 32. We Are Hiring at EmmaHappy Hour Tonight at EddieGeorge’s Grill from 6-8pmhttp://myemma.com/tech-jobs/Email: alex@myemma.comTwitter: @aezellisdead or@emmaemailtech
    33. 33. Photo CreditsNixon - BusinessWeek: http://images.businessweek.com/ss/07/04/0426_dow/source/5.htmChange - 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.htmlButterflies - http://21stcenturylearning.typepad.com/blog/2009/01/why-change.htmlSad boy - http://www.psychologytoday.com/blog/ulterior-motives/200806/will-i-regret-it-in-the-morning-how-about-when-im-64

    ×