Python:
The Programmer’s Lingua Franca

    Using Python to build bridges between
    technologies, businesses and people
What we'll talk about

•   What is a lingua franca?
•   Why the industry needs one
•   Acmeism – the Ingy approach
•   Past and current examples: BASIC, C,
    and Java
•   Why Python is better
•   TPSL: Teaching Python as a Second (or
    third or fourth) Language
•   Getting past the barriers
What is a lingua franca?
        “a language systematically used to make communication possible
        between people not sharing a mother tongue, in particular when it
        is a third language, distinct from both mother tongues.”
             -- Wikipedia

•   The original “Lingua Franca” was an amalgam of languages
        – Made up of Italian, Arabic, French, Greek, Portuguese, Spanish and
            Turkish.
        – Used in the Mediterranean during the Rennaissance

•   English functions as the de facto modern lingua franca
        – For international business, aviation, science and technology
        – Integrates words from other languages

•   English doesn't fit the strict definition
        – It is often the mother tongue of at least one party...
        – but this example is closer to what we'll talk about
Why do we need one for
programming?
•   So many languages
       – more than 2500 in all (“The Language List” Bill Kinnersley)
       – if you just include popular ones, you still can't learn them
            all
•   Programmers need a vehicle to express concepts to
      one another
•   Programs need a vehicle to interact with one another
       – open data formats
       – standard protocols
       – an API everyone can use
What this audience reported:
                  Number of Languages in Organization
                          5%



                                         14%
      27%




                                                         1 language
                                                         2 languages
                                                         3 languages
                                                         4 or more languages
                                                         Unknown or no answer
                                                   18%




            37%
Ingy döt Net
  •   Inventor of YAML
  •   Leader in the Perl Community
  •   100+ CPAN modules
  •   Several PyPI Modules
  •   Old and New “Activator”
  •   Acmeist
  •   Currently travelling around Europe
Acmeism
•   A different path to mutual comprehension
•   Ideas (modules) need to be shared across all
    language boundaries
•   Build technology that is programming language
    independent
       – YAML – data serialization for many programming
           languages
       – C'Dent - Acmeist Module Language
       – Pegex - Acmeist Parser for creating new
           languages
       – TestML - Acmeist Unit test language (like FIT)
Other programming lingua francas
•   BASIC
        – Used to be everywhere, code samples in math and science
           textbooks
        – Many first generation micro-computer hackers started with this
           language
•   C
        – Widely used and part of most comp-sci programs
        – Most experienced programmers are familiar with it
        – Lower-level language
•   Java
        – Extremely popular, cross-platform, also widely taught
        – Very verbose
        – Open source (GPL) only since 2007 (c.f. Apache Harmony)
... used by this audience
              Language Used to Describe Programming Ideas

             15%                       14%




                                                       14%   C
                                                             Java
                                                             Python
                                                             Other
                                                             No answer




                                                 13%
       43%
Why Python is better
•   Free
•   Easy to read
       – Syntax (specifically indentation) enforces sane visual block
           structure
       – Concise, high-level interpreted language
•   Easy to learn
       – Excellent documentation and tutorials
       – Numerous training resources
•   Increasingly popular
       – Adopted by important organizations: Google, NASA, Disney,
           Sony, SEC
Comparisons
Which language is most readable and concise?

     – Example code adapted from http://www.dmh2000.com/cjpr/
     – Using object oriented C++ instead of C to be more fair
C++
#include   <iostream>
#include   <sstream>
#include   <string>
#include   <vector>

using namespace std;

