Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PyCon Ireland 2013 Opening Keynote: Mike Müller

PyCon Ireland 2013 Opening Keynote: Mike Müller

(via http://localhost:8000/pycon/2013/talks/the_python_paradox/)
The Python Paradox

How can a programming language be equally appealing to beginners and advanced programmers?

Python is very popular among beginner programmers. Frequently, people who have no programming background use Python to enter into the world of programming. High school students like to use Python and it is often their first programming language. It is relativity easy to learn and get started with. Projects like the Raspberry Pi use it as the preferred way of programming for this little great devices.

On the other hand, Python offers powerful features like metaprogramming that are often more jokingly referred to with the phrase "makes your head explode". Even experienced Python users can learn a lot of sophisticated techniques if they dive deeper into the language. These features often provide the basis for popular frameworks for testing, database and web programming.

This talk explores the features of Python that make it suitable for both extremes of the programmer spectrum. It analyzes this paradoxical situation to find out how much it contributes to Python's success.

PyCon Ireland

October 12, 2013
Tweet

More Decks by PyCon Ireland

Other Decks in Technology

Transcript

  1. The Python Paradox How can a programming language be equally

    appealing to beginners and advanced programmers? Dr.-Ing. Mike Müller Python Academy GmbH & Co. KG October 11, 2013 Dr.-Ing. Mike Müller The Python Paradox 1/40
  2. About Me Scientific background Python user since 1999, Python 1.5.2

    Dr.-Ing. Mike Müller The Python Paradox 2/40
  3. About Me Scientific background Python user since 1999, Python 1.5.2

    Python trainer since 2004 Dr.-Ing. Mike Müller The Python Paradox 2/40
  4. About Me Scientific background Python user since 1999, Python 1.5.2

    Python trainer since 2004 Founded Python Academy in 2006 1 Dr.-Ing. Mike Müller The Python Paradox 2/40
  5. About Me Scientific background Python user since 1999, Python 1.5.2

    Python trainer since 2004 Founded Python Academy in 2006 1 Serial Python conference initiator and organizer Dr.-Ing. Mike Müller The Python Paradox 2/40
  6. About Me Scientific background Python user since 1999, Python 1.5.2

    Python trainer since 2004 Founded Python Academy in 2006 1 Serial Python conference initiator and organizer EuroSciPy, PyCon DE, EuroPython Dr.-Ing. Mike Müller The Python Paradox 2/40
  7. About Me PSF Member Chair Python Software Verband e.V. (German

    PSF equivalent) Dr.-Ing. Mike Müller The Python Paradox 3/40
  8. Why This Talk Running a lot of trainings Different types

    of participants Dr.-Ing. Mike Müller The Python Paradox 4/40
  9. Why This Talk Running a lot of trainings Different types

    of participants Professional software developers (C++, Java) Dr.-Ing. Mike Müller The Python Paradox 4/40
  10. Why This Talk Running a lot of trainings Different types

    of participants Professional software developers (C++, Java) Sysadmins Dr.-Ing. Mike Müller The Python Paradox 4/40
  11. Why This Talk Running a lot of trainings Different types

    of participants Professional software developers (C++, Java) Sysadmins Folks with programming knowledge but little software engineering experience (scientists) Dr.-Ing. Mike Müller The Python Paradox 4/40
  12. Why This Talk Running a lot of trainings Different types

    of participants Professional software developers (C++, Java) Sysadmins Folks with programming knowledge but little software engineering experience (scientists) Total beginners Dr.-Ing. Mike Müller The Python Paradox 4/40
  13. Why This Talk Running a lot of trainings Different types

    of participants Professional software developers (C++, Java) Sysadmins Folks with programming knowledge but little software engineering experience (scientists) Total beginners All seem to get along and many really like it Dr.-Ing. Mike Müller The Python Paradox 4/40
  14. Why This Talk Running a lot of trainings Different types

    of participants Professional software developers (C++, Java) Sysadmins Folks with programming knowledge but little software engineering experience (scientists) Total beginners All seem to get along and many really like it How does this work? Dr.-Ing. Mike Müller The Python Paradox 4/40
  15. First Programming Language for Kids Schools use it (UK) Universities

    for CS 101 Dr.-Ing. Mike Müller The Python Paradox 9/40
  16. Technical Reasons Easy to get started Shallow learning curve Understandable

    syntax Dr.-Ing. Mike Müller The Python Paradox 13/40
  17. Technical Reasons Easy to get started Shallow learning curve Understandable

    syntax Few data types Dr.-Ing. Mike Müller The Python Paradox 13/40
  18. Technical Reasons Easy to get started Shallow learning curve Understandable

    syntax Few data types Partial knowledge really useful (multi-paradigm) Dr.-Ing. Mike Müller The Python Paradox 13/40
  19. Simple Usage Interactive prompt >>> (100 + 10) * 3

    330 Dr.-Ing. Mike Müller The Python Paradox 15/40
  20. Simple Usage import random from matplotlib import pylab pylab.plot(random.random() for

    _ in range(100)) pylab.title(’Simple Plot with Matplotlib’) pylab.xlabel(’X Axis’) pylab.ylabel(’Y Axis’) pylab.show() Dr.-Ing. Mike Müller The Python Paradox 16/40
  21. Example: File-like Objects Looks like a file Behaves like a

    file Dr.-Ing. Mike Müller The Python Paradox 20/40
  22. Example: File-like Objects Looks like a file Behaves like a

    file But is not necessarily a file Dr.-Ing. Mike Müller The Python Paradox 20/40
  23. Using File-like Objects fobj = open(’myfile.txt’) first_line = next(fobj) for

    line in fobj: print(line) Dr.-Ing. Mike Müller The Python Paradox 21/40
  24. Example: Decorators Writing can be involved Using one is simple

    Dr.-Ing. Mike Müller The Python Paradox 23/40
  25. Example: Decorators - Writing Parametrized decorator A function that returns

    a function that returns a function (mostly) Dr.-Ing. Mike Müller The Python Paradox 24/40
  26. Example: Decorators - Writing """Check function arguments for given type.

    """ import functools Dr.-Ing. Mike Müller The Python Paradox 25/40
  27. Example: Decorators - Writing def check(*argtypes): """Function argument type checker.

    """ def _check(func): """Takes the function. """ @functools.wraps(func) def __check(*args): ... return __check return _check Dr.-Ing. Mike Müller The Python Paradox 26/40
  28. Example: Decorators - Writing def __check(*args): """Takes the arguments """

    if len(args) != len(argtypes): msg = ’Expected %d but got %d arguments’ % \ (len(argtypes), len(args)) raise TypeError(msg) for arg, argtype in zip(args, argtypes): if not isinstance(arg, argtype): msg = ’Expected %s but got %s’ % ( argtypes, tuple(type(arg) for arg in args)) raise TypeError(msg) return func(*args) Dr.-Ing. Mike Müller The Python Paradox 27/40
  29. Example: Decorators - Using @check(int, int) def add(a, b): return

    a + b Simple to use Dr.-Ing. Mike Müller The Python Paradox 28/40
  30. Example: Decorators - Using @check(int, int) def add(a, b): return

    a + b Simple to use Not that simple to implement Dr.-Ing. Mike Müller The Python Paradox 28/40
  31. Social Reasons Community “You come for the feature. You stay

    for the community.” Dr.-Ing. Mike Müller The Python Paradox 29/40
  32. Social Reasons Community “You come for the feature. You stay

    for the community.” Stackoverflow: Very fast response time to Python questions Dr.-Ing. Mike Müller The Python Paradox 29/40
  33. Social Reasons Community “You come for the feature. You stay

    for the community.” Stackoverflow: Very fast response time to Python questions Lots of online resources Dr.-Ing. Mike Müller The Python Paradox 29/40
  34. Social Reasons Community “You come for the feature. You stay

    for the community.” Stackoverflow: Very fast response time to Python questions Lots of online resources Great Python conferences Dr.-Ing. Mike Müller The Python Paradox 29/40
  35. Philosophical Reasons Python Zen Python fits your brain Open Source

    Dr.-Ing. Mike Müller The Python Paradox 30/40
  36. Does Python Have an Image Problem? Recent discussion on LinkedIn

    Python Group Dr.-Ing. Mike Müller The Python Paradox 31/40
  37. Does Python Have an Image Problem? Recent discussion on LinkedIn

    Python Group Scripting or glue language label Dr.-Ing. Mike Müller The Python Paradox 31/40
  38. Does Python Have an Image Problem? Recent discussion on LinkedIn

    Python Group Scripting or glue language label Do we need Interfaces and “enterprise-level” features? Dr.-Ing. Mike Müller The Python Paradox 31/40
  39. Does Python Have an Image Problem? Recent discussion on LinkedIn

    Python Group Scripting or glue language label Do we need Interfaces and “enterprise-level” features? Would Python be more accepted in business? Dr.-Ing. Mike Müller The Python Paradox 31/40
  40. Does Python Have an Image Problem? Recent discussion on LinkedIn

    Python Group Scripting or glue language label Do we need Interfaces and “enterprise-level” features? Would Python be more accepted in business? Can we do this without losing the other side of the spectrum? Dr.-Ing. Mike Müller The Python Paradox 31/40
  41. Feature Creep? Python gains more features over time Cannot really

    lose features Dr.-Ing. Mike Müller The Python Paradox 32/40
  42. Feature Creep? Python gains more features over time Cannot really

    lose features Exception: Python 3 got rid of some old things Dr.-Ing. Mike Müller The Python Paradox 32/40
  43. Feature Creep? Python gains more features over time Cannot really

    lose features Exception: Python 3 got rid of some old things Fact: The languages grows Dr.-Ing. Mike Müller The Python Paradox 32/40
  44. Feature Creep? Python gains more features over time Cannot really

    lose features Exception: Python 3 got rid of some old things Fact: The languages grows Do we loose the “small” language that you can keep in your head? Dr.-Ing. Mike Müller The Python Paradox 32/40
  45. Feature Example: List Comprehensions First reactions: “Who needs these? We

    do have loops.” Dr.-Ing. Mike Müller The Python Paradox 33/40
  46. Feature Example: List Comprehensions First reactions: “Who needs these? We

    do have loops.” Later: “This is kind of weird, but works pretty well.” Dr.-Ing. Mike Müller The Python Paradox 33/40
  47. Feature Example: List Comprehensions First reactions: “Who needs these? We

    do have loops.” Later: “This is kind of weird, but works pretty well.” Finally: “Best thing since sliced bread.” (http://www.flickr.com/photos/jow/) Dr.-Ing. Mike Müller The Python Paradox 33/40
  48. Feature Example: List Comprehensions First reactions: “Who needs these? We

    do have loops.” Later: “This is kind of weird, but works pretty well.” Finally: “Best thing since sliced bread.” (http://www.flickr.com/photos/jow/) Features are nice and helpful. Dr.-Ing. Mike Müller The Python Paradox 33/40
  49. Feature Example: List Comprehensions First reactions: “Who needs these? We

    do have loops.” Later: “This is kind of weird, but works pretty well.” Finally: “Best thing since sliced bread.” (http://www.flickr.com/photos/jow/) Features are nice and helpful. At the same time they make the language grow. Dr.-Ing. Mike Müller The Python Paradox 33/40
  50. Solution 1: Standard Library Putting things into the standard lib

    instead of the core language may help Dr.-Ing. Mike Müller The Python Paradox 34/40
  51. Solution 1: Standard Library Putting things into the standard lib

    instead of the core language may help Collections Dr.-Ing. Mike Müller The Python Paradox 34/40
  52. Solution 1: Standard Library Putting things into the standard lib

    instead of the core language may help Collections Itertools Dr.-Ing. Mike Müller The Python Paradox 34/40
  53. Solution 1: Standard Library Putting things into the standard lib

    instead of the core language may help Collections Itertools ... Dr.-Ing. Mike Müller The Python Paradox 34/40
  54. Solution 2: Easy Use of Sophisticated Implementations Context managers Decorators

    Metaclasses Dr.-Ing. Mike Müller The Python Paradox 35/40
  55. Example py.test and tox py.test is very simple to use

    for simple cases Dr.-Ing. Mike Müller The Python Paradox 36/40
  56. Example py.test and tox py.test is very simple to use

    for simple cases And still understandable for complex tasks Dr.-Ing. Mike Müller The Python Paradox 36/40
  57. Example py.test and tox py.test is very simple to use

    for simple cases And still understandable for complex tasks I.e., pythonic Dr.-Ing. Mike Müller The Python Paradox 36/40
  58. Example py.test and tox py.test is very simple to use

    for simple cases And still understandable for complex tasks I.e., pythonic However, its implementation is really involved Dr.-Ing. Mike Müller The Python Paradox 36/40
  59. Example py.test and tox py.test is very simple to use

    for simple cases And still understandable for complex tasks I.e., pythonic However, its implementation is really involved The assert statement is re-implemented Dr.-Ing. Mike Müller The Python Paradox 36/40
  60. Example py.test and tox py.test is very simple to use

    for simple cases And still understandable for complex tasks I.e., pythonic However, its implementation is really involved The assert statement is re-implemented Modifying the AST Dr.-Ing. Mike Müller The Python Paradox 36/40
  61. Avoiding Python++ No committee-driven design process please Keep the BDFL

    model Dr.-Ing. Mike Müller The Python Paradox 38/40
  62. Avoiding Python++ No committee-driven design process please Keep the BDFL

    model Limit features in the core language Dr.-Ing. Mike Müller The Python Paradox 38/40
  63. Avoiding Python++ No committee-driven design process please Keep the BDFL

    model Limit features in the core language Less is more Dr.-Ing. Mike Müller The Python Paradox 38/40
  64. Avoiding Python++ No committee-driven design process please Keep the BDFL

    model Limit features in the core language Less is more Improve the standard lib Dr.-Ing. Mike Müller The Python Paradox 38/40
  65. Where should Python go? Multi-Level-User language Serving different kinds of

    users is possible Dr.-Ing. Mike Müller The Python Paradox 39/40
  66. Where should Python go? Multi-Level-User language Serving different kinds of

    users is possible We’ve done pretty well so far Dr.-Ing. Mike Müller The Python Paradox 39/40
  67. Where should Python go? Multi-Level-User language Serving different kinds of

    users is possible We’ve done pretty well so far Can we keep our status and expand to more / new users at the same time? Dr.-Ing. Mike Müller The Python Paradox 39/40