Download Introduction to Computing and Programming in Python, Global Edition Mark J. Guzdial ebook All Chapters PDF
Download Introduction to Computing and Programming in Python, Global Edition Mark J. Guzdial ebook All Chapters PDF
com
https://ebookmass.com/product/introduction-to-computing-and-
programming-in-python-global-edition-mark-j-guzdial/
OR CLICK HERE
DOWLOAD NOW
https://ebookmass.com/product/introduction-to-computing-and-problem-
solving-using-python-1st-edition-e-balaguruswamy/
ebookmass.com
https://ebookmass.com/product/introduction-to-computation-and-
programming-using-python-third-edition-john-v-guttag/
ebookmass.com
https://ebookmass.com/product/greek-and-roman-technology-a-sourcebook-
of-translated-greek-and-roman-texts-2nd-edition-andrew-n-sherwood/
ebookmass.com
SAP S/4HANA Financial Accounting Configuration: Learn
Configuration and Development on an S/4 System, 2nd
Edition Andrew Okungbowa
https://ebookmass.com/product/sap-s-4hana-financial-accounting-
configuration-learn-configuration-and-development-on-
an-s-4-system-2nd-edition-andrew-okungbowa/
ebookmass.com
https://ebookmass.com/product/etextbook-pdf-for-healthcare-human-
resource-management-3rd-edition/
ebookmass.com
https://ebookmass.com/product/racial-and-ethnic-groups-14th-
edition-14th-edition/
ebookmass.com
https://ebookmass.com/product/developments-in-the-formulation-and-
reinforcement-of-concrete-2nd-ed-edition-mindess/
ebookmass.com
https://ebookmass.com/product/tools-for-teaching-2nd-edition/
ebookmass.com
Where Did the Universe Come From? And Other Cosmic
Questions Ferrie Chris
https://ebookmass.com/product/where-did-the-universe-come-from-and-
other-cosmic-questions-ferrie-chris/
ebookmass.com
Introduction to
Computing and
Programming
TM
in Python
A MULTIMEDIA APPROACH
Fourth Edition
Global Edition
MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE INFORMATION
CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED AS PART OF THE SERVICES FOR ANY PURPOSE. ALL SUCH
DOCUMENTS AND RELATED GRAPHICS ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS
RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION,
INCLUDING ALL WARRANTIES AND CONDITIONS OF MERCHANTABILITY, WHETHER EXPRESS, IMPLIED OR STATUTORY, FITNESS
FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL MICROSOFT AND/OR ITS RESPECTIVE
SUPPLIERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF INFORMATION AVAILABLE FROM THE SERVICES. THE
DOCUMENTS AND RELATED GRAPHICS CONTAINED HEREIN COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL
ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS
MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED HEREIN AT ANY TIME.
PARTIAL SCREEN SHOTS MAY BE VIEWED IN FULL WITHIN THE SOFTWARE VERSION SPECIFIED.
The rights of Mark J. Guzdial and Barbara Ericson to be identified as the authors of this work have been asserted by them in accordance with the
Copyright, Designs and Patents Act 1988.
Authorized adaptation from the United States edition, entitled Introduction to Computing and Programming in Python™ : A Multimedia Approach, Fourth
Edition, ISBN 9780134025544, by Mark J. Guzdial and Barbara Ericson published by Pearson Education © 2016.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic,
mechanical, photocopying, recording or otherwise, without either the prior written permission of the publisher or a license permitting restricted copying in
the United Kingdom issued by the Copyright Licensing Agency Ltd, Saffron House, 6−10 Kirby Street, London EC1N 8TS.
All trademarks used herein are the property of their respective owners. The use of any trademark in this text does not vest in the author or publisher any
trademark ownership rights in such trademarks, nor does the use of such trademarks imply any affiliation with or endorsement of this book by such owners.
A catalogue record for this book is available from the British Library
10 9 8 7 6 5 4 3 2 1
1 INTRODUCTION 25
1 Introduction to Computer Science and Media
Computation 27
1.1 What Is Computer Science About? 27
1.2 Programming Languages 30
1.3 What Computers Understand 33
1.4 Media Computation: Why Digitize Media? 35
1.5 Computer Science for Everyone 37
1.5.1 It’s About Communication 37
1.5.2 It’s About Process 37
1.5.3 You Will Probably Need It 38
2 Introduction to Programming 42
2.1 Programming Is About Naming 42
2.1.1 Files and Their Names 44
2.2 Programming in Python 45
2.3 Programming in JES 46
2.4 Media Computation in JES 47
2.4.1 Showing a Picture 51
2.4.2 Playing a Sound 54
2.4.3 Naming Values 54
2.5 Making a Program 57
2.5.1 Functions: Real Math-Like Functions That Take
Input 61
6 Contents
2 SOUND 225
7 Modifying Sounds Using Loops 227
7.1 How Sound Is Encoded 227
7.1.1 The Physics of Sound 227
7.1.2 Investigating Different Sounds 230
7.1.3 Encoding the Sound 235
7.1.4 Binary Numbers and Two’s Complement 236
7.1.5 Storing Digitized Sounds 237
7.2 Manipulating Sounds 239
7.2.1 Open Sounds and Manipulating Samples 239
7.2.2 Using the JES MediaTools 242
7.2.3 Looping 243
7.3 Changing the Volume of Sounds 244
8 Contents
4 MOVIES 407
14 Creating and Modifying Movies 409
14.1 Generating Animations 410
14.2 Working with Video Source 419
14.2.1 Video Manipulating Examples 419
14.3 Building a Video Effect Bottom-Up 423
15 Speed 430
15.1 Focusing on Computer Science 430
15.2 What Makes Programs Fast? 430
15.2.1 What Computers Really Understand 431
15.2.2 Compilers and Interpreters 432
15.2.3 What Limits Computer Speed? 436
15.2.4 Does It Really Make a Difference? 438
15.2.5 Making Searching Faster 441
15.2.6 Algorithms That Never Finish or Can’t Be Written 443
15.2.7 Why Is Photoshop Faster than JES? 444
15.3 What Makes a Computer Fast? 444
15.3.1 Clock Rates and Actual Computation 445
15.3.2 Storage: What Makes a Computer Slow? 446
15.3.3 Display 447
Contents 11
APPENDIX 506
A Quick Reference to Python 506
A.1 Variables 506
A.2 Function Creation 507
A.3 Loops and Conditionals 507
A.4 Operators and Representation Functions 508
A.5 Numeric Functions 509
A.6 Sequence Operations 509
A.7 String Escapes 509
12 Contents
Bibliography 512
Index 515
Preface for the
Fourth Edition
We started Media Computation in the of Summer 2002, and taught it for the first time
in Spring 2003. It’s now over ten years later, which is a good time to summarize the
changes across the second, third, and fourth editions.
Media Computation has been used successfully in an undergraduate course at Geor-
gia Tech for the last dozen years. The course continues to have high retention rates (over
85% of students complete the class with a passing grade), and is majority female. Both
students and teachers report enjoying the course, which is an important recommendation
for it.
Researchers have found that Media Computation works in a variety of contexts.
The University of Illinois-Chicago had the first Media Computation paper outside of
Georgia, and they showed how switching to MediaComp improved their retention
rates in classes that were much more diverse than those at Georgia Tech [41]. The
University of California-San Diego adopted Media Computation as part of a big change
in their introductory course, where they also started using pair-programming and peer
instruction. Their paper at the 2013 SIGCSE Symposium showed how these changes
led to dramatic improvements in student retention, even measured a year later in the
Sophomore year. The paper also won the Best Paper award at the conference [27].
It’s been particularly delightful to see Media Computation adopted and adapted for
new settings, like Cynthia Bailey Lee’s creation of a MATLAB Media Computation
curriculum [12].
Mark wrote a paper in 2013, summarizing ten years of Media Computation research.
Media Computation does often improve retention. Our detailed interview studies with
female students supports the claim that they find the approach to be creative and engag-
ing, and that’s what keeps the students in the class. That paper won the Best Paper award
at the 2013 International Computing Education Research (ICER) Conference [33].
• Let the students be creative. The most successful Media Computation classes
use open-ended assignments that let the students choose what media they use.
For example, a collage assignment might specify the use of particular filters and
compositions, but allow for the student to choose exactly what pictures are used.
These assignments often lead to the students putting in a lot more time to get just
the look that they wanted, and that extra time can lead to improved learning.
14 Preface for the Fourth Edition
• Let the students share what they produce. Students can produce some beautiful
pictures, sounds, and movies using Media Computation. Those products are more
motivating for the students when they get to share them with others. Some schools
provide online spaces where students can post and share their products. Other
schools have even printed student work and held an art gallery.
• Code live in front of the class. The best part of the teacher actually typing in code
in front of the class is that nobody can code for long in front of an audience and
not make a mistake. When the teacher makes a mistake and fixes it, the students
see (a) that errors are expected and (b) there is a process for fixing them. Coding
live when you are producing images and sounds is fun, and can lead to unexpected
results and the opportunity to explore, “How did that happen?”
• Pair programming leads to better learning and retention. The research results on
pair programming are tremendous. Classes that use pair programming have better
retention results, and the students learn more.
• Peer instruction is great. Not only does peer instruction lead to better learning
and retention outcomes, but it also gives the teacher better feedback on what the
students are learning and what they are struggling with. We strongly encourage
the use of peer instruction in computing classes.
• Worked examples help with creativity learning. Most computer science classes
do not provide anywhere nearly enough worked-out examples for students to
learn from. Students like to learn from examples. One of the benefits of Media
Computation is that we provide a lot of examples (we’ve never tried to count the
number of for and if statements in the book!), and it’s easy to produce more
of them. In class, we do an activity where we hand out example programs, then
show a particular effect. We ask pairs or groups of students to figure out which
program generated that effect. The students talk about code, and study a bunch of
examples.
AP CS PRINCIPLES
The Advanced Placement exam in CS Principles1 has now been defined. We have
explicitly written the fourth edition with CS Principles in mind. For example, we show
how to measure the speed of a program empirically in order to contrast two algorithms
(Learning Objective 4.2.4), and we explore multiple ways of analyzing CSV data from
the Internet (Learning Objectives 3.1.1, 3.2.1, and 3.2.2).
Overall, we address the CS Principles learning objectives explicitly in this book as
shown below:
• In Big Idea I: Creativity:
• LO 1.1.1: . . . use computing tools and techniques to create artifacts.
• LO 1.2.1: . . . use computing tools and techniques for creative expression.
1
http://apcsprinciples.org
Preface for the Fourth Edition 15
ACKNOWLEDGMENTS
Our sincere thanks go out to all our reviewers and bug-finders:
• At the top of the list is Susan Schwarz of the US Military Academy at West Point.
Susan runs a large course with many instructors, and pays careful attention to
what’s going in all of the sections of the course. She turned that attention on
the third edition of this book. She caught many bugs, and gave us lots of useful
feedback. Thanks, Susan!
2
http://home.cc.gatech.edu/mediaComp and http://www.mediacomputation.org
Preface for the Fourth Edition 17
• Our other bug finders for the book were John Rutkiewicz, U. Massachusetts–
Dartmouth; Brian Dorn, U. Nebraska–Omaha; Dave Largent, Ball State Univer-
sity; Simon, University of Newcastle; Eva Heinrich, Massey University; Peter
J. DePasquale, The College of New Jersey, and Bill Leahy, Georgia Institute of
Technology.
• Matthew Frazier, North Carolina State University, worked with us in the summer
of 2014 to create a new version of JES – fixing many bugs, and improving JES
considerably.
• We are grateful for the feedback from our book reviewers for the 4th edition:
Andrew Cencini, Bennington College; Susan Fox, Macalester College; Kristin
Lamberty, University of Minnesota-Morris; Jean Smith, Technical College of the
Lowcountry; and William T. Verts, University of Massachusetts-Amherst.
• We are grateful for the input from our book reviewers for the 3rd edition, too:
Joseph Oldham, Centre College; Lukasz Ziarek, Purdue University;Joseph
O’Rourke, Smith College; Atul Prakash, University of Michigan; Noah D. Bar-
nette, Virginia Tech; Adelaida A. Medlock, Drexel University; Susan E. Fox,
Macalester College; Daniel G. Brown, University of Waterloo; Brian A. Malloy,
Clemson University; Renee Renner, California State University, Chico.
(as they tell us in surveys and interviews [6, 18]). The relevant context is part of the
explanation for the success we have had with retention in the Georgia Tech course for
which this book was written.
The late entrance of abstraction isn’t the only unusual ordering in this approach. We
start using arrays and matrices in Chapter 3, in our first significant programs. Typically,
introductory computing courses push arrays off until later, because they are obviously
more complicated than variables with simple values. A relevant and concrete context
is very powerful [19]. We find that students have no problem manipulating matrices of
pixels in a picture.
The rate of students withdrawing from introductory computing courses or receiving
a D or F grade (commonly called the WDF rate) is reported in the 30–50% range or
even higher. A recent international survey of failure rates in introductory computing
courses reported that the average failure rate among 54 U.S. institutions was 33% and
among 17 international institutions was 17% [24]. At Georgia Tech, from 2000 to 2002,
we had an average WDF rate of 28% in the introductory course required for all majors.
We used the first edition of this text in our course Introduction to Media Computation.
Our first pilot offering of the course had 121 students, no computing or engineering
majors, and two-thirds of the students were female. Our WDF rate was 11.5%.
Over the next two years (Spring 2003 to Fall 2005), the average WDF rate at Georgia
Tech (across multiple instructors, and literally thousands of students) was 15% [29].
Actually, the 28% prior WDF rate and 15% current WDF rate are incomparable, since
all majors took the first course and only liberal arts, architecture, and management
majors took the new course. Individual majors have much more dramatic changes.
Management majors, for example, had a 51.5% WDF rate from 1999 to 2003 with the
earlier course, and had a 11.2% failure rate in the first two years of the new course [29].
Since the first edition of this book was published, several other schools have adopted
and adapted this approach and evaluated their result. All of them have reported similar,
dramatic improvements in success rates [4, 42].
Further, it gives us the opportunity to point out that the same algorithm can have
similar effects in different media (e.g., scaling a picture up or down and shifting a
sound higher or lower in pitch are the same algorithm). But it could certainly be
skipped to save time.
• Chapter 12 (on movies) introduces no new programming or computing concepts.
While motivational, movie processing could be skipped to save time.
• We recommend getting to at least some of the chapters in the last unit, in order to
lead students into thinking about computing and programming in a more abstract
manner, but clearly not all of the chapters have to be covered.
TYPOGRAPHICAL NOTATIONS
Examples of Python code look like this: x = x + 1. Longer examples look like this:
def helloWorld():
print "Hello, world!"
When showing something that the user types in with Python’s response, it will have
a similar font and style, but the user’s typing will appear after a Python prompt (>>>):
>>> print 3 + 4
7
User interface components of JES (Jython Environment for Students) will be spec-
ified using a small caps font, like Save menu item and the Load button.
There are several special kinds of sidebars that you’ll find in the book.
INSTRUCTOR RESOURCES
The instructor resources are available on the Pearson Education’s Instructor Resource
Center at www.pearsonglobaleditions.com/guzdial:
• PowerPoint Presentation slides
ACKNOWLEDGMENTS
Our sincere thanks go out to the following:
• Jason Ergle, Claire Bailey, David Raines, and Joshua Sklare, who made the initial
version of JES with surprising quality in an amazingly short amount of time. Over
the years, Adam Wilson, Larry Olson, Yu Cheung (Toby) Ho, Eric Mickley, Keith
McDermott, Ellie Harmon, Timmy Douglas, Alex Rudnick, Brian O’Neill, and
William Fredrick (Buck) Scharfnorth III have made JES into the useful and still
understandable tool that it is today.
• Adam Wilson built the MediaTools that are so useful for exploring sounds and
images and processing video.
• Andrea Forte, Mark Richman, Matt Wallace, Alisa Bandlow, Derek Chambless,
Larry Olson, and David Rennie helped build course materials. Derek, Mark, and
Matt created many example programs.
• There were several people who really made the effort come together at Georgia
Tech. Bob McMath, Vice-Provost at Georgia Tech, and Jim Foley, Associate Dean
for Education in the College of Computing, invested in this effort early on. Kurt
Eiselt worked hard to make this effort real, convincing others to take it seriously.
Janet Kolodner and Aaron Bobick were excited and encouraging about the idea
of media computation for students new to computer science. Jeff Pierce reviewed
Preface to the First Edition 23
and advised us on the design of the media functions used in the book. Aaron
Lanterman gave me lots of advice on how to convey the digital material content
accurately. Joan Morton, Chrissy Hendricks, David White, and all the staff of the
GVU Center made sure that we had what we needed and that the details were
handled to make this effort come together. Amy Bruckman and Eugene Guzdial
bought Mark time to get the final version completed.
• We are grateful to Colin Potts and Monica Sweat who have taught this class at
Georgia Tech and given us many insights about the course.
• Charles Fowler was the first person outside of Georgia Tech willing to take the
gamble and trial the course in his own institution (Gainesville College), for which
we’re very grateful.
• The pilot course offered in Spring 2003 at Georgia Tech was very important in
helping us improve the course. Andrea Forte, Rachel Fithian, and Lauren Rich did
the assessment of the pilot offering of the course, which was incredibly valuable in
helping us understand what worked and what didn’t. The first teaching assistants
(Jim Gruen, Angela Liang, Larry Olson, Matt Wallace, Adam Wilson, and Jose
Zagal) did a lot to help create this approach. Blair MacIntyre, Colin Potts, and
Monica Sweat helped make the materials easier for others to adopt. Jochen Rick
made the CoWeb/Swiki a great place for CS1315 students to hang out.
• Many students pointed out errors and made suggestions to improve the book.
Thanks to Catherine Billiris, Jennifer Blake, Karin Bowman, Maryam Doroudi,
Suzannah Gill, Baillie Homire, Jonathan Laing, Mireille Murad, Michael Shaw,
Summar Shoaib, and especially Jonathan Longhitano, who has a real flair for
copyediting.
• Thanks to former Media Computation students Constantino Kombosch, Joseph
Clark, and Shannon Joiner for permission to use their snapshots from class in
examples.
• The research work that led to this text was supported by grants from the National
Science Foundation—from the Division of Undergraduate Education, CCLI pro-
gram, and from the CISE Educational Innovations program. Thank you for the
support.
• Thanks to computing students Anthony Thomas, Celines Rivera, and Carolina
Gomez for allowing us to use their pictures.
• Finally but most important, thanks to our children Matthew, Katherine, and Jennifer
Guzdial, who allowed themselves to be photographed and recorded for Mommy
and Daddy’s media project and who were supportive and excited about the class.
3
http://www.ecepalliance.org
PART
1 INTRODUCTION
1 to Computer Science
and Media Computation
1.1 WHAT IS COMPUTER SCIENCE ABOUT?
To use our metaphor a bit more—think of an algorithm as the step-by-step way that
your grandmother made her secret recipe. She always did it the same way, and had a
28 Chapter 1 Introduction to Computer Science and Media Computation
reliably great result. Writing it down so that you can read it and do it later is like turning
her algorithm into a program for you. You execute the recipe by doing it—following
the recipe step-by-step in order to create something the way that your grandmother did.
If you give the recipe to someone else who can read the language of the recipe (maybe
English or French), then you have communicated that process to that other person, and
the other person can similarly execute the recipe to make something the way that your
grandmother did.
If you’re a biologist who wants to describe how migration works or how DNA
replicates, then being able to write a recipe that specifies exactly what happens, in
terms that can be completely defined and understood, is very useful. The same is true
if you’re a chemist who wants to explain how equilibrium is reached in a reaction.
A factory manager can define a machine-and-belt layout and even test how it works—
before physically moving heavy things into position—using computer programs. Being
able to exactly define tasks and/or simulate events is a major reason why computers
have radically changed so much of how science is done and understood.
In fact, if you can’t write a recipe for some process, maybe you don’t really under-
stand the process, or maybe the process can’t actually work the way that you are thinking
about it. Sometimes, trying to write the recipe is a test in itself. Now, sometimes you
can’t write the recipe because the process is one of the few that cannot be executed by
a computer. We will talk more about those in Chapter 14.
It may sound funny to call programs a recipe, but the analogy goes a long way. Much
of what computer scientists study can be defined in terms of recipes.
• Some computer scientists study how recipes are written: Are there better or worse
ways of doing something? If you’ve ever had to separate egg whites from yolks, you
realize that knowing the right way to do it makes a world of difference. Computer
science theoreticians think about the fastest and shortest recipes, and the ones that
take up the least amount of space (you can think about it as counter space—the
analogy works), or even use the least amount of energy (which is important when
running on low-power devices like cell phones). How a recipe works, completely
apart from how it’s written (e.g., in a program), is called the study of algorithms.
Software engineers think about how large groups can put together recipes that still
work. (Some programs, like the ones that keep track of credit card transactions,
have literally millions of steps!) The term software means a collection of computer
programs (recipes) that accomplish a task.
• Other computer scientists study the units used in recipes. Does it matter whether
a recipe uses metric or English measurements? The recipe may work in either
case, but if you don’t know what a pound or a cup is, the recipe is a lot less
understandable to you. There are also units that make sense for some tasks and
not others, but if you can fit the units to the tasks, you can explain yourself more
easily and get things done faster—and avoid errors. Ever wonder why ships at
sea measure their speed in knots? Why not use something like meters per second?
Sometimes, in certain special situations—on a ship at sea, for instance—the more
common terms aren’t appropriate or don’t work as well. Or we may invent new
kinds of units, like a unit that represents a whole other program or a computer, or
Section 1.1 What Is Computer Science About? 29
a network like your friends and your friends’ friends in Facebook. The study of
computer science units is referred to as data structures. Computer scientists who
study ways of keeping track of lots of data (in lots of different kinds of units) and
figuring out how to access the data quickly are studying databases.
• Can recipes be written for anything? Are there some recipes that can’t be written?
Computer scientists know that there are recipes that can’t be written. For example,
you can’t write a recipe that can absolutely tell whether some other recipe will
actually work. How about intelligence? Can we write a recipe such that a computer
following it would actually be thinking (and how would you tell if you got it right)?
Computer scientists in theory, intelligent systems, artificial intelligence, and
systems worry about things like this.
• There are even computer scientists who focus on whether people like what the
recipes produce, almost like restaurant critics for a newspaper. Some of these
are human–computer interface specialists who worry about whether people can
understand and make use of the recipes (“recipes” that produce an interface that
people use, like windows, buttons, scrollbars, and other elements of what we think
about as a running program).
• Just as some chefs specialize in certain kinds of recipes, like crepes or barbecue,
computer scientists also specialize in certain kinds of recipes. Computer scientists
who work in graphics are mostly concerned with recipes that produce pictures,
animations, and even movies. Computer scientists who work in computer music
are mostly concerned with recipes that produce sounds (often melodic ones, but
not always).
• Still other computer scientists study the emergent properties of recipes. Think
about the World Wide Web. It’s really a collection of millions of recipes (programs)
talking to one another. Why would one section of the Web get slower at some
point? It’s a phenomenon that emerges from these millions of programs, certainly
not something that was planned. That’s something that networking computer
scientists study. What’s really amazing is that these emergent properties (that
things just start to happen when you have many, many recipes interacting at once)
can also be used to explain noncomputational things. For example, how ants forage
for food or how termites make mounds can also be described as something that
just happens when you have lots of little programs doing something simple and
interacting. There are computer scientists today who study how the Web allows for
new kinds of interactions, particularly in large groups (like Facebook or Twitter).
Computer scientists who study social computing are interested in how these new
kinds of interactions work and the characteristics of the software that are most
successful for promoting useful social interactions.
The recipe metaphor also works on another level. Everyone knows that some things
in a recipe can be changed without changing the result dramatically. You can always
increase all the units by a multiplier (say, double) to make more. You can always add
more garlic or oregano to the spaghetti sauce. But there are some things that you cannot
change in a recipe. If the recipe calls for baking powder, you may not substitute baking
30 Chapter 1 Introduction to Computer Science and Media Computation
CHICKEN CACCIATORE
3 whole, boned chicken breasts 1 (28 oz) can chopped tomatoes
1 medium onion, chopped 1 (15 oz) can tomato sauce
1 tbsp chopped garlic 1 (6.5 oz) can mushrooms
2 tbsp and later 1 4 c olive oil 1 (6 oz) can tomato paste
1 1 2 c flour 12
of (26 oz) jar of spaghetti
14
c Lawry’s seasoning salt sauce
1 bell pepper, chopped (optional) 3 tbsp Italian seasoning
any color 1 tsp garlic powder (optional)
Cut up the chicken into pieces about 1 inch square. Saute the
onion and garlic until the onion is translucent. Mix the flour and
Lawry’s salt. You want about 1:4–1:5 ratio of seasoning salt to flour
and enough of the whole mixture to coat the chicken. Put the cut up
chicken and seasoned flour in a bag, and shake to coat. Add the coated
chicken to the onion and garlic. Stir frequently until browned.
You’ll need to add oil to keep from sticking and burning; I sometimes
add up to 1 4 cup of olive oil. Add the tomatoes, sauce, mushrooms,
and paste (and the optional peppers, too). Stir well. Add the Italian
seasoning. I like garlic, so I usually add the garlic powder, too. Stir
well. Because of all the flour, the sauce can get too thick. I usually
cut it with the spaghetti sauce, up to 1 2 jar. Simmer 20–30 minutes.
FIGURE 1.1
A cooking recipe—you can always double the ingredients, but throwing in an extra cup
of flour won’t cut it, and don’t try to brown the chicken after adding the tomato sauce!
soda. The order matters. If you’re supposed to brown the chicken and then add tomato
sauce, you won’t get the same result if you add tomato sauce and then (somehow) try
to brown the chicken (Figure 1.1).
The same holds for software recipes. There are usually things you can easily change:
the actual names of things (though you should change names consistently), some of
the constants (numbers that appear as plain old numbers, not as variables), and maybe
even some of the data ranges (sections of the data) being manipulated. But the order of
the commands to the computer, however, almost always has to stay exactly as stated.
As we go on, you’ll learn what can be safely changed, and what can’t.
Python/Jython
def hello():
print "Hello World"
Java
class HelloWorld {
static public void main( String args[] ) {
System.out.println( "Hello World!" );
}
}
C++
#include <iostream.h>
main() {
cout << "Hello World!" << endl;
return 0;
}
Scheme
(define helloworld
(lambda ()
(display "Hello World")
(newline)))
FIGURE 1.2
Comparing programming languages: a common simple programming task is to print the
words ‘‘Hello World!’’ to the screen.
easier to find a hundred programmers who know a popular language than a less popular
one—but that doesn’t mean that the popular language is the best one for your task!
The programming language that we’re using in this book is Python (visit http://
www.python.org for more information on it). Python is a popular programming lan-
guage, used very often for Web and media programming. The Web search engine
Google uses Python. The media company Industrial Light & Magic also uses Python.
A list of companies using Python is available at http://css.dzone.com/articles/
best-python-companies-work. Python is easy to learn, easy to read, very flexible,
but not as efficient as other programming languages. The same algorithm coded in C
and in Python will probably be faster in C. Python is a good language for writing pro-
grams that work within an application, like the image manipulation language GIMP
(http://www.gimp.org) or the 3D content creation tool Blender (http://www.
blender.org).
The version of Python used in this book is called Jython (http://www.jython.
org).1 Jython is a form of Python that is particularly effective for programming in
multimedia that will work across multiple computer platforms. You can download a
version of Jython for your computer from the Jython Web site that will work for all kinds
of purposes. Most programs written for Jython will work without change in Python.
In this book, we will describe how to program in Jython using a programming
environment called JES (Jython Environment for Students) that has been developed to
make it easier to program in Jython. JES has some features for working with media, like
viewers for sounds and images. JES also has embedded in it some special functions for
manipulating digital media that are made available to you without you doing anything
special. Anything you can do in JES, you can also do in normal Jython, though you
will have to explicitly include the special libraries.
Media Computation special libraries work with other environments and other forms
of Python, too.
• Pythy developed by Stephen Edwards and his colleagues at Virginia Tech is a
browser-based programming environment.2 All programming occurs through a
Web browser with Pythy, and programs and media are stored in the cloud. Programs
that work in JES will work in Pythy.
• A team led by Paul Gries at the University of Toronto has implemented portions
of the special media libraries in JES to work in other forms of Python.3
• The books at http://www.interactivepython.org/ by Brad Miller at Luther
College support manipulation of images in Python in all of their ebooks.
Let’s revisit here two of the most important terms that we’ll be using in this book:
• A program is a description in a programming language of a process that achieves
some result that is useful to someone. A program can be small (like one that imple-
ments a calculator) or huge (like one your bank uses to track all of its accounts).
1
Python is often implemented in the programming language C. Jython is Python implemented in
Java—this means that Jython is actually a program written in Java.
2
See https://github.com/web-cat/pythy for information on installing Pythy.
3
See https://code.google.com/p/pygraphics/ for information on the Pygraphics library.
Section 1.3 What Computers Understand 33
wires
0 27 = 128* 0 = 0 +
1 26 = 64* 1 = 64 +
0 25 = 32* 0 = 0 +
0 24 = 16* 0 = 0 +
1 23 = 8* 1 = 8 +
0 22 = 4* 0 = 0 +
1
1 2 = 2* 1 = 2 +
0 20 = 1* 0 = 0
interpreted as 74
FIGURE 1.3
Eight wires with a pattern of voltages is a byte, which is interpreted as a pattern of eight
0’s and 1’s, which in turn is interpreted as a decimal number.
launcher to . . .”). Modern computers can do billions of calculations per second. But
what makes the computer useful for general recipes is the concept of encodings.
If one of these bytes is interpreted as the number 65, it could simply be the number
65. Or it could be the letter A using a standard encoding of numbers to letters called the
American Standard Code for Information Interchange (ASCII). If the 65 appears in a
collection of other numbers that we’re interpreting as text, and it’s in a file that ends in
“.html” it might be part of something that looks like this <a href=. . ., which a Web
browser will interpret as the definition of a link. Down at the level of the computer, that
A is just a pattern of voltages. Many layers of recipes up, at the level of a Web browser,
it defines something that you can click on to get more information.
If the computer understands only numbers (and that’s a stretch already), how does
it manipulate these encodings? Sure, it knows how to compare numbers, but how does
that extend to being able to alphabetize a class list? Typically, each layer of encoding
is implemented as a piece or layer in software. There’s software that understands how
to manipulate characters. The character software knows how to do things like compare
names because it has encoded that a comes before b and so on, and that the numeric
comparison of the order of numbers in the encoding of the letters leads to alphabetical
comparisons. The character software is used by other software that manipulates text in
files. That’s the layer that something like Microsoft Word or Notepad or TextEdit would
use. Still another piece of software knows how to interpret HTML (the language of the
Section 1.4 Media Computation: Why Digitize Media? 35
Web), and another layer of the same software knows how to take HTML and display
the right text, fonts, styles, and colors.
We can similarly create layers of encodings in the computer for our specific tasks.
We can teach a computer that cells contain mitochondria and DNA, and that DNA
has four kinds of nucleotides, and that factories have these kinds of presses and these
kinds of stamps. Creating layers of encoding and interpretation so that the computer is
working with the right units (recall back to our recipe analogy) for a given problem, is
the task of data representation or defining the right data structures.
If this sounds like a lot of software, it is. When software is layered this way, it
slows the computer down a bit. But the powerful thing about computers is that they’re
amazingly fast—and getting faster all the time!
Computers today can execute literally billions of recipe steps per second. They can
hold in memory literally encyclopedias of data! They never get tired or bored. Search
a million customers for an individual cardholder? No problem! Find the right set of
numbers to get the best value out of an equation? Piece of cake!
Process millions of picture elements or sound fragments or movie frames? That’s
media computation. In this book, you will write recipes that manipulate images,
sounds, text, and even other recipes. This is possible because everything in the computer
is represented digitally, even recipes. We would not be able to do media computation if
the media were not represented digitally. By the end of the book, you will have written
recipes to implement digital video special effects that create Web pages in the same
way that Amazon and eBay do, and that filter images like Photoshop.
Manipulating these dots (each referred to as a pixel or picture element) can take a
lot of processing. There are thousands or even millions of them in a picture that you
might want to work with on your computer or on the Web. But the computer doesn’t
get bored, and it’s very fast.
The encoding that we will be using for sound involves 44,100 two-byte sets (called
a sample) for each second of time. A three-minute song requires 158,760,000 bytes
(twice that for stereo). Doing any processing on this takes a lot of operations. But at a
billion operations per second, you can do lots of operations to every one of those bytes
in just a few moments.
Creating encodings of this kind for media requires a change to the media. Look at the
real world: it isn’t made up of lots of little dots that you can see. Listen to a sound: Do
you hear thousands of little bits of sound per second? The fact that you can’t hear little
bits of sound per second is what makes it possible to create these encodings. Our eyes
and ears are limited: we can only perceive so much, and only things that are just so
small. If you break up an image into small enough dots, your eyes can’t tell that it’s not
a continuous flow of color. If you break up a sound into small enough pieces, your ears
can’t tell that the sound isn’t a continuous flow of auditory energy.
The process of encoding media into little bits is called digitization, sometimes
referred to as “going digital.” Digital means (according to the Longman Dictionaries)
Using a system in which information is recorded or sent out electronically in the form
of numbers, usually ones and zeros.5 Making things digital is about turning things from
continuous and uncountable to something that we can count, as if with our fingers.
Digital media, done well, feel the same to our limited human sensory apparatus
as the original. Phonograph recordings (ever seen one?) capture sound continuously
as an analog signal. Photographs (on film) capture light as a continuous flow. Some
people say that they can hear a difference between phonograph recordings and CD
recordings, but to our ears and most measurements, a CD (which is digitized sound)
sounds just the same, or maybe clearer. Digital cameras at high enough resolutions
produce photograph-quality pictures.
Why would you want to digitize media? Because then the media will be easier to
manipulate, to replicate exactly, to compress, to search, to index and classify (e.g., to
group similar images or sounds together), to compare, and to transmit. For example,
it’s hard to manipulate images that are in photographs, but it’s very easy when the same
images are digitized. This book is about using the increasingly digital world of media
and manipulating it—and learning computation in the process.
Moore’s Law has made media computation feasible as an introductory topic. Media
computation relies on the computer doing lots and lots of operations on lots and lots of
bytes. Modern computers can do this easily. Even with slow (but easy to understand)
languages, even with inefficient (but easy to read and write) recipes, we can learn about
computation by manipulating media.
5
Definition of “digital” from Longman Dictionary of Contemporary English. Copyright © 2009 by
Pearson Education. Reprinted with permission.
Section 1.5 Computer Science for Everyone 37
figure in the field of computer science. The highest award in computer science is the
ACM Turing Award. Perlis was the first recipient of that award. He’s an important figure
in software engineering and he started several of the first computer science departments
in the United States.
Perlis’s argument can be made in comparison with calculus. Calculus is generally
considered part of a liberal education: not everyone takes calculus, but if you want to
be well educated, you will typically take at least a term of calculus. Calculus is the
study of rates, which is important in many fields. Computer science, as stated earlier
in this chapter, is the study of process. Process is important to nearly every field, from
business to science to medicine to law. Knowing process formally is important for
everyone. Using a computer to automate processes has changed every profession.
Jeannette Wing has argued that everyone should learn computational thinking [23].
She views the types of skills taught in computing as critical skills for all students. This
is what Alan Perlis predicted: that automating computation would change the way we
learn about our world.
PROBLEMS
1.1 A study performed by a team of researchers at Carnegie Mellon University
in 2005 predicted that most programmers would not be professional software
developers. Use a web browser and a search engine like Google to find out how
the population of programmers is being studied these days. List some possible
areas in which programming could be required in everyday life.
6
See http://dl.acm.org/citation.cfm?id=1083231.1083232&coll=DL&dl=ACM&CFID=347064215&
CFTOKEN=87606004.
Problems 39
1.2 The 2013 Nobel Prize in Chemistry was in some sense a Nobel Prize given for
work in computer science. What was the role of computers in that Nobel Prize?
1.3 Text characters are encoded in different ways. The bottom level is always binary
in bytes, but a different binary pattern can be used to represent different char-
acters. Two of these encodings are ASCII and Unicode. See if you can do Web
searches on ASCII and Unicode. What’s the difference between ASCII and
Unicode? Why would we need Unicode if we already had ASCII?
1.4 Consider the representation for pictures described in Section 1.4, where each
dot (pixel) in the picture is represented by three bytes, for the red, green, and blue
components of the color at that dot. How many bytes does it take to represent a
640 by 480 picture, a common picture size on the Web? How many bytes does
it take to represent a 1024 by 768 picture, a common screen size? (What do you
think is meant now by a “three megapixel” camera?)
1.5 One bit can represent 0 or 1. With two bits you have four possible combinations
00, 01, 10, and 11. How many different combinations can you make with four
bits or eight bits (one byte)? Each combination can be used to represent a binary
number. How many numbers can you represent with 2 bytes (16 bits)? How
many numbers can you represent with four bytes?
1.6 Microsoft Word used to use an encoding of a word-processing document called
“DOC.” Most recent versions of Microsoft Word use a different encoding called
“DOCX.” What’s the difference between them?
1.7 One of the powerful ideas in computer science is that encodings can be layered.
Most of the encodings we’ve talked about so far (e.g., pixels in a picture, char-
acters, floating point numbers) are based on binary. XML is a way of encoding
information in text, which is in turn encoded in binary. What are the advantages
and disadvantages of using XML rather than binary encodings?
1.8 How can you encode a floating-point number in terms of bytes? Do a search
on the Web for “floating point.” You will find that there are different encodings
of floating point numbers. Take a common one like the IEEE Floating Point
Standard as an example. Assuming single precision, what is the largest and
smallest numbers that you can represent in that encoding?
1.9 As we said in the chapter, computer science is about people. Start your explo-
ration of computer science by exploring the people who are computer scientists
and influence computer science. As you do, find Web sites that you believe are
credible for your information, and include the URL in your answers—with your
reasons for believing that source is credible. What general rules do you use to
determine what is a credible Web site?
1.10 What is digitization? Define digital as per Longman Dictionaries. Justify the
need to digitize media. How has Moore’s Law made media computation feasi-
ble? Bring out the difference between phonograph and photograph.
1.11 Search for Gordon Moore on the web. What claim was he making with respect
to computing power? What was Moore’s observation?
Exploring the Variety of Random
Documents with Different Content
The Project Gutenberg eBook of Proper pride :
A novel. Volume 2 (of 3)
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
Author: B. M. Croker
Language: English
IN THREE VOLUMES.
VOL. II.
LONDON:
TINSLEY BROTHERS, 8, CATHERINE ST., STRAND.
1882.
[All rights reserved.]
CHARLES DICKENS AND EVANS,
CRYSTAL PALACE PRESS.
CONTENTS.
PAGE
CHAPTER I.
“THE NEILGHERRIES” 1
CHAPTER II.
AFGHANISTAN 20
CHAPTER III.
“MY CAPTAIN DOES NOT ANSWER; HIS LIPS ARE PALE 48
AND STILL”
CHAPTER IV.
MONKSWOOD 80
CHAPTER V.
WAITING FOR AN ANSWER 87
CHAPTER VI.
THE RETURN OF THE NATIVE 105
CHAPTER VII.
“MARY, IT IS MY HUSBAND!” 134
CHAPTER VIII.
ALICE’S OVERTURES ARE DECLINED 163
CHAPTER IX.
“SIR REGINALD’S EYES ARE OPENED” 200
CHAPTER X.
GEOFFREY MANŒUVRES 238
CHAPTER XI.
“MEET ME BY MOONLIGHT ALONE” 245
PROPER PRIDE.
CHAPTER I.
“THE NEILGHERRIES.”
Our hero went to the Neilgherry Hills for the remainder of his two
months’ leave. It is quite beyond my pen to describe that lovely
region, but in common with almost all who have ever been there I
have an admiration amounting to a passion for the Blue Hills. I
declare them to be the most salubrious, delightful, beautiful range in
the whole world. If I were to attempt a detailed description of these
most favoured hills, I should fall so far short of their perfections that
I would only incur the wrath and contempt of their many devoted
admirers, so I shall content myself by merely giving a description of
Sir Reginald’s journey up the Ghaut.
He arrived at the foot of the hills early one morning, having spent
a night of heat, mosquitoes, and consequent madness at
Mettapollium. He rode up by the old road, which is nine miles to
Coonor, in preference to driving up the new ghaut, a detour of
sixteen miles. His thoughts were exceedingly pleasant, and he
whistled uninterruptedly for the first two miles; but after a while the
beautiful scenery he was passing through engaged his attention
entirely, and more than once he stopped his horse and looked about
in amazed admiration. “Oh, if Alice could only see it! If she were
here, what ecstasies she would be in!” was his frequent thought. As
he journeyed steadily up, the close tropical vegetation was gradually
left behind, the trees assumed a more European aspect, the air lost
its thick steamy feel, and became every instant more rarefied and
pure. The path appeared to wind in and out through mountain-sides
clothed with trees and foliage of every description; a foaming river
was tearing headlong down a wide rocky channel and taking frantic
leaps over all impediments. The scenery was splendid. In spite of
hunger and fatigue, Sir Reginald felt as if he could gaze and gaze for
hours, and yet that his eyes would scarcely be satisfied. Wild roses
and wild geraniums abounded on all sides; enormous bunches of
heliotrope were growing between the stones; lovely flowering
creepers connected the trees, and as to the ferns——!
The graves of several engineers who had died when this old ghaut
was being made were passed—poor lonely graves! and yet could
those laid in them, so many thousands of miles away from their
native land, desire to be buried in a more beautiful spot?
At one side towered the “Droog,” crowned by Tippoo’s old fortress.
The “Droog” itself, a bold beetling hill facing south, and most
precipitous, seemed to stand as sentry to this garden of India. From
the top of it you could look sheer down into the plains. It was on the
opposite side of the river to the old ghaut, and a long day’s outing
from Coonor. On its summit were the gray broken walls of the fort,
very old and much dismantled, and from which they say that Tippoo,
when in an angry mood, used to toss his unhappy prisoners down to
the plains below. There it was that the Mahrattas made their last
stand against the British; and as they brought an enormous amount
of treasure up from their strongholds in the plains, which treasure
has never been recovered, the “Droog” is considered a highly
interesting place for more reasons than one. It is said that all the
gold and jewels were thrown down a well somewhere just beyond
the fort walls. One very old man was supposed to know of its
whereabouts, but he would never divulge the secret, as he said the
spot was guarded by the ghosts—devils, he called them—of many
Mahratta warriors, and he was afraid to incur their displeasure.
Sir Reginald arrived in due time at Coonor, and put up at an hotel,
before the windows of which there was a hedge of heliotrope cut like
box at home, and so high and so dense, that you could ride at one
side of it, and someone else at the other, without either being aware
of their mutual proximity. It was one mass of flowers, and smelt like
ten thousand cherry-pies, and was one of the sights of the
Neilgherries. Sir Reginald relaxed somewhat as regarded society,
made friends with the other inmates of the hotel, and joined in
picnics to all the most celebrated views. He was well known on the
Toda Mund as one of the best and most inveterate of tennis-players,
and carried off the first prize in a tournament which took place
during his stay.
Touching the Toda Mund, there were no Todas there then; they
had long removed themselves, with their black ringlets and sheet
clothing, to a more remote region; but years previously the present
lawn-tennis-court ground had been the home of generations of
these extraordinary people.
Sir Reginald returned to his regiment much the better for his trip,
and received the congratulations of his friends on his improved
appearance, and also on the discovery he had made at Cheetapore;
as what had been the talk of all that station naturally came to the
ears of his brother-officers, and they boldly conversed of himself and
his wife as if they had known all along that he had been a married
man. The individual who had been so contemptuously scouted when
he had declared that Fairfax was a Benedict now found himself
looked upon as a man of unusual penetration—in short, a second
Daniel; and for a time his opinions were quoted at at least ten per
cent. above their usual regimental value.
As for Fairfax himself, a change had certainly come over the spirit
of his dream. He was an altered man; no more headlong solitary
rides, no more moping in his own quarters. Attired in faultless garb
of undoubted “Europe” origin, he was led, like a lamb, to make a
series of calls among the chief notabilities of the place. “Better late
than never!” they mentally exclaimed when his card was handed in,
and being assured that “Missus could see,” the hero of the hour
followed. His history was now as well known as if it had been
published in The Pioneer, and the ladies of Camelabad overwhelmed
him with sympathy and condolence, which he accepted with the best
grace he could muster; but he shrank from speaking of his wife,
save in the most distant and general terms; and it was easy to see
that the mock certificate was a very sore, distasteful subject.
As each succeeding mail came in he said to himself, “Surely this
will bring a letter from Alice?” How he looked forward to mail-days
no one knew but himself; how buoyant were his spirits every
Saturday morning, how depressed that same evening, when, tossing
over the newly-arrived letters on the anteroom table, he would find
one from Mark Mayhew, one from his agent, and perhaps one from
his tailor, but not a line from his wife. He heard from the Mayhews
that Alice had received and acknowledged the confessions; and
Mark, Helen, and Geoffrey each sent him a long letter full of
indignation and congratulation. The burden of each of these epistles
was the same, although couched in very different style and
language: it said, “Come home.” “Whenever his wife endorsed their
wishes, he would leave Bombay by the following mail.” This was
what he said to himself over and over again. Two months elapsed
and no letter came—not a line, not even a message. After making
allowance for every conceivable delay, he gradually and reluctantly
relinquished all hopes of the ardently-desired missive, and came to
the conclusion that nothing now remained for him to think but that
she wished their separation to be life-long.
One evening he mounted his horse and galloped out alone to one
of his former favourite haunts, an old half-ruined temple, about six
miles from the cantonment. Here he dismounted and tied his Arab to
a tree, saying to himself as he ascended the steps: “There is no fear
of any interruption here, and I will make up my mind to some
definite plan before I return to Camelabad this evening.” As he
paced up and down the empty echoing ruin, he tried to judge
between Alice and himself as calmly and dispassionately as if he
were a third person. His own motives and actions were easily
explained, but Alice’s were not so readily understood. What could be
the meaning of her extraordinary conduct? His name had been
cleared, and she, who should never have doubted him, and who, at
any rate now, ought to be the first to come forward, had been
dumb. There was but one reasonable solution. “She did not know
her own mind when she was married; she never cared two straws
about me, and she seizes the first pretext to free herself from a
distasteful union. So be it; she shall be free,” he muttered. “I will
hold myself utterly aloof from her for the future. I shall go home and
live at Looton, and surround myself with friends—shoot, hunt, and
lead as gay a bachelor life as if I had no wife in existence. Why
should I expatriate myself for her sake?” he asked himself aloud.
But on second thoughts this scheme did not prove so alluring. At
Looton, every room, every walk, every face would only remind him
of Alice.
“I could not stand it just yet,” he muttered; “it is all too fresh, too
recent; one does not get over a thing like that so soon. In a year or
two, when I am thoroughly hardened and indifferent, I will go;
meanwhile I shall remain in the service.”
The duties of his profession had their charms for him; and the
society of his brother-officers was, he reflected, more welcome and
more necessary to him now than ever. Weak he had always been
where Alice was concerned, but for once he would be firm and be a
man, and no longer an infatuated fool, following the ignis fatuus of a
woman’s caprice.
As he stood on the steps of the temple, watching the crimson sun
that was slowly sinking beyond the horizon and tinting the arid
plains, the distant hills, the old temple, and Reginald himself, with
the gorgeous hues of its departing splendour, “That sun,” he
exclaimed, as he watched the last little red streak utterly disappear,
“has set on my folly and weakness; to-morrow will find me, in one
respect at least, a different man. For the future I will endeavour to
forget that I ever had a wife. I know it will be no easy matter to
banish her from my thoughts, but I shall do my best. As a wife she
is dead to me in all but name; her indifference shall be only rivalled
by mine.” Query: Was he not still thinking of her as he sat for fully
an hour, with his head resting in his hands? He was endeavouring to
dig the grave of his love, and to bury decently all the unfulfilled
hopes he had cherished for so long. The moon arose, owls and bats
made their appearance and flitted to and fro, apparently
unconscious of the silent figure on the temple steps. At length the
pawing and neighing of his horse aroused him. He started up hastily,
pulled himself morally together, and hurried down to the impatient
steed, whom he unfastened and mounted, and in another moment
was galloping away over the moonlit midan, leaving the old temple
to the undisturbed possession of a veteran hyena and a family of
jackals.
The Seventeenth Hussars had expected, as a sequel to his
discovery at Cheetapore, that Sir Reginald would have returned to
his ancestral halls as fast as steam could take him.
But month after month went by, and he still remained a fixture at
Camelabad. He carried out his mental resolution to the letter, and
left himself no leisure to think of Alice or anyone else. He returned
with the greatest energy to all his bachelor amusements, kept a
string of racers, hunted the regimental pack, and made constant
shooting expeditions. He played whist till the small hours, and
entered into everything with the greatest zeal; took a prominent if
somewhat mechanical part in all the entertainments in the station,
and was voted “charming” by the ladies, both young and old.
Notwithstanding his bachelor pursuits, he developed a curious and
Benedict-like interest in babies—a species of humanity that he had
hitherto held in abhorrence. He cast more than one inquisitive
glance on the smaller fry in arms as he went round the married
quarters. And Mrs. Gifford, the wife of the only married captain in
the Seventeenth, was amazed when her ayah informed her that “Sir
Fairfax” had more than once taken notice of her baby, “asking age,
asking boy or girl, how soon walking?” It was most flattering, if a
little mysterious, and he became a greater favourite than ever with
Mrs. Gifford. She was not aware that her boy shone with a borrowed
lustre in Sir Reginald’s eyes for being almost the same age as his
son, and that the toys and presents which were showered on him as
he grew older were not bestowed altogether for his own sake.
A year after his visit to Cheetapore, Sir Reginald received a letter
in Alice’s well-known writing. “It has come at last,” he said to
himself, as with trembling hands he tore it open in his own
bungalow. He drew out the photo of a sturdy dark-eyed cherub,
enclosed in a sheet of blank letter-paper. At first he could hardly
credit his senses; his indignation and his bitter disappointment were
too great for words. His first impulse was to tear the photo into four
pieces, but, mastering this rather insane idea, he took it up and
looked at it closely instead. He was glad he had not obeyed his first
rash notion. The boy was certainly a splendid little fellow. Written in
the corner of the carte was, “Maurice E. Fairfax, aged thirteen
months.” He was something more tangible now, his father thought,
as he minutely studied every feature. He felt a thrill of novel and
very pleasant pride as he looked at the bright eager little face, and
said to himself: “This is my son. He has the Fairfax eyes and brows,
I believe,” he continued, as he still studied the photo critically, “but
no one will deny that he has his mother’s mouth.”
With a sigh he pieced together the torn envelope, and looked in
vain for a word; the blank sheet of paper he scrupulously turned
over; it was really blank indeed. He gazed at it for some time, as if
there were actually something written on it; then, suddenly
gathering himself together, he carefully folded it up and put it along
with the photograph into the envelope, and locked them away in his
desk.
Sir Reginald had been nearly two years at Camelabad when the
outbreak which had been simmering for some time in Afghanistan
came to boiling-point, and the gauntlet of defiance was thrown
down by the Ameer.
Captains Campbell and Vaughan were reposing in long chairs in
front of their mess, much exhausted with lawn-tennis, refreshing
themselves with copious iced pegs, and enjoying a delightful
experience of the dolce far niente as embodied in Bombay—chairs
and brandies-and-sodas.
Suddenly a solitary horseman was seen madly careering across
the midan, in the direction of their lines.
“I say, just look at this fellow; his horse has bolted!” said Captain
Campbell.
“Not a bit of it,” replied his companion serenely; “don’t you see
that it’s Fairfax on his chestnut, riding ventre à terre, as usual?”
“Hallo, Fairfax, what’s up?” they shouted as he approached. “Are
the barracks ablaze, and are you going for the fire-engine?”
“Better than that,” he cried, clattering into the compound. “I have
just come up from the general’s with glorious news—we start for the
front this day week.”
CHAPTER II.
AFGHANISTAN.
Although Hafiz Khan and his hordes were defeated and dispersed,
they speedily rallied sufficiently to be a ceaseless thorn in the flesh
to the brigade now permanently encamped within a few miles of the
late scene of action. Hafiz was a striking illustration of the saying,
“He who fights and runs away will live to fight another day.” He was
a fakir—exceptionally holy, having made the blessed pilgrimage no
less than thrice—notorious alike for his zealous piety as for his
abhorrence of the accursed Kaffir. Scandal whispered that he had
not always been such a devoted servant of the Prophet; that for
years he lived in ill-odour among his neighbours, owing to his
constant appropriation of their flocks and herds. Whatever may have
been the truth, he was now an ardent patriot, and preyed on the
Feringhees instead of on his friends. He was a most daring and
successful raider, and covered himself with glory, notably on one
occasion when he carried off seven hundred head of cattle from
Jellalabad.
He cut off more convoys and slaughtered more grass-cutters and
camel-drivers than any other leader between Cabul and the Khyber;
and his depredations were so secretly and skilfully carried out, that
his very name alone inspired the stoutest-hearted camp-follower
with terror.
Invariably mounted on his superb black Turcoman, he gave chase
or effected his retreat with a speed that set everything at defiance.
His horse was known by the name of “Shaitan,” and was supposed
to be in direct communication with the Evil One, being imported
expressly from the lower regions for the purpose of hunting down
the infidels. The rider of this desirable mount was an elderly thick-
set man, wearing a gigantic green turban, so large as almost to
conceal his features. Still his hooked nose, fierce hawk eye, and
bushy beard were visible; and the treacherous, cruel, malignant
expression of his face was such as a devil might have envied. Armed
with a pair of horse-pistols and a formidable yataghan, he headed a
band of followers varying from fifty to two thousand, and infested an
area of many miles in extent. His patriotic zeal had no bounds; he
was known to have recently butchered an entire village, merely
because the headman had supplied (under strong pressure) cattle
and grain to the English commissariat; in short, his name far and
near was a byword for ferocity and fanaticism.
One evening, Sir Reginald and his two friends, Captain Vaughan
and Mr. Harvey, went for a short ride in the neighbourhood of their
camp, the former mounted on his first charger, an unusually large,
powerful Arab, the two latter on stout Yarkundi ponies. All were clad
in Karki suits, and carried (a most necessary precaution) revolvers in
their belts. The country around was reported clear. Hafiz and his
faction were said to be miles away. Certainly nothing had been heard
of them for two whole days. It was a lovely evening, and tempted by
the odd wild scenery they extended their ride farther than they had
previously intended. At sunset they found themselves close by a
straggling Mohammedan cemetery, whose large square tombs were
thickly crowded together, some of them richly carved, some of them
poor and plain. The graveyard was planted with magnificent
cypresses, now casting long, long shadows in the setting sun. A
solemn melancholy silence hung around the place; even the mud
hovel, usually inhabited by the guardian fakir, was empty—a huge
Afghan dog, with closely-cropped ears and tail, lay in front of the
open doorway, sleeping on his post.
“Do you know that they say there is a Christian grave somewhere
quite close to this?” said Sir Reginald, looking round. “I wonder they
buried him so near to these people,” nodding his head in the
direction of the cemetery.
“Yes,” returned Mr. Harvey; “but it was probably done with an idea
that he would like some company.”
“Defend me from the company of an Afghan, dead or alive,”
returned his brother-officer, walking his horse on to where he
commanded a view of the fourth side of the graveyard. His two
friends followed him, and another second brought in sight a grave
and plain stone cross, about a hundred yards to their right. Standing
beside it was the fakir, in close and earnest conversation with no less
a person than Hafiz himself—Hafiz, mounted as usual on his black
Turcoman, and alone! Both had their backs turned to the cemetery,
and stood facing the setting sun, deeply absorbed in conversation,
which they emphasized from time to time with vehement and almost
frenzied gesticulation. Evidently they were hatching some evil deed.
“Hafiz, by all that is lucky!” exclaimed Sir Reginald, drawing out his
revolver and putting his horse into a sharp canter. But between him
and the fakirs ran a deep nullah, and ere he reached its bank they
were both aware of the presence of the three hussars.
Hafiz paused for a second to glare at the intruders, then raising
one arm to heaven, with a loud invocation to Allah, he turned and
spat on the cross beneath him with a gesture of the utmost
abhorrence and contempt, and wheeling his horse half round, with a
derisive farewell to his foes, he started off at full gallop. This
outrageous insult to their faith and nation affected the three
Englishmen variously. Captain Vaughan, who was of rather full habit,
became absolutely purple with passion; Mr. Harvey relieved his
feelings with several round oaths; Sir Reginald said nothing, but his
lips tightened under his dark moustache in a way that was ominous
enough. With a vicious dig of the spurs he forced his horse down the
rugged sides of the nullah, up the opposite bank, and away across
the plain in hot pursuit of the holy man. The two Yarkundis, urged to
the very top of their speed, joined neck and neck in the chase for a
short distance, but endurance, not pace, was their forte, and they
soon ceased to answer to the repeated applications of their riders’
spurs and Annamullay canes, and began to lag behind the free-going
Arab.
“It’s no use, Fairfax,” shouted Captain Vaughan, pulling up; “you’ll
never overtake him.”
“I will!” he returned, looking back for a second. “I’ll catch him and
kill him, if I follow him to Candahar.”
His friends’ remonstrances were given to the winds; he had
already distanced them by a hundred yards, and soon he and the
far-receding fakir became mere specks in the distance, and rounding
the spur of a hill, were completely lost to sight.
The two officers waited impatiently for the sound of shots, but the
silence that reigned around them remained unbroken, save for the
distant cry of the jackal setting out on his nightly career, and
seeming to say more distinctly than usual: “I smell dead white men,
I smell dead white men.”
The whistle of a kite sailing homewards was the only other sound
that broke the dead surrounding stillness. The sun had set; ten
minutes previously it had vanished below the horizon in the shape of
a little red speck; gray twilight was rapidly spreading her mantle over
hills and plains, and our two friends, finding they had completely lost
sight of their hot-headed companion, reluctantly turned their ponies’
heads homewards, and retailed their adventure to their comrades
round the camp-fire. These listened to it with many interruptions of
surprise and dismay.
“Fairfax was splendidly mounted; that Arab of his was one of the
best horses out of Abdul Rahman’s stables, that’s some comfort,”
remarked one.
“Yes, he was evidently gaining on the Turcoman when we saw the
last of him,” returned Mr. Harvey; “but, for all we know, Fairfax has
galloped straight into the Afghan camp.”
“I had no idea he was such a Quixotic fool,” growled a grizzly-
headed colonel, angrily kicking the logs in front of him. “It would not
surprise me if we never saw him again.”
Some said one thing, some another, but all agreed in feeling very
grave uneasiness on behalf of their brother-officer.
The mess-bugle sounded and was responded to, dinner was
disposed of, and still Fairfax did not appear. Meanwhile Sir Reginald,
once lost to sight, had been, as Mr. Harvey remarked, overtaking
Hafiz at every stride. The Turcoman had done a long day’s march,
and, though urged by his rider to great exertions, was no match for
the well-bred Arab in his wake. The distance between them
diminished gradually but surely. The black horse was only leading by
thirty yards when Hafiz turned and glanced over his shoulder. It was,
as he had fancied, the very selfsame Kaffir who had taken the
sacred standard. They were within half a mile of the Rohilla
headquarters, and Allah had surely given him over for a prey into his
hand. But his horse was failing, and the Feringhee would soon be at
his girths. Best finish the matter at once. Reining up suddenly, he
faced the approaching horseman with astonishing celerity, and
drawing a pistol, which he aimed for half a second, he fired at him
point-blank. The bullet missed its intended destination and buried
itself deep in the brain of the Arab charger, who with one frantic
convulsive bound fell forward dead on the sand, and the fakir, with
drawn yataghan, charged down on the dismounted hussar,
determined to have his life.
But, Hafiz, your evil star was in the ascendant. Had you but
known, you would have been far wiser to have ridden off and left
your foe to find his way back to camp on foot, and to take his
chance of being murdered by your prowling countrymen.
With an expression of fiendish hatred the fakir rode at Sir
Reginald, his uplifted weapon ready to descend with fatal effect. But
he had to contend with a man of half his age and ten times his
activity, who sprang at him and seized his arm, and in so doing
broke the force of the blow, which, instead of sweeping off our
hero’s head, as intended, merely inflicted a flesh wound in his
shoulder, and before Hafiz had time to recover himself, a bullet from
Sir Reginald’s revolver found a lodging in his breast. Swaying heavily
backwards and forwards, his powerless hands dropped reins and
weapon, and he fell from his saddle like a sack; and our hussar,
catching the Turcoman by the bridle and disengaging his late master
from the stirrup, sprang on his back, turned his head in the direction
of the English camp, and rode off at the top of his speed.
His practised ear had caught the sounds of approaching hoofs,
attracted doubtless by the shots; but still he had a start of fully a
quarter of a mile, and made the very most of it. Infuriated Pathans
rode hard upon his track, and it was not till he was well within the
lines of the English picket, and saw their camp-fires blazing, that he
ventured to draw rein and allow the exhausted Turcoman to proceed
at a walk. It does not often happen to a horse to have to carry two
successive riders flying for their lives within the same hour. Shaitan’s
drooping head and heaving sides bore witness to a hard day’s work,
as he was led by his new owner within the bright circle of light
thrown by the officers’ camp-fire.
Exclamations, remonstrances, and questions were volleyed at Sir
Reginald as once more he stood among his friends, bare-headed and
ghastly pale, with the bridle of the notorious black charger hanging
over one arm. Very brief were the answers he vouchsafed to half-a-
dozen simultaneous interrogations.
“Hafiz was badly wounded, if not dead. He was not likely to
trouble them for some time, if ever; his own charger was lying on
the plain with a bullet in his brain, and affording a fine supper for
the jackals. Yes, he had had to ride for it coming back, and the black
was pretty well done.” Here, as he came nearer to the logs, it was
seen that one sleeve of his Karki coat was soaked in blood.
Questions were immediately at an end, and he was hurried off by
the doctor to have his wounds looked to, in spite of his urgent
disclaimers and assurances “that it was a mere scratch.”
The Turcoman, the sight of which acted on the Afghans as a red
rag to a turkey-cock, soon became accustomed to an English bit and
an English rider, and made his new master a most valuable second
charger. Many were the attempts to recover him, to shoot him, to
get him from his abhorred Kaffir owner at any price, but all efforts
were futile, he was much too well guarded. When Sir Reginald was
invalided home, he was sent down to Bombay with his other horses,
and sold for a very high price to a hard-riding Member of Council;
and doubtless the destination of the once feared and honoured “evil
one” will be to end his days in a Bombay buggy.
CHAPTER III.
“MY CAPTAIN DOES NOT ANSWER; HIS LIPS
ARE PALE AND STILL.”
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookmass.com