snakes on the web; developing web applications in python

25
Snakes on the web an overview of developing web applications in . 2014 kickstart Tech-Talks @kudanai

Post on 17-Oct-2014

294 views

Category:

Software


1 download

DESCRIPTION

From kickstart 2014 tech-talks. The presentation gives an overview of web application development in python.

TRANSCRIPT

Page 1: Snakes on the Web; Developing web applications in python

Snakes on the web!

an overview of developing web applications in .!

2014 kickstart Tech-Talks @kudanai!

Page 2: Snakes on the Web; Developing web applications in python

hi…sssssss…!•  Naail Abdul Rahman!–  a.k.a. @kudanai (http://kudanai.com)!

•  Freelance developer!–  Specializing in!

•  back-end systems!•  Mobile applications!•  Web applications!•  … in that order!

–  not so much!•  UI/design/front-end stuff…!

•  …and part time lecturer!–  Villa college, Clique College.!

2014 Kickstart Tech-Talks @kudanai!

Page 3: Snakes on the Web; Developing web applications in python

– B.Sc (Physics, Math, CS)!– M.Sc (Software Engineering)!

– Plenty of non-formal education!– … been around for a while now.!

2014 Kickstart Tech-Talks @kudanai!

Page 4: Snakes on the Web; Developing web applications in python

Full Disclosure!•  I love Python!– Use it for practically everything!

•  … IF I can get away with it.!•  BUT…!–  no delusions here!

•  Python has its moments!•  It’s a choice!

•  After years of messing around with other languages.!•  …also!– By “web”, I don’t necessarily mean the world-

wide-web.!

2014 Kickstart Tech-Talks @kudanai!

Page 5: Snakes on the Web; Developing web applications in python

2014 Kickstart Tech-Talks @kudanai!

Page 6: Snakes on the Web; Developing web applications in python

Python!•  1989 as a successor to ABC!–  Guido Van Rossum!–  It’s been around for a while.!

•  Philosophy (Zen of Python, PEP 20)!-  Beautiful is better than ugly!-  Explicit is better than implicit!-  Simple is better than complex!-  Complex is better than complicated!-  Flat is better than nested!-  Sparse is better than dense!-  Readability counts!-  …!

2014 Kickstart Tech-Talks @kudanai!

Page 7: Snakes on the Web; Developing web applications in python

Python!•  What it has going for it…!–  Really easy to learn!–  Good for pretty much anything, really!–  General purpose programming!–  Really descriptive!–  Good congruence with mathematical conventions!–  Excellent data structures!–  Really good standard library!–  Excellent, beautiful documentation!–  Awesome community!–  Python3 and its break from backwards compatibility.!

2014 Kickstart Tech-Talks @kudanai!

Page 8: Snakes on the Web; Developing web applications in python

Python!–  Excellent package management!–  Alternative interpreters!

•  Jython, Iron Python etc…!•  What’s not so good about it!–  Interpretation lag!–  Speed, in certain situations!–  Was never really designed for web stuff anyway…!

•  Hosting support and stuff is limited, but on the rise.!–  A bit harder to deploy (as opposed to, say, PHP)!–  Direct database interactions can be a bit clunky!–  Not so great (right now) for real-time stuff!

2014 Kickstart Tech-Talks @kudanai!

Page 9: Snakes on the Web; Developing web applications in python

Python!•  Who uses it?!

–  Google!•  A large part of Google internals are written on python, like Groups,

Maps, Gmail, Blogger!–  Reddit!

•  Rebuilt on python ~2005!–  Youtube!–  Digg!–  Dropbox!–  Instagram!–  Pinterest!–  FriendFeed!–  Quora!–  … to name a few!

2014 Kickstart Tech-Talks @kudanai!

Page 10: Snakes on the Web; Developing web applications in python

Python for the web!•  What’s available?!– DBAPI, libraries, ORM’s, template engines and

so forth…!–  Frameworks and stuff!

•  Zope3, Pyramid/Pylons, Django, Flask, Bottle, web2py, Grok, so on and so forth…!

•  Hosting support and stuff!– OOTB Support!

•  Support on Apache, Nginx!– PAAS support!

•  Start a flame war…!

2014 Kickstart Tech-Talks @kudanai!

Page 11: Snakes on the Web; Developing web applications in python

What’s available!•  Databases!

–  Backbone of most modern web applications!–  Support is pretty great.!–  Supported databases!

•  Postgres!•  MySQL!•  IBM DB2!•  MSSSQL!•  Oracle!•  SAP DB!•  ODBC Stuff!•  ADO Stuff!•  SQLite!•  BerkeleyDB!•  MongoDB!

2014 Kickstart Tech-Talks @kudanai!

Page 12: Snakes on the Web; Developing web applications in python

What’s available!•  Libraries!– Extensive Python library set!

•  Can be installed locally as part of the project itself!– Package management via pip!–  Isolate environments via Virtualenv!

•  Keep packages and even interpreter independent for multiple deployments!•  Built-in to Python3!

2014 Kickstart Tech-Talks @kudanai!

Page 13: Snakes on the Web; Developing web applications in python

What’s available!•  Template engines!– Mako, Chameleon, Cheetah, Wheezy, Genshi,

Jinja…!– Django template engine!

•  Inspired Jinja!•  Also inspired things like AngularJS!

–  Very similar.!–  There are literally hundreds out there.!

•  Other stuff!–  LESS/SASS compilers!

2014 Kickstart Tech-Talks @kudanai!

Page 14: Snakes on the Web; Developing web applications in python

What’s available!•  ORM’s!– Bazaar, forgetSQL, SQLAlchemy, Django,

Axiom!– Healthy pick…!

2014 Kickstart Tech-Talks @kudanai!

Page 15: Snakes on the Web; Developing web applications in python

What’s available!•  SQLAlchemy!– One of the best out there!– Used by:!

•  Reddit!•  Yelp!!•  Mozilla!•  OpenStack!•  Fedora!•  Dropbox!•  Surveymonkey!•  Sourceforge!

– Never touch SQL stuff…!

2014 Kickstart Tech-Talks @kudanai!

Page 16: Snakes on the Web; Developing web applications in python

Frameworks!•  Zope3!– The granddaddy of python frameworks!– Been around since 1999!– Batteries included!

•  Provides configurable modules for!–  Authentication!–  Templating!– DB handling!–  Routing etc…!–  I8n!–  ZODB!

2014 Kickstart Tech-Talks @kudanai!

Page 17: Snakes on the Web; Developing web applications in python

Frameworks!•  Pylons/Pyramid!– Pylons!

•  Collection of tools rather than particular tech!•  Pyramid is one of these!

– Pyramid!•  Minimalist framework inspired by Zope, Django

and Pylons (the original)!•  Designed to be modular!

–  Pick which engines to use!–  Eg: popular config is Pyramid + SQLAlchemy + Jinja2!

2014 Kickstart Tech-Talks @kudanai!

Page 18: Snakes on the Web; Developing web applications in python

Frameworks!•  Flask!– “micro” framework!– plug in what you need!

•  By default uses jinj2 for templating!•  Free to pick DB interaction!

–  SQLAlchemy is popular!

– Really good at doing RESTful stuff!–  Integrated unit-testing (nose)!– Very little overhead, so will fit pretty much

anywhere where python can run!

2014 Kickstart Tech-Talks @kudanai!

Page 19: Snakes on the Web; Developing web applications in python

Frameworks!•  Django!– By far the most popular!– Seriously batteries included!– HUGE community!

•  Massive library of drop-in modules!– ORM (which inspired SQLAlchemy)!

•  Can support SQLite, Postgres, MySQL, MSSQL!– Automatic, customizable admin!

•  Can handle CRUD on models!•  Manage users, permissions on a per model basis!

–  Template engine (inspired Jinja, AngularJS)!

2014 Kickstart Tech-Talks @kudanai!

Page 20: Snakes on the Web; Developing web applications in python

Frameworks!•  Tie-in with the front-end!– Almost all these are MVC style applications!–  Front-end is defined by the templates (usually)!– Relies on Apache/Nginx etc… to serve static

media!•  Can leverage this for very robust rich applications!

–  Rapidly deploy REST back-ends using Flask/Django etc..!–  REST drop-ins can leverage model definitions quite nicely!–  Deploy Single Page apps over static channels!

2014 Kickstart Tech-Talks @kudanai!

Page 21: Snakes on the Web; Developing web applications in python

Deployment!•  Python Support!– Hosts that provide VPS and a Python install!

•  Configure through CGI/FastCGI!– Not optimal, but possible!

– Python friendly hosts are increasing!•  Site5, BlueHost, HostMonster, etc… work well!

– PAAS!•  Heroko, DotCloud, Pythonanywhere!

!

2014 Kickstart Tech-Talks @kudanai!

Page 22: Snakes on the Web; Developing web applications in python

Deployment!•  Apache / Nginx!– Support python deployments through!

•  fastCGI!•  WSGI interface via mod_wsgi!

– Web Server Gateway Interface!– Communication between server and Python framework!–  Recommended!– … Synchronous!

2014 Kickstart Tech-Talks @kudanai!

Page 23: Snakes on the Web; Developing web applications in python

Deployment!•  Real-Time apps become messy!– WSGI is blocking, and synchronous by

definition.!– uWSGI (and other implementations) are

coming around to it.!

2014 Kickstart Tech-Talks @kudanai!

Page 24: Snakes on the Web; Developing web applications in python

Deployment!•  Asynchronous stuff!– Greenlets!

•  Combining WSGI with Gevent !•  A bit “hackish” TBH!

– Tornado!•  Developed by FriendFeed, maintained by

Facebook!•  Very robust!

2014 Kickstart Tech-Talks @kudanai!

Page 25: Snakes on the Web; Developing web applications in python

Q&A!

Thanks!!

Don’t forget to follow @kudanai on twitter!

2014 Kickstart Tech-Talks @kudanai!