template<class T> class RedBlackTree {

private:
    static const int red   = 0;
    static const int black = 1;

     int                   m_color;
     T                     m_val;
     RedBlackTree          *m_left;
     RedBlackTree          *m_right;

     RedBlackTree(RedBlackTree *b) {
         m_val      = b->m_val;
         m_left     = b->m_left;
         m_right    = b->m_right;
         m_color    = red;
     }

public:
    RedBlackTree(T      x) {
        m_val           = x;
        m_left          = 0;
        m_right         = 0;
        m_color         = red;
    }

     const RedBlackTree *find(const T &key) const {
         const RedBlackTree *result = 0;
         if (key == m_val) {
             result = this;
         }
         else if (key < m_val) {
             if (m_left != 0) {
                 result = m_left->find(key);
             }
         }
         else {
             if (m_right != 0) {
                 result = m_right->find(key);
             }
         }
         return result;
     }
};
Java
import java.util.*;
public class RedBlackTree<T extends Comparable<T>> {

    public static final int red   = 0;
    public static final int black = 1;

    private   int               __color;
    private   T                 __val;
    private   RedBlackTree<T>   __left;
    private   RedBlackTree<T>   __right;

    private RedBlackTree(RedBlackTree<T> b) {
        __val      = b.__val;
        __left     = b.__left;
        __right    = b.__right;
        __color    = red;
    }

    public RedBlackTree(T x) {
        __val      = x;
        __left     = null;
        __right    = null;
        __color = red;
    }

    public RedBlackTree<T> find(T key) {
        RedBlackTree<T> result = null;
        if (key == __val) {
            result = this;
        }
        else if (key.compareTo(__val) < 0) {
            if (__left != null) {
                result = __left.find(key);
            }
        }
        else {
            if (__right != null) {
                result = __right.find(key);
            }
        }
        return result;
    }
}
Python
class RedBlackTree:
    red, black = range(2)

    def __init__(self,   val=None):
        self.left        = None
        self.right       = None
        self.val         = val
        self.color       = RedBlackTree.red

    def find(self, key):
        result = None
        if (key == self.val):
            result = self
        elif (key < self.val):
            if (self.left != None):
                result = self.left.find(key)
        else:
            if (self.right != None):
                result = self.right.find(key)
        return result
Integration with other languages
•       Python libraries are commonly written in C or C++ when
        performance is a consideration
•       You can use other languages in Python, and Python in other
        languages
           – Inline, PyInline, Inline::Python etc.
•       More projects integrating Python with other programming
        languages:
           – Bridges for C/C++, Java, C#/.NET, PHP, Perl, and more

... and databases
    •   Commercial / enterprise: Oracle, SQL Server, DB2, SAP DB,
        Sybase
    •   Open source: MySQL, PostgreSQL, SQLite, redis, MongoDB
Alternative Python interpreters
Python is an open source language, implementations of
 Python are not controlled by a single commercial entity, as
 was case with Java and is the case with C#.
     – Important for avoiding vendor lock-in
     – PSF license is very permissive
This encourages innovation and allows for alternative
 implementations:
     –   Jython: implemented in Java
     –   Stackless Python: CPython variant
     –   unladen-swallow: Google project for a faster Python
     –   Iron Python: for the .NET Framework
     –   PyPy: also focussing on speed and efficiency
Python as a Second Language
•   What makes it easier to read also makes it easier to
    learn
•   Many programmers come to Python from other
    languages
       – lots of resources (Python wiki) for those switching
       – “Learning Python” by Mark Lutz and David Ascher
       – Ingy's anecdotal evidence
•   Non-English tutorials and documentation
       – http://wiki.python.org/moin/Languages
       – there's even a Python tutorial in Esperanto!
How ActiveState can help
Resources for developer-led initiatives to introduce and
  expand Python usage in your organization

      •
          Commercial support and indemnification
      •
          Quality assured, vendor-backed builds
      •
          Python training from the best in the field
      •
          Development advice
      •
          code.activestate.com
               •
                   PyPM Index
               •
                   Recipes
      •
          Komodo Edit and IDE
