cmpe202 01 research

30
Programming Language Overview Copyright ©2011, Volodymyr Korshak

Upload: vladimirkorshak

Post on 14-May-2015

590 views

Category:

Documents


0 download

DESCRIPTION

CMPE202-01 Research project. SJSU 2011

TRANSCRIPT

Page 1: Cmpe202 01 Research

Programming Language Overview

Copyright ©2011, Volodymyr Korshak

Page 2: Cmpe202 01 Research

Outline

History review. Why and by whom was python created?

Programming philosophy. How is it different to any other language?

Code samples. "Hands on" experience. Usage and Possibilities.

Page 3: Cmpe202 01 Research

History in Brief

Page 4: Cmpe202 01 Research

History overview

Python was conceived in the late 1980s by Guido van Rossum as a successor to the ABC programming language capable of exception handling.

Python has twice been awarded as TIOBE Programming Language of the Year (2007, 2010), which is given to the language with the greatest growth in popularity over the course of the year (as measured by the TIOBE index).

Page 5: Cmpe202 01 Research

Programming Philosophy

Page 6: Cmpe202 01 Research

Programming philosophy

Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage collector for memory management.

Pseudo-code:

Page 7: Cmpe202 01 Research

Programming philosophy

An important feature of Python is dynamic name resolution (late binding), which binds method and variable names during program execution.

Pseudo-code:

Page 8: Cmpe202 01 Research

Programming philosophy

Designed to be highly extensible. New built-in modules can be easily written in C, C++ or Cython.

Most of widely used modules are included in the Standard Library.

"there should be one—and preferably only one—obvious way to do it"

Code should be "beautiful", "explicit" "simple" and “easily-readable”

Page 9: Cmpe202 01 Research

Most famous modules PyGame - Principal wrapper of the SDL library.

PyQt - Bindings for the cross-platform Qt framework.

Python Imaging Library (PIL) - Supports many file formats, and provides powerful image processing and graphics capabilities.

Django - High-level web framework.

web2py - High-level framework for agile development.

And many, many other powerful libraries, frameworks and modules.

Page 10: Cmpe202 01 Research

Code Samples

Page 11: Cmpe202 01 Research

Code Samples: Layout

Python does not use { } to enclose blocks of code for if/loops/function etc.. Instead, Python uses the colon (:) and indentation/whitespace to group statements.

Page 12: Cmpe202 01 Research

Code Samples: Slices

The "slice" syntax is a handy way to refer to sub-parts of sequences - typically strings and lists. The slice s[start:end] is the elements beginning at start and extending up to but not including end.

Page 13: Cmpe202 01 Research

Code Samples: Lists

Python has a great built-in list type named "list". List literals are written within square brackets [ ].

Page 14: Cmpe202 01 Research

Code Samples: For In

Python's “for” and “in” constructs are extremely useful, and the first use of them we'll see is with lists. The “for” construct - for var in list - is an easy way to look at each element in a list (or other collection).

Page 15: Cmpe202 01 Research

Code Samples: List Methods

Common list methods:

Page 16: Cmpe202 01 Research

Code Samples: Dicts

Python's efficient key/value hash table structure is called a "dict". The contents of a dict can be written as a series of key:value pairs within braces { }

Page 17: Cmpe202 01 Research

Code Samples: Dicts

Common “dict” methods:

Page 18: Cmpe202 01 Research

Where is it used?

Page 19: Cmpe202 01 Research

Common Usage

Often used as a scripting language. In operating systems. In large companies and organizations.

Page 20: Cmpe202 01 Research

Common Usage

Often used as a scripting language:

Python has been successfully embedded in a number of software products as a scripting language, including in finite element method software such as Abaqus, 3D animation packages such as Houdini, Maya, MotionBuilder, Softimage, Cinema 4D, BodyPaint 3D, modo and Blender and 2D imaging programs like GIMP, Inkscape, Scribus and Paint Shop Pro.

Page 21: Cmpe202 01 Research

Common Usage

In operating systems:

It ships with most Linux distributions, NetBSD, OpenBSD and with Mac OS X and can be used from the terminal. A number of Linux distributions use installers written in Python: Ubuntu uses the Ubiquity installer, while Red Hat Linux and Fedora use the Anaconda installer. Gentoo Linux uses Python in its package management system, Portage and the standard tool to access it, emerge. Pardus uses it for administration and during system boot.

Page 22: Cmpe202 01 Research

Common Usage

In large companies and organizations:

Among the users of Python are YouTube and the original BitTorrent client. Organizations that make use of Python include Google, Yahoo!, CERN, NASA, ILM, and ITA. Most of the Sugar software for the One Laptop per Child XO, now developed at Sugar Labs, is written in Python.

Page 23: Cmpe202 01 Research

Features

Page 24: Cmpe202 01 Research

Features: Speed and Power

Python is powerful... and fast:

Fans of Python use the phrase "batteries included" to describe the standard library, which covers everything from asynchronous processing to zip files. The language itself is a flexible powerhouse that can handle practically any problem domain.

Page 25: Cmpe202 01 Research

Features: Easy and Open

Python is friendly... and easy to learn:

Python also comes with complete documentation, both integrated into the language and as separate web pages. Online tutorials target both the seasoned programmer and the newcomer. All are designed to make you productive quickly. The availability of first-rate books completes the learning package.

Python is Open:

The Python implementation is under an open source license that makes it freely usable and distributable, even for commercial use.

Page 26: Cmpe202 01 Research

Features: Flexible

Python plays well with others:

For Java libraries, use Jython, an implementation of Python for the Java Virtual Machine.

For .NET, try IronPython , Microsoft's new implementation of Python for .NET.

If you find something that Python cannot do, or if you need the performance advantage of low-level code, you can write extension modules in C or C++, or wrap existing code with SWIG or Boost.Python. You can also go the opposite route and embed Python in your own application, providing your users with a language they'll enjoy using.

Page 27: Cmpe202 01 Research

Features: Portable

Python runs everywhere:

Python is available for all major operating systems: Windows, Linux/Unix, OS/2, Mac, Amiga, among others. There are even versions that run on .NET, the Java virtual machine, and Nokia Series 60 cell phones. You'll be pleased to know that the same source code will run unchanged across all implementations.

Page 28: Cmpe202 01 Research

Summary

Page 29: Cmpe202 01 Research

Summary

Python has: very clear, readable syntax intuitive object orientation full modularity, supporting hierarchical packages exception-based error handling very high level dynamic data types extensive standard libraries and third party modules for

virtually every task embeddable within applications as a scripting interface

Page 30: Cmpe202 01 Research

Credits

Materials used: Official web-site: http://www.python.org

Google-python-class: http://code.google.com/edu/

Wikipedia Python article: http://en.wikipedia.org/wiki/Python_(programming_language)

Copyright ©2011, Volodymyr Korshak