-
Notifications
You must be signed in to change notification settings - Fork 7
/
introduction.txt
executable file
·91 lines (72 loc) · 3.99 KB
/
introduction.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
============
Introduction
============
-------------
Why Stackless
-------------
According the stackless website at http://www.stackless.com/::
Stackless Python is an enhanced version of the Python programming language.
It allows programmers to reap the benefits of thread-based programming
without the performance and complexity problems associated with
conventional threads. The microthreads that Stackless adds to Python are a
cheap and lightweight convenience which can if used properly, give the
following benefits:
+ Improved program structure.
+ More readable code.
+ Increased programmer productivity.
Which acts as a very concise definition of stackless python, but what does that
mean to us? It means that stackless provides the tools to model concurrency
more easily than you can currently do in most conventional languages. We're
not just talking about Python itself, but Java, C/C++ and other languages as
well. Although there are some languages out there that provide concurrency
features, they are either languages languages being primarily used in academia
(such as Mozart/Oz) or lesser used/special purpose professional languages (such
as erlang). With stackless, you get concurrency in addition to all of the
advantages of python itself, in an environment that you are (hopefully) already
familiar with.
This of course begs the question: Why concurrency?
The Real World is Concurrent
============================
The real world is 'concurrent'. It is made up of a bunch of things (or
**actors**) that interact with each other in a loosely coupled way with limited
knowledge of each other. One of the purported benefits of object-oriented
programming is that objects model things in the real world. To a certain
extent, this is true. Object-oriented programming does a good job modelling
individual objects, but it doesn't do a very good job representing interactions
between these individual objects in a realistic way. For example, what is
wrong with the following code example?
::
def familyTacoNight():
husband.eat(dinner)
wife.eat(dinner)
son.eat(dinner)
daughter.eat(dinner)
At first glance, nothing. But there is a subtle programs with the above
example; the events occur serially. That is, the wife does not eat until after
the husband is completed with his meal, the son doesn't eat until the wife is
done, and the daughter is last in line. In the real world, the wife, son,
and daughter will eat even if the husband gets caught in a traffic jam. In the
above example they'll starve to death. Even worse no one will ever know
because they'll never get the opportunity to throw an exception and notify the
world!
Concurrency might, just might, be the next big programming paradigm
===================================================================
I personally believe that concurrency is the next big paradigm in the software
world. As programs become more complex and resource intensive, we can no
longer count on Moore's Law providing us with faster processors every year.
Current performance increases in commodity PC's are coming from multi-core and
multi-cpu machines. Once an individual CPU is maxed out for performance,
software developers will have to move to distributed models where multiple
computers interact with each other to create a high powered application (think
think GooglePlex). To take advantage of both multi-core machines and
distributed programming, concurrency quickly becomes the de-facto standard way
of doing things.
--------------------
Installing Stackless
--------------------
Details for installing stackless can be found on the stackless website.
Currently, linux users can get the source from subversion and perform a build.
For windows users, there is an available .zip file that has to be extracted
into an existing installation of python. The rest of this tutorial assumes
that you have a working installation of stackless python, along with a basic
understanding of the python language itself.