Python in the cloud
Cloud application platform for Python and many others languages




     –   not a Platform as a Service... it's for creating your own
     –   based on Cloud Foundry – we've added Python support and a lot more
     –   supports multiple languages: Python, Perl, Ruby, Node.js, Java...
     –   all the Python web frameworks: Django, Bottle, Flask, Pyramid
     –   ... via WSGI
     –   deploy new applications or migrate existing ones
     –   http://activestate.com/cloud
Questions?
Thank You!

      Troy Topnik: troyt@activestate.com

      Ingy döt Net: ingy@activestate.com
               www.acmeism.org

         Speak to a representative about
          ActivePython or Python training:
                 1-866-510-2914
       business-solutions@activestate.com
               www.activestate.com

Python: The Programmer's Lingua Franca

  • 1.
    Python: The Programmer’s LinguaFranca Using Python to build bridges between technologies, businesses and people
  • 2.
    What we'll talkabout • What is a lingua franca? • Why the industry needs one • Acmeism – the Ingy approach • Past and current examples: BASIC, C, and Java • Why Python is better • TPSL: Teaching Python as a Second (or third or fourth) Language • Getting past the barriers
  • 3.
    What is alingua franca? “a language systematically used to make communication possible between people not sharing a mother tongue, in particular when it is a third language, distinct from both mother tongues.” -- Wikipedia • The original “Lingua Franca” was an amalgam of languages – Made up of Italian, Arabic, French, Greek, Portuguese, Spanish and Turkish. – Used in the Mediterranean during the Rennaissance • English functions as the de facto modern lingua franca – For international business, aviation, science and technology – Integrates words from other languages • English doesn't fit the strict definition – It is often the mother tongue of at least one party... – but this example is closer to what we'll talk about
  • 4.
    Why do weneed one for programming? • So many languages – more than 2500 in all (“The Language List” Bill Kinnersley) – if you just include popular ones, you still can't learn them all • Programmers need a vehicle to express concepts to one another • Programs need a vehicle to interact with one another – open data formats – standard protocols – an API everyone can use
  • 5.
    What this audiencereported: Number of Languages in Organization 5% 14% 27% 1 language 2 languages 3 languages 4 or more languages Unknown or no answer 18% 37%
  • 6.
    Ingy döt Net • Inventor of YAML • Leader in the Perl Community • 100+ CPAN modules • Several PyPI Modules • Old and New “Activator” • Acmeist • Currently travelling around Europe
  • 7.
    Acmeism • A different path to mutual comprehension • Ideas (modules) need to be shared across all language boundaries • Build technology that is programming language independent – YAML – data serialization for many programming languages – C'Dent - Acmeist Module Language – Pegex - Acmeist Parser for creating new languages – TestML - Acmeist Unit test language (like FIT)
  • 8.
    Other programming linguafrancas • BASIC – Used to be everywhere, code samples in math and science textbooks – Many first generation micro-computer hackers started with this language • C – Widely used and part of most comp-sci programs – Most experienced programmers are familiar with it – Lower-level language • Java – Extremely popular, cross-platform, also widely taught – Very verbose – Open source (GPL) only since 2007 (c.f. Apache Harmony)
  • 9.
    ... used bythis audience Language Used to Describe Programming Ideas 15% 14% 14% C Java Python Other No answer 13% 43%
  • 10.
    Why Python isbetter • Free • Easy to read – Syntax (specifically indentation) enforces sane visual block structure – Concise, high-level interpreted language • Easy to learn – Excellent documentation and tutorials – Numerous training resources • Increasingly popular – Adopted by important organizations: Google, NASA, Disney, Sony, SEC
  • 11.
    Comparisons Which language ismost readable and concise? – Example code adapted from http://www.dmh2000.com/cjpr/ – Using object oriented C++ instead of C to be more fair
  • 12.
    C++ #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; template<class T> class RedBlackTree { private: static const int red = 0; static const int black = 1; int m_color; T m_val; RedBlackTree *m_left; RedBlackTree *m_right; RedBlackTree(RedBlackTree *b) { m_val = b->m_val; m_left = b->m_left; m_right = b->m_right; m_color = red; } public: RedBlackTree(T x) { m_val = x; m_left = 0; m_right = 0; m_color = red; } const RedBlackTree *find(const T &key) const { const RedBlackTree *result = 0; if (key == m_val) { result = this; } else if (key < m_val) { if (m_left != 0) { result = m_left->find(key); } } else { if (m_right != 0) { result = m_right->find(key); } } return result; } };
  • 13.
    Java import java.util.*; public classRedBlackTree<T extends Comparable<T>> { public static final int red = 0; public static final int black = 1; private int __color; private T __val; private RedBlackTree<T> __left; private RedBlackTree<T> __right; private RedBlackTree(RedBlackTree<T> b) { __val = b.__val; __left = b.__left; __right = b.__right; __color = red; } public RedBlackTree(T x) { __val = x; __left = null; __right = null; __color = red; } public RedBlackTree<T> find(T key) { RedBlackTree<T> result = null; if (key == __val) { result = this; } else if (key.compareTo(__val) < 0) { if (__left != null) { result = __left.find(key); } } else { if (__right != null) { result = __right.find(key); } } return result; } }
  • 14.
    Python class RedBlackTree: red, black = range(2) def __init__(self, val=None): self.left = None self.right = None self.val = val self.color = RedBlackTree.red def find(self, key): result = None if (key == self.val): result = self elif (key < self.val): if (self.left != None): result = self.left.find(key) else: if (self.right != None): result = self.right.find(key) return result
  • 15.
    Integration with otherlanguages • Python libraries are commonly written in C or C++ when performance is a consideration • You can use other languages in Python, and Python in other languages – Inline, PyInline, Inline::Python etc. • More projects integrating Python with other programming languages: – Bridges for C/C++, Java, C#/.NET, PHP, Perl, and more ... and databases • Commercial / enterprise: Oracle, SQL Server, DB2, SAP DB, Sybase • Open source: MySQL, PostgreSQL, SQLite, redis, MongoDB
  • 16.
    Alternative Python interpreters Pythonis an open source language, implementations of Python are not controlled by a single commercial entity, as was case with Java and is the case with C#. – Important for avoiding vendor lock-in – PSF license is very permissive This encourages innovation and allows for alternative implementations: – Jython: implemented in Java – Stackless Python: CPython variant – unladen-swallow: Google project for a faster Python – Iron Python: for the .NET Framework – PyPy: also focussing on speed and efficiency
  • 17.
    Python as aSecond Language • What makes it easier to read also makes it easier to learn • Many programmers come to Python from other languages – lots of resources (Python wiki) for those switching – “Learning Python” by Mark Lutz and David Ascher – Ingy's anecdotal evidence • Non-English tutorials and documentation – http://wiki.python.org/moin/Languages – there's even a Python tutorial in Esperanto!
  • 18.
    How ActiveState canhelp Resources for developer-led initiatives to introduce and expand Python usage in your organization • Commercial support and indemnification • Quality assured, vendor-backed builds • Python training from the best in the field • Development advice • code.activestate.com • PyPM Index • Recipes • Komodo Edit and IDE
  • 19.
    Python in thecloud Cloud application platform for Python and many others languages – not a Platform as a Service... it's for creating your own – based on Cloud Foundry – we've added Python support and a lot more – supports multiple languages: Python, Perl, Ruby, Node.js, Java... – all the Python web frameworks: Django, Bottle, Flask, Pyramid – ... via WSGI – deploy new applications or migrate existing ones – http://activestate.com/cloud
  • 20.
  • 21.
    Thank You! Troy Topnik: troyt@activestate.com Ingy döt Net: ingy@activestate.com www.acmeism.org Speak to a representative about ActivePython or Python training: 1-866-510-2914 business-solutions@activestate.com www.activestate.com