Wednesday, February 8, 2012

Python. Why should you learn python?

Today I was confronted with the question: why should anybody learn python?
And...gee, I couldn't give a strong argument besides: "because I like it, it's clear, fun to work with, and I you can do everything with it"

So in this entry I'll "curate" some facts and opinions of people from the web advocating for the Python programming language.
  1. Because it's a de-facto standard in the industry. [1] [2][3]
  2. Excellent  relation between speed/memory consumption/language features [1]
  3. Very easy to learn [1][2]
  4. Elegant and clear syntax [1]:
  5. class BankAccount(object):
        def __init__(self, initial_balance=0):
            self.balance = initial_balance
        def deposit(self, amount):
            self.balance += amount
        def withdraw(self, amount):
            self.balance -= amount
        def overdrawn(self):
            return self.balance < 0
    my_account = BankAccount(15)
    my_account.withdraw(5)
    print my_account.balance
    
  6. A huge variety of modules to accomplish anything you can think of. [1][2]
  7. Straight forward web programming [1][2]
---------------------------------------------------------------------------------------------------------------
Other unsorted reasons from stack overflow:
As for what tasks can be done:
  • Python is extremely fun to develop in.
  • Everything can be done with Python.
  • If something can't be done, you can create an extension for it.
  • Everything can not only be done, but it can be done fast. For example a program that takes you weeks in C++ might take you a day in Python.
  • Great for prototyping, and even for usage in a commercial setting.
As for language features:
  • Scripting language
  • Multi-paradigms (object oriented, imperative, functional)
  • Dynamic type system
  • Automatic memory management
  • Links to other dynamic languages
  • Embedding into other languages
  • Nice py2exe program that converts python scripts to executables for windows. Other platforms include it by default.
  • Strongly typed without static typing
  • Large standard library
  • Includes lists, dictionaries, sets, and much more as basic data types
  • Some implementations of python compile directly to machine code
  • It is actively being worked on
  • It has an antigravity module as noted by Jeremy Cantrell
  • ...
As for resources available:
  • Python is free to use
  • There are a ton of online resources and free tutorials
  • There are a ton of books on Python
  • There is a large community of developers available for help
--
Why should you learn Python?
  • Because it is a modern, elegant, highest level OO language
  • Because it is highly expressive, i.e., you will earn higher productivity
  • Because it comes with "batteries included" i.e. libraries for whatever you want
  • Because it is well documented and has a well-established community
  • Because it is simple to learn (and easy to read!) if you already know another OO language
  • Because it is relatively portable (that is, portable until you use system-specific features)
  • Because it is free and already installed on any modern Linux distribution (and also on Mac OS X and *BSD, I guess)
As for what can be done in Python: everything except extremely low-level things (i.e. kernels, drivers, programming a microcontroller). Also, you should not use Python directly for number crunching (it is far too slow for that), but you can wrap C or C++ number crunching libraries with Python modules (and it has already been done, the most notable examples being Numpy and Scipy).
------------------------------------------------------------------------------------------------------------------
I'll update this post as I find more convincing rationales advocating for python.

No comments:

Post a Comment