15.04.2013 Views

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1.3. Features<br />

Although it has been around for well over fifteen years, some feel that <strong>Python</strong> is still relatively new to<br />

the general software development industry. We should, however, use caution with our use of the word<br />

"relatively," as a few years seem like decades when developing on "Internet time."<br />

When people ask, "What is <strong>Python</strong>?" it is difficult to say any one thing. The tendency is to want to blurt<br />

out all the things that you feel <strong>Python</strong> is in one breath. <strong>Python</strong> is (fill-in-the-blanks here). Just what are<br />

some of those features? For your sanity, we will elucidate each here ... one at a time.<br />

1.3.1. High Level<br />

It seems that with every generation of languages, we move to a higher level. Assembly was a godsend<br />

for those who struggled with machine code, then came FORTRAN, C, and Pascal, which took computing<br />

to another plane and created the software development industry. Through C came more modern<br />

compiled languages, C++ and Java. And further still we climb, with powerful, system-accessible,<br />

interpreted scripting languages like Tcl, Perl, and <strong>Python</strong>.<br />

Each of these languages has higher-level data structures that reduce the "framework" development time<br />

that was once required. Useful types like <strong>Python</strong>'s lists (resizeable arrays) and dictionaries (hash tables)<br />

are built into the language. Providing these crucial building blocks in the core language encourages their<br />

use and minimizes development time as well as code size, resulting in more readable code.<br />

Because there is no one standard library for heterogeneous arrays (lists in <strong>Python</strong>) and hash tables<br />

(<strong>Python</strong> dictionaries or "dicts" for short) in C, they are often reimplemented and copied to each new<br />

project. This process is messy and error prone. C++ improves the situation with the standard template<br />

library, but the STL can hardly compare to the simplicity and readability of <strong>Python</strong>'s built-in lists and<br />

dicts.<br />

1.3.2. Object Oriented<br />

Object-oriented programming (OOP) adds another dimension to structured and procedural languages<br />

where data and logic are discrete elements of programming. OOP allows for associating specific<br />

behaviors, characteristics, and/or capabilities with the data that they execute on or are representative<br />

of. <strong>Python</strong> is an object-oriented (OO) language, all the way down to its core. However, <strong>Python</strong> is not just<br />

an OO language like Java or Ruby. It is actually a pleasant mix of multiple programming paradigms. For<br />

instance, it even borrows a few things from functional languages like Lisp and Haskell.<br />

1.3.3. Scalable<br />

<strong>Python</strong> is often compared to batch or Unix shell scripting languages. Simple shell scripts handle simple<br />

tasks. They may grow (indefinitely) in length, but not truly in depth. There is little code-reusability and<br />

you are confined to small projects with shell scripts. In fact, even small projects may lead to large and<br />

unwieldy scripts. Not so with <strong>Python</strong>, where you can grow your code from project to project, add other<br />

new or existing <strong>Python</strong> elements, and reuse code at your whim. <strong>Python</strong> encourages clean code design,<br />

high-level structure, and "packaging" of multiple components, all of which deliver the flexibility,<br />

consistency, and faster development time required as projects expand in breadth and scope.<br />

The term "scalable" is most often applied to measuring hardware throughput and usually refers to<br />

additional performance when new hardware is added to a system. We would like to differentiate this<br />

comparison with ours here, which tries to reflect the notion that <strong>Python</strong> provides basic building blocks on

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!