Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

Programming for Absolute Beginners:

Using the JavaScript Programming


Language 1st Edition Jonathan Bartlett
Visit to download the full and correct content document:
https://ebookmass.com/product/programming-for-absolute-beginners-using-the-javas
cript-programming-language-1st-edition-jonathan-bartlett/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Modern C for Absolute Beginners: A Friendly


Introduction to the C Programming Language 2nd Edition
Slobodan Dmitrovi■

https://ebookmass.com/product/modern-c-for-absolute-beginners-a-
friendly-introduction-to-the-c-programming-language-2nd-edition-
slobodan-dmitrovic/

Javascript: Crash Course - The Complete Beginners Guide


To Learning JavaScript Programming In No Time!
(Angularjs, jQuery, JavaScript Visually) Nathaniel Hill

https://ebookmass.com/product/javascript-crash-course-the-
complete-beginners-guide-to-learning-javascript-programming-in-
no-time-angularjs-jquery-javascript-visually-nathaniel-hill/

Modern C++ for Absolute Beginners: A Friendly


Introduction to the C++ Programming Language and C++11
to C++23 Standards, 2nd Edition Slobodan Dmitrovi■

https://ebookmass.com/product/modern-c-for-absolute-beginners-a-
friendly-introduction-to-the-c-programming-language-
and-c11-to-c23-standards-2nd-edition-slobodan-dmitrovic/

The AWK Programming Language, 2nd Edition Aho

https://ebookmass.com/product/the-awk-programming-language-2nd-
edition-aho/
C Programming Absolute Beginner’s Guide (3rd Edition)
Perry

https://ebookmass.com/product/c-programming-absolute-beginners-
guide-3rd-edition-perry/

Go Programming Language For Dummies 1st Edition Wei-


Meng Lee

https://ebookmass.com/product/go-programming-language-for-
dummies-1st-edition-wei-meng-lee/

C Programming for Beginners by Sett John Hafeez


Abdulmutolib

https://ebookmass.com/product/c-programming-for-beginners-by-
sett-john-hafeez-abdulmutolib/

Coding for Kids 5 Books in 1: Javascript, Python and


C++ Guide for Kids and Beginners (Coding for Absolute
Beginners) Mather

https://ebookmass.com/product/coding-for-kids-5-books-
in-1-javascript-python-and-c-guide-for-kids-and-beginners-coding-
for-absolute-beginners-mather/

C Programming Language: C PROGRAMMING LANG _p2 2nd


Edition, (Ebook PDF)

https://ebookmass.com/product/c-programming-language-c-
programming-lang-_p2-2nd-edition-ebook-pdf/
Programming for
Absolute Beginners
Using the JavaScript
Programming Language

Jonathan Bartlett
Programming for Absolute Beginners: Using the JavaScript Programming Language
Jonathan Bartlett
Tulsa, OK, USA

ISBN-13 (pbk): 978-1-4842-8750-7 ISBN-13 (electronic): 978-1-4842-8751-4


https://doi.org/10.1007/978-1-4842-8751-4
Copyright © 2023 by Jonathan Bartlett
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: James Markham
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image by Fullvector on Freepik (www.freepik.com)
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004,
U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.
springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science +
Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub (https://github.com/Apress). For more detailed information, please visit http://www.
apress.com/source-­code.
Printed on acid-free paper
Most good programmers do programming not because
they expect to get paid or get adulation by the public,
but because it is fun to program.

—Linus Torvalds
Table of Contents
About the Author����������������������������������������������������������������������������������������������������� xi

About the Technical Reviewer������������������������������������������������������������������������������� xiii

Acknowledgments���������������������������������������������������������������������������������������������������xv

Chapter 1: Introduction�������������������������������������������������������������������������������������������� 1
1.1 What You Will Learn����������������������������������������������������������������������������������������������������������������� 1
1.2 How to Use This Book������������������������������������������������������������������������������������������������������������� 3
1.3 For Younger Programmers������������������������������������������������������������������������������������������������������ 4

Part I: Computers, Data, and Communication.................................................. 5


Chapter 2: A Short History of Computers����������������������������������������������������������������� 7
2.1 The Prehistory of Computers�������������������������������������������������������������������������������������������������� 7
2.2 The Idea of a Computer����������������������������������������������������������������������������������������������������������� 9
2.3 The Age of the Computer������������������������������������������������������������������������������������������������������ 10
2.4 Computers in the Age of Networks��������������������������������������������������������������������������������������� 13
2.4.1 Review�������������������������������������������������������������������������������������������������������������������������� 14
2.4.2 Apply What You Have Learned�������������������������������������������������������������������������������������� 15

Chapter 3: How Computers Communicate�������������������������������������������������������������� 17


3.1 The Layers of Internet Communication��������������������������������������������������������������������������������� 19
3.2 Communicating Using HTTP�������������������������������������������������������������������������������������������������� 22
3.3 Connecting with a Remote Server Manually������������������������������������������������������������������������� 26
3.4 How Computers Are Located on the Internet������������������������������������������������������������������������ 27
3.4.1 Review�������������������������������������������������������������������������������������������������������������������������� 29
3.4.2 Apply What You Have Learned�������������������������������������������������������������������������������������� 29

v
Table of Contents

Chapter 4: How a Computer Looks at Data������������������������������������������������������������� 31


4.1 What Computer Memory Looks Like������������������������������������������������������������������������������������� 32
4.2 Using Numbers to Represent Data���������������������������������������������������������������������������������������� 35
4.3 Sequences in Data���������������������������������������������������������������������������������������������������������������� 37
4.4 Using Numbers to Represent Letters������������������������������������������������������������������������������������ 38
4.5 What Is a File Format?���������������������������������������������������������������������������������������������������������� 40
4.5.1 Review�������������������������������������������������������������������������������������������������������������������������� 42
4.5.2 Apply What You Have Learned�������������������������������������������������������������������������������������� 43

Chapter 5: How Computers Work��������������������������������������������������������������������������� 45


5.1 Parts of a Computer�������������������������������������������������������������������������������������������������������������� 46
5.2 A Simplified Paper Machine Simulation�������������������������������������������������������������������������������� 48
5.3 A Short Program: Multiplying by 2���������������������������������������������������������������������������������������� 5 2
5.3.1 Setting Up the Simulation��������������������������������������������������������������������������������������������� 53
5.3.2 Running the Simulation������������������������������������������������������������������������������������������������ 53
5.4 Adding a List of Numbers������������������������������������������������������������������������������������������������������ 56
5.5 Machine Opcode Tables�������������������������������������������������������������������������������������������������������� 60
5.5.1 Review�������������������������������������������������������������������������������������������������������������������������� 65
5.5.2 Apply What You Have Learned�������������������������������������������������������������������������������������� 66

Part II: Basic Ingredients for Web Programming........................................... 67


Chapter 6: The HTML File Format��������������������������������������������������������������������������� 69
6.1 A Quick Introduction to HTML����������������������������������������������������������������������������������������������� 69
6.2 The Parts of an HTML Document������������������������������������������������������������������������������������������� 72
6.3 Adding Attributes to Tags������������������������������������������������������������������������������������������������������ 76
6.4 Tags That Refer to Other Documents������������������������������������������������������������������������������������ 76
6.5 Relative URLs������������������������������������������������������������������������������������������������������������������������ 80
6.6 Other HTML Features������������������������������������������������������������������������������������������������������������ 81
6.6.1 Entities�������������������������������������������������������������������������������������������������������������������������� 81
6.6.2 Lists������������������������������������������������������������������������������������������������������������������������������ 82
6.6.3 Table Tags��������������������������������������������������������������������������������������������������������������������� 82
6.6.4 Form Tags��������������������������������������������������������������������������������������������������������������������� 84
vi
Table of Contents

6.6.5 Standard Attributes������������������������������������������������������������������������������������������������������ 85


6.6.6 Comments, Declarations, Processing Instructions, and CDATA Blocks������������������������� 86
6.6.7 Review�������������������������������������������������������������������������������������������������������������������������� 88
6.6.8 Apply What You Have Learned�������������������������������������������������������������������������������������� 89

Chapter 7: Introduction to Cascading Style Sheets������������������������������������������������ 91


7.1 The Origin of Cascading Style Sheets����������������������������������������������������������������������������������� 91
7.2 The Structure of a CSS Document����������������������������������������������������������������������������������������� 93
7.3 Understanding Selectors������������������������������������������������������������������������������������������������������� 95
7.4 The CSS Box Model��������������������������������������������������������������������������������������������������������������� 98
7.5 Other Capabilities of CSS���������������������������������������������������������������������������������������������������� 101
7.5.1 Review������������������������������������������������������������������������������������������������������������������������ 101
7.5.2 Apply What You Have Learned������������������������������������������������������������������������������������ 102

Chapter 8: Your First JavaScript Program������������������������������������������������������������ 105


8.1 A Short History of JavaScript���������������������������������������������������������������������������������������������� 105
8.2 A Simple JavaScript Program��������������������������������������������������������������������������������������������� 107
8.3 Moving the JavaScript to Its Own File��������������������������������������������������������������������������������� 112
8.3.1 Review������������������������������������������������������������������������������������������������������������������������ 114
8.3.2 Apply What You Have Learned������������������������������������������������������������������������������������ 115

Part III: JavaScript Fundamentals............................................................... 117


Chapter 9: Basic JavaScript Syntax��������������������������������������������������������������������� 119
9.1 Elements of Syntax������������������������������������������������������������������������������������������������������������� 119
9.2 Assignment Statements������������������������������������������������������������������������������������������������������ 121
9.3 Control Structures��������������������������������������������������������������������������������������������������������������� 123
9.3.1 The if Statement��������������������������������������������������������������������������������������������������������� 123
9.3.2 The while Statement��������������������������������������������������������������������������������������������������� 126
9.3.3 The for Statement������������������������������������������������������������������������������������������������������� 128
9.3.4 Review������������������������������������������������������������������������������������������������������������������������ 130
9.3.5 Apply What You Have Learned������������������������������������������������������������������������������������ 131

vii
Table of Contents

Chapter 10: Introducing Functions and Scope����������������������������������������������������� 133


10.1 Your First Function������������������������������������������������������������������������������������������������������������ 134
10.2 More Function Examples��������������������������������������������������������������������������������������������������� 136
10.3 Functions Calling Functions���������������������������������������������������������������������������������������������� 138
10.4 Variable Scopes����������������������������������������������������������������������������������������������������������������� 138
10.4.1 Review���������������������������������������������������������������������������������������������������������������������� 141
10.4.2 Apply What You Have Learned���������������������������������������������������������������������������������� 142

Chapter 11: Grouping Values Together with Objects and Arrays�������������������������� 145
11.1 A Basic Introduction to Objects����������������������������������������������������������������������������������������� 146
11.2 Simplifying Object Creation����������������������������������������������������������������������������������������������� 149
11.3 Storing Sequences of Values Using Arrays����������������������������������������������������������������������� 150
11.4 Using Arrays in Programs�������������������������������������������������������������������������������������������������� 151
11.5 Mixing Objects and Arrays������������������������������������������������������������������������������������������������ 154
11.6 Object Methods����������������������������������������������������������������������������������������������������������������� 156
11.6.1 Review���������������������������������������������������������������������������������������������������������������������� 159
11.6.2 Apply What You Have Learned���������������������������������������������������������������������������������� 160

Chapter 12: Interacting with Web Pages�������������������������������������������������������������� 161


12.1 Using the JavaScript Console������������������������������������������������������������������������������������������� 161
12.2 Finding and Modifying Web Page Elements���������������������������������������������������������������������� 163
12.3 Creating New HTML Elements������������������������������������������������������������������������������������������ 165
12.4 Communicating with Input Fields������������������������������������������������������������������������������������� 166
12.5 Adding Functionality to Buttons���������������������������������������������������������������������������������������� 169
12.6 Putting It All Together�������������������������������������������������������������������������������������������������������� 170
12.7 Logging to the Console����������������������������������������������������������������������������������������������������� 172
12.7.1 Review���������������������������������������������������������������������������������������������������������������������� 174
12.7.2 Apply What You Have Learned���������������������������������������������������������������������������������� 175

viii
Table of Contents

Part IV: Intermediate JavaScript................................................................. 177


Chapter 13: Recursive Functions and the Stack��������������������������������������������������� 179
13.1 The Program Stack������������������������������������������������������������������������������������������������������������ 179
13.2 Local Variables in the Stack���������������������������������������������������������������������������������������������� 183
13.3 Recursive Functions���������������������������������������������������������������������������������������������������������� 188
13.3.1 Review���������������������������������������������������������������������������������������������������������������������� 192
13.3.2 Apply What You Have Learned���������������������������������������������������������������������������������� 193

Chapter 14: Manipulating Functions and Scopes������������������������������������������������� 195


14.1 Functions as Parameters to Functions������������������������������������������������������������������������������ 195
14.2 Functions That Return Functions�������������������������������������������������������������������������������������� 198
14.3 Functions That Create Functions�������������������������������������������������������������������������������������� 198
14.4 Currying Functions������������������������������������������������������������������������������������������������������������ 204
14.5 Anonymous Functions������������������������������������������������������������������������������������������������������� 205
14.5.1 Review���������������������������������������������������������������������������������������������������������������������� 206
14.5.2 Apply What You Have Learned���������������������������������������������������������������������������������� 207

Chapter 15: Intermediate Objects������������������������������������������������������������������������� 209


15.1 Attaching Functions to Objects����������������������������������������������������������������������������������������� 209
15.2 Using Objects Productively����������������������������������������������������������������������������������������������� 213
15.3 Constructing Objects��������������������������������������������������������������������������������������������������������� 215
15.3.1 Review���������������������������������������������������������������������������������������������������������������������� 216
15.3.2 Apply What You Have Learned���������������������������������������������������������������������������������� 217

Part V: Programming Applications.............................................................. 219


Chapter 16: Modernizing JavaScript�������������������������������������������������������������������� 221
16.1 Declaring Variables with let and const������������������������������������������������������������������������������ 221
16.2 Destructuring Assignments����������������������������������������������������������������������������������������������� 223
16.3 Accessing Properties with Strings������������������������������������������������������������������������������������ 225
16.4 Function Syntax��������������������������������������������������������������������������������������������������������������� 226
16.4.1 Review���������������������������������������������������������������������������������������������������������������������� 227
16.4.2 Apply What You Have Learned���������������������������������������������������������������������������������� 228

ix
Table of Contents

Chapter 17: Working with Remote Services (APIs)���������������������������������������������� 229


17.1 Getting an API Key������������������������������������������������������������������������������������������������������������� 230
17.2 JSON: The Language of Data��������������������������������������������������������������������������������������������� 231
17.3 Accessing the Network with JavaScript��������������������������������������������������������������������������� 232
17.4 The Query String��������������������������������������������������������������������������������������������������������������� 233
17.5 Interacting with a Web Page��������������������������������������������������������������������������������������������� 235
17.6 A Few Other Bits to Note��������������������������������������������������������������������������������������������������� 237
17.6.1 Review���������������������������������������������������������������������������������������������������������������������� 239
17.6.2 Apply What You Have Learned���������������������������������������������������������������������������������� 240

Chapter 18: Writing Server-Side JavaScript��������������������������������������������������������� 241


18.1 Programming Languages�������������������������������������������������������������������������������������������������� 241
18.2 Using JavaScript Outside of the Browser�������������������������������������������������������������������������� 242
18.3 A Small Web Service Using Node�������������������������������������������������������������������������������������� 243
18.4 Why We Need Frameworks����������������������������������������������������������������������������������������������� 244
18.5 Making Your Service Available������������������������������������������������������������������������������������������ 245
18.5.1 Review���������������������������������������������������������������������������������������������������������������������� 246
18.5.2 Apply What You Have Learned���������������������������������������������������������������������������������� 246

Chapter 19: Conclusion����������������������������������������������������������������������������������������� 249

Appendix A: Glossary�������������������������������������������������������������������������������������������� 251

Appendix B: Operating System and Browser Specifics���������������������������������������� 293


Appendix C: The JavaScript Toolbox on Docker��������������������������������������������������� 309

Appendix D: Character Encoding Issues��������������������������������������������������������������� 311

Appendix E: Additional Machine Language Programs������������������������������������������ 319

Index��������������������������������������������������������������������������������������������������������������������� 323

x
About the Author
Jonathan Bartlett is a software developer, researcher, and
writer. His first book, Programming from the Ground Up, has
been required reading in computer science programs from
DeVry to Princeton. He has been the sole or lead author for
eight books on topics ranging from computer programming
to calculus. He is a senior software developer for McElroy
Manufacturing, spearheading projects in web, mobile, and
embedded software. He is now the author of several Apress
books including Electronics for Beginners and more.

xi
About the Technical Reviewer
Germán González-Morris is a polyglot software architect/engineer with more than 20
years in the field, with knowledge in Java(EE), Spring, Haskell, C, Python, and JavaScript,
among others. He works with web-distributed applications. Germán loves math
puzzles (including reading Knuth) and swimming. He has tech-reviewed several books,
including an application container book (Weblogic), as well as titles covering various
programming languages (Haskell, Typescript, WebAssembly, Math for coders, and
regexp). You can find more details at his blog site (https://devwebcl.blogspot.com/)
or Twitter account (@devwebcl).

xiii
Acknowledgments
I want to take a moment and thank everyone who helped me write this book. First, I want
to thank those who read and appreciated my first programming book, Programming
from the Ground Up. The encouragement I received from that book has given me the
encouragement to continue writing and educating throughout the years.
Next, I want to thank my homeschool summer co-op class for being guinea pigs
for this material. Your questions, your successes, and your difficulties all informed the
writing of this book. You were both my motivation to write in the first place and the first
proving ground for the material.
I would also like to thank my family, my friends, and my church, all of whom are
essential parts of my life. Thanks especially to my wife who puts up with me when I am
too focused on my writing to notice what the kids have been up to or to put a stop to
whatever trouble they have found themselves in!

xv
CHAPTER 1

Introduction
The modern world is filled with computers. Computers run our phones, our cars, and
even our refrigerators. Computers manage our businesses, our calendars, and our social
lives. With the world relying on computers for so many functions, it is important to know
how these devices work. Even if you never need to program a computer yourself, chances
are that, at some point in your life, you will be involved with software development.
You may be an accountant who needs to tell a computer programmer how you want
your purchasing system set up. You may be an engineer who needs to describe your
engineering process so that a programmer can automate it. In all such tasks as these, it
is important to know something about how computers are programmed, even if you are
not personally writing the software.

1.1 What You Will Learn


When programming computers, a programmer uses a programming language to tell
the computer how to do something. Because computers are not intelligent beings, they
can’t understand ordinary human languages. Computers understand a type of language
called machine language, which will be discussed further in Chapter 5. Machine
languages are very different from the kind of languages ordinary people use. Therefore,
programming languages were developed to meet programmers halfway—they are more
humanlike than machine language and more machinelike than human language.
Numerous programming languages have been developed over the years. Some that
you may have heard of include Java, JavaScript, Ruby, Python, C#, Go, Rust, and Swift.
Although each language looks different, they are all trying to do the same task of helping
you to interface with the machine in a way that is friendlier and easier to manage than
machine language. In fact, most programming languages are geared around very similar
concepts, and some of them even look similar. Therefore, learning any programming
language will help you more easily learn any other programming language. I have rarely

1
© Jonathan Bartlett 2023
J. Bartlett, Programming for Absolute Beginners, https://doi.org/10.1007/978-1-4842-8751-4_1
Chapter 1 Introduction

hired people for my development team who already knew the programming language
that my team uses. If someone learns one programming language and practices until
they are good at it, then the effort to learn a new language is fairly minimal.
You may wonder why, if the languages are so similar, there are so many
programming languages to choose from. The fact is, when engineering anything, trade-­
offs have to be made. Sometimes in order to make one type of task easier, another type
of task has to be made harder. In my kitchen I have both a mixer and a blender. Both of
them operate on the same basic principles—you put food into the main container area,
an electric motor turns, and some attachment combines the food together. While these
tasks are very similar and operate on the same principles, there are many types of food
in the world and many ways that they need to be mixed, such that the mixer works better
for some tasks and the blender for others. Similarly, with programming languages, some
of them are better suited to different tasks. Also, the choice of programming language
is dependent on the programmer. Just as different types of cars suit the preferences and
tendencies of different types of drivers, so do different programming languages suit the
preferences and tendencies of different types of programmers. Because of these reasons,
there are numerous programming languages available for nearly any task you might
want to perform.
The programming language covered in this book is called JavaScript. I like to teach
JavaScript as a first language for several reasons. First of all, JavaScript was developed
to be a first language. One of the goals of the language was to make it easy for new
programmers to get started quickly. Even though JavaScript was designed to make
programming easier for new programmers, it is not any less powerful as a language.
Second, JavaScript has become the de facto programming language for website
interfaces. If you use a website that does anything besides link to other web pages,
JavaScript is probably involved. Therefore, learning JavaScript will have immediate
practical benefits in learning how the Web operates. Third, the tools for programming
JavaScript are available on every computer. You don’t need to download any special tools
to program JavaScript. If you have a computer with a web browser, you can program
JavaScript! Finally, JavaScript is very similar to other popular programming languages
such as C#, Java, and Swift. Therefore, knowing JavaScript will not only be immediately
beneficial for programming websites, it is also a language that makes it easy to transition
to other popular systems.
This book is for the first-time programmer. No prior programming experience is
assumed. This book does assume that you have a basic understanding of how to use your
computer and browse the Internet. That is all that you need!
2
Chapter 1 Introduction

You will learn not only the basics of computer programming but also a more general
knowledge of how computers and data work. You will learn where computers came
from, how they work, how computers work with data, how data is transmitted, and how
web pages work. This book will not go in-depth in all of these subjects, but it will give
you a basic working framework that will help you better understand ideas that you may
encounter elsewhere.

1.2 How to Use This Book


This book follows several conventions to help you along your programming journey.
First, this book will introduce you to new terminology. In order to highlight the
important words, terms will be printed in bold print the first time that they are used.
You can find a complete list of terms in Appendix A. These terms are important, and you
should memorize their meanings.
When this book lists out computer programs, parts of computer programs, or
anything that should be typed in directly (and precisely), it will be offset from the text
and written in a special font to help you see that it is a computer program. Computer
programs will look like this:

window.alert("This is an example of a computer program.");

When discussing smaller pieces of code within a paragraph, code that is under
discussion will look like this.
Now, there are many different types of computers, each with different operating
systems and software loaded on them, with each of those having different versions.
There are also numerous different web browsers, each with different features available
and slightly different ways of working. This book attempts to walk you through setting
everything up on each operating system. If there is anything in this book that depends
on the specific operating system or browser that you are using, Appendix B has the steps
for several different systems, including Windows and Mac operating systems. This book
will refer you to the appropriate section of the Appendix when needed. Though this
book works with any modern web browser (basically anything released after 2008), I
recommend that you use Google Chrome. As of the time of this writing, Google Chrome
is the easiest browser to work with as a programmer. That being said, you should be just
fine with any web browser, including Brave, Firefox, Safari, Chrome, Opera, or Edge.

3
Chapter 1 Introduction

This book contains several practice questions and practice activities. The goal of
these questions and activities is to provide you with a hands-on way of understanding
the material. By doing the questions and activities, the text will become much more
meaningful and understandable. More importantly, they might show you the places
where you did not fully understand the text. Many people have a tendency to skip over
things if they don’t understand them well. Practice questions and activities give you a
chance to slow down and make sure you know which parts you understood and which
parts you need to read again and spend time thinking about. Practice questions build
on each other, so by doing them all in the order given, you can see exactly where you are
having problems.
At the end of every chapter is a review section which covers the most important
concepts of each chapter. After that is a section to help you practice applying your
knowledge to problems. These questions require you to further engage your brain and
really think about what you learned in that chapter and what it means.
Appendix A contains an extended glossary of terms used in this book, plus others
you are likely to encounter when reading about programming. This chapter will help you
find your bearings as you read and talk with other people about programming. I would
suggest that, concurrent with your readings, you also take the time to look through the
glossary for words that you may have heard but did not understand at the time.
Also, if you run into problems when writing code, Section B.6 has several suggestions
for getting you back on the right track.

1.3 For Younger Programmers


This book is primarily geared for people who are coming to computer programming as a
new career, college students, or even high school students. However, it can also be used
for middle school students with some modification. Middle school students, generally,
are not cognitively ready for all of the material after Part 3. This doesn’t mean it can’t be
covered or read, but it might be good to pick and choose material that is appropriate to
student interests and abilities. If parts are difficult to understand, they can be returned to
at a later time.
All right, are you ready? Let’s get started!

4
CHAPTER 2

A Short History
of Computers
The history of computers is weird and wonderful. What started as an abstract
philosophical quest ended up setting the course for society for over a century and
continues to be one of the most profound parts of modern life. The goal of this chapter is
to trace an outline of where computing started, where it has been, and where it is now.

2.1 The Prehistory of Computers


Humans have always had tools. Humans have built fires, made spears, and built houses
from the beginning. At first, however, technology was limited to standing structures or
tools that were extensions of yourself—like knives or bows and arrows. Very little early
technology was powered and free-functioning. It was manually powered by human
effort. Therefore, since the power of a machine was limited to what humans could drive,
only small machines could be devised.
The ability to power a machine led to huge advances in technology. The earliest
power source was probably water, where water could turn a wheel to grind wheat or
operate a sawmill. These water-based power sources, however, were fairly limited in the
types of devices they could drive. Such technology was mostly limited to standing wheel-­
based inventions.
This was essentially the state of technology from about 300 BC to the early 1700s
AD. At this point in history, technology had two main limiting factors. The first was
limitations of power availability, and the second was the need for customized parts.
The industrial revolution solved both of these problems. The steam engine allowed
the creation of powered machines anywhere. Powered machines were no longer tied

7
© Jonathan Bartlett 2023
J. Bartlett, Programming for Absolute Beginners, https://doi.org/10.1007/978-1-4842-8751-4_2
Chapter 2 A Short History of Computers

to being near streams but could now go anywhere, since the power could be generated
from fire and stored water. Eventually this even allowed the creation of trains, since the
power could move with the vehicle.
The other invention of the industrial revolution was interchangeable parts.
This allowed a standardization and maintenance of equipment that was previously
unattainable. Instead of having each part be a unique piece, the parts became
standardized which allowed for the machines to become more specialized. It is one
of the more curious paradoxes of technology that as the pieces of technology become
less unique, the more advanced and unique the systems created from those parts can
become. Standardization allows for users of technology to stop having to think about all
of the low-level decisions and focus on the larger, more meaningful decisions. This also
allows for better communication about systems, because the parts can be more readily
described. If I can give you a schematic that lists premade parts, it is much easier to
design and communicate that design than if I also had to describe how each individual
part was supposed to be made.
So the introduction of available powered machinery and standardized parts in the
industrial revolution led to an explosion of specialized machines. We then had machines
to perform any number of tasks that a person could want to do. The next step was the
introduction of machines which were directed not by people directly controlling the
machine but by coded instructions. The earliest of these machines was the Jacquard
Loom, which used punched cards to signify a pattern woven into a fabric. The cards had
punched holes to signify to the machine the raising or lowering of the particular thread
causing it to be visible or hidden in the pattern. Thus, the loom could be programmed
to make a pattern by specifying at each point whether each thread should be raised or
lowered.
Later inventions applied this concept to mathematics. Calculating machines had
been around for a long time, with Blaise Pascal’s mechanical calculator having been
invented in the mid-1600s. However, this required the power of physical manipulation
to actually accomplish the addition. Most mathematical tasks are not single-step like
addition but require a process of several steps, sometimes repeating steps, before finding
an answer. Charles Babbage invented a more advanced machine to perform navigational
calculations. In this machine, the user entered the input, and then the machine used
that input to run a series of steps which eventually yielded results. Babbage eventually
designed a machine that could take a list of arbitrary instructions much like a modern
computer, but he was never able to build that design.

8
Chapter 2 A Short History of Computers

Once humans had the ability to power a machine, create a machine that operated
on external instructions, and use those instructions to perform mathematical functions,
they had all of the pieces in place to create a computer. However, the revolution that
brought about computing took place not from an invention, but from a problem in
philosophy.

2.2 The Idea of a Computer


What separates modern computers from the calculating machines of the past is that
modern computers are general-purpose computers. That is, they are not limited to a
specific set of predesigned features. I can load new features onto a computer by inputting
the right program. How did we get the idea of creating such a general-purpose machine?
It turns out that a question in philosophy led to the creation of general-purpose
machines. The question was this—was there a way to create an unambiguous procedure
for checking mathematical proofs? This seems like an odd question, but it was a big
question in the nineteenth century. There had been many “proofs” where it was unclear
if the proof actually proved its subject. Thus, philosophers of mathematics tried to
find out if there was a way to devise what was then called an “effective procedure” for
checking the validity of a mathematical proof. But that leads to another question—what
counts as an “effective procedure” anyway? If I list out the steps of a procedure, how do I
know that I’ve given you enough details that you can accomplish this procedure exactly
as I have described it? How can I tell that my instructions are clear enough to know that
the procedure that I have listed can be unambiguously accomplished?
Alan Turing and Alonzo Church both tackled this problem in the 1930s. The
results showed that one could define unambiguous procedures with the help of
machines. By describing a machine that could perform the operation, one can be
certain that the operation of the procedure would be unambiguous. In addition,
Turing described a set of operations which could be used to mimic any other set
of operations given the right input. That is, Turing defined the minimum set of
features needed for a computing system to become truly programmable—where the
programmer had an open-ended ability to write whatever software he or she wanted.
Machines and programming languages that are at least as powerful as Turing’s set of
features are known as Turing-­complete or Universal programming languages. Nearly
every modern programming language in common usage is Turing-complete.

9
Chapter 2 A Short History of Computers

It is interesting to note that the creation of computing came from a question in


philosophy. Many are eager to dismiss the role of philosophy in academics as being
impractical or unimportant. But, as we see here, like all truths, philosophical truths have
a way of leading to things of deep practical importance.
And what happened to the original question—can you develop an effective
procedure for checking proofs? The answer is, strangely, no. It turns out that there are
true facts that cannot be proven via mechanical means. But to learn that answer, we
had to develop computers first. Of course, that leads to another interesting intersection
between computers and philosophy. If there are true facts that cannot be mechanically
proven, how could we know that? The only way must be because our minds cannot be
represented mechanically. This puts a limit on the potential capabilities of artificial
intelligence and shows that even though computer programmers have developed some
very clever means of pretending to be human, the human mind is simply outside the
realm of mechanism or mechanistic simulations.1

2.3 The Age of the Computer


Shortly after Turing described the necessary feature set for computers, people began to
build them. Probably the first Turing-complete machine was Konrad Zuse’s Z3 computer,
built in 1941. Although the Z3’s operating principles were somewhat similar to modern
computers, the Z3 was still largely a mechanical device. The first general-purpose, digital
electronic computer was the ENIAC in 1946 and was about a thousand times faster than
its mechanical predecessors. It should be noted that the ENIAC was the size of a very
large room, but it had roughly the same processing power as a scientific calculator. Its
main jobs included performing calculations for the production of the hydrogen bomb
and calculating tables for firing artillery.
The next generation of computers introduced what is normally termed the von
Neumann architecture, which means that the computer had a single memory area
which held both programs and data. This is based on the fact that both a program and
the values that the program generates can both be represented by numbers. Therefore,
the same memory can be used both for the program that tells the computer what to do

1
If you want to dive deeper into this subject, you can see my article in MindMatters, “Why I Doubt
That AI Can Match the Human Mind,” available at https://bit.ly/3FOtOsS. You may also want
to check out my YouTube video, “How to Build an Artificial Intelligence Using the Doctrine of
Man,” available at https://youtu.be/FzXW7p3AG1Y.

10
Chapter 2 A Short History of Computers

and for the data that the program generates and operates on. This makes the computers
much easier to program and use, which led to the ability to sell computers commercially.
The first commercially available computer to implement this idea was the Manchester
Mark 1. The first mass-produced computer was the UNIVAC I, followed shortly after by
IBM’s 650. These computers were still massive in size but contained less memory storage
space than a single graphic on a modern computer. The UNIVAC I was the first computer
to have an external tape storage, and external disk storage (similar to modern hard
drives) followed soon after.
The next move for computer hardware was toward miniaturization. The original
computers used large devices called vacuum tubes to perform data processing (see
Figure 2-1, left column). These vacuum tubes would allow or not allow current to flow
based on whether other wires had current flowing through them or not. Combinations of
many of these tubes could allow for data to be stored as current flow, for mathematical
operations to be performed on such data, and for the data to be moved around.
After the vacuum tube came the invention of the transistor (see Figure 2-1, middle
column). Transistors generally have three wires, where the middle wire controls whether
the electricity can flow between the other two wires. As with vacuum tubes, transistors
can be wired together to create digital computer memory, digital computer logic
operations, and digital information pathways. Transistors, while they performed the
same basic functions as the vacuum tube, were able to do so in a much smaller package
and operating on a lot less power. Transistors allowed much smaller devices to be built
which also required almost 1,000 times less power. The Metrovick 950, released in 1956,
was the first commercial computer that operated on this principle.
Miniaturization continued with the advent of integrated circuits or what are often
called microchips or just chips (see Figure 2-1, right column). An integrated circuit
basically allows for miniaturized transistors to be stored on a small, single plate of
silicon. When integrated circuits were first introduced, they only had a few transistors.
Today, integrated circuits come in a variety of sizes, and the ones used for desktop
computing can hold billions of transistor equivalents on a 2-inch square chip. Integrated
circuits basically brought computers as we know them into the world. However, when
they were first introduced, they were primarily used by very large businesses.
In the 1960s, Douglas Engelbart led a research team to look at the future of
computing. In 1968, Engelbart presented what has been termed “the mother of all
demos,” which predicted and demonstrated nearly all aspects of modern personal
computing, including graphical interfaces, networking, email, video conferencing,

11
Chapter 2 A Short History of Computers

collaborative document editing, and the Web. This served as an inspiration for a number
of companies to start pushing to make this vision of computing a reality. Engelbart had
accomplished it in a lab, but others were needed to make it a commercial reality.

Figure 2-1. Advancements in Computer Hardware Miniaturization

The picture on the left is of a vacuum tube (photo courtesy of Tvezymer on


Wikimedia). Vacuum tubes are still around today, primarily for audio applications. The
picture in the middle is of a transistor. Transistors were much smaller, required fewer
materials to produce, and used much less power but still did largely the same job as
vacuum tubes. The picture on the right is a modern microchip used in appliances (photo
courtesy of Vahid alpha on Wiki-media). Such a microchip contains the equivalent of a
few hundred thousand transistors.
The first recreational personal computer was the Altair, and the first commercial
personal computer was the Apple I which came out in 1976, after which a flood of
personal computers entered the market. IBM eventually entered the market, with
Microsoft providing the software for the computer. The interfaces for these computers
were usually text-only. However, eventually Apple released the Macintosh, which
inaugurated the age of graphical user interfaces. Shortly after, Microsoft released
Windows, which brought the graphical interface to the IBM side of the personal
computer world.

12
Chapter 2 A Short History of Computers

2.4 Computers in the Age of Networks


Thus far, computers had been largely isolated machines. You could share files through
disks, but, by and large, computers operated alone. When you link together two or more
computers, it is called a network. Though networking technology had been around for
quite a while, it had not been cheap enough or popular enough to make an impact for
most personal computer users.
For most users, networking started with office file sharing systems, usually using
a type of local networking called Ethernet which runs networking services over
specialized networking cables. People would use applications that were installed on
their own computers but store the files on a server so that the other members of the
office could access it. A server is a computer on the network that provides one or more
services to other computers and users on a network. A software program that accesses
a server is often called a client. Many office networks eventually added groupware
services to their networks—local email and calendar sharing systems that allowed the
office to work together more efficiently. While smaller organizations were focused on
local services such as file sharing and groupware, larger institutions were also at work
linking networks together. This allowed organizations to share information and data
between each other more easily.
At the same time, a few home computer users started reaching out to each other
through the phone system. A device called a modem allowed a computer to access
another computer over standard telephone lines. Services called bulletin-board
systems (known as a BBS) started popping up which allowed people to use their
computers to access a remote computer and leave messages and files for other users.
These developments laid the groundwork for the idea of the Internet. At the time
it was developed, there were many different, incompatible networking technologies.
Organizations wanted to connect their networks to other organizations’ networks but
were finding it problematic since everyone used different types of networks. In the 1970s
and 1980s, DARPA, the Defense Advanced Research Projects Agency, developed a way
to unify different types of networks from different organizations under a single system
so that they could all communicate. This network, known as ARPANET, became very
popular. Other large, multi-organizational groups started using the design of ARPANET
to create their own network. Since these networks all used the same basic design, they
were eventually joined together to become the Internet in the late 1980s.

13
Chapter 2 A Short History of Computers

The 1990s witnessed the rise of Internet Service Providers, or ISPs, which provided
a way for computer users to use the modems that they used to use for bulletin-board
systems to connect their computers to the Internet. Instead of using a modem to connect
to a single computer, like they did with bulletin-board systems, the ISP allowed a user to
use their modem to connect to a whole network. This began the mass public adoption of
the Internet by both individuals and organizations of all stripes.
In the early days of the Internet, the speed of the network was very slow, and
only text could be transmitted quickly. Eventually, modems were replaced with more
advanced (and faster) ways of connecting to the Internet, such as DSL, cable, and fiber.
This allowed more and more complex content to be transmitted over the Internet. Also,
because these technologies do not tie up a phone line, they can be used continuously,
rather than intermittently. In addition, wireless technologies, such as WiFi and
cellular-­based networking, allowed users to connect to the Internet without being tied
down by cables. These developments together led to the near-ubiquitous availability of
the Internet that we have today.
So, today, nearly all computer software is built with the network in mind. In fact,
much of the software that people use on a daily basis operates not on an individual
computer, but over a network. This allows for users to access software programs no
matter where they are or what computer they are using. It has also changed software
development so that the focus of computer software is no longer on individuals and
individual tasks but on organizing groups of people.

2.4.1 Review
In this chapter, we covered the basic history of computers. We have learned the
following:

• Humans have used tools to accomplish tasks from the beginning.

• Early tools were limited by available power options.

• Advances in power technology allowed for the improvements and


industrialization of tools.
• Standardization of parts allows for more complex machines to be
built and serviced.

• Electricity allowed for the movement of power to any needed


location.
14
Chapter 2 A Short History of Computers

• The ability to control a machine via instructions, such as the Jacquard


Loom, allowed for the creation of more general-purpose tools which
could be specialized by providing the right sets of instructions.

• Alan Turing and Alonzo Church identified the logical requirements


for making general-purpose computations.

• Several early computers were built around the idea of a general-­


purpose calculating machine.

• Advances in electronics allowed for storage of millions of transistors


onto a single microchip.

• The availability of microchips led to the era of personal computing.

• The increased usage of computers in organizations eventually


led to the need to have better means of communication between
computers.

• Networks were invented to allow computers to be hooked together to


share file and messages.

• The isolated networks around the world were eventually unified into
a single Internet-work, known as the Internet.

• The growth of the Internet combined with the ability to access


the Internet wirelessly has made the Internet a primary factor in
computer usage.

• The ubiquity of the Internet has led programmers to start designing


applications with the network in mind first, rather than as an
afterthought.

2.4.2 Apply What You Have Learned


1. Take some time to think about the history of technology and the
Internet. What do you think is next on the horizon for technology?
2. The pace of technology appears to have been accelerating over the
past century. What do you think has caused this acceleration?

15
Chapter 2 A Short History of Computers

3. Pick your favorite piece of technology mentioned in this short


history and research it. What inspired the person who developed
it? What other inventions came after it? Was it successful? Write a
few paragraphs describing the technology you have chosen, how it
functioned, and how it impacted the future of technology.

16
CHAPTER 3

How Computers
Communicate
Before we start our study of computer programming, we are going to begin by studying
the way that computers communicate. The Internet is basically a giant communication
system. Communication systems operate using protocols. A protocol is a predefined
sequence of steps used to ensure proper communication.
We actually use protocols every day. Think about what happens when you answer
the phone. What do you say and why do you say it? Think about what happens when
you answer the phone (see Figure 3-1). This signals to the person calling us that we
have picked up the phone and we are ready to start talking. If we didn’t say “hello,” the
person might think that we accidentally accepted the call without knowing it or that we
are not quite ready to talk yet. Then, at the end of the call, we usually say something like,
“Thanks for calling! Goodbye!” This signals to the other person that we are done with the
conversation. If we didn’t tell them goodbye, they might think that we are still on the line
and continue talking. If they heard silence, they may presume that either we were not
speaking because we were upset or that there was a technical problem. Therefore, we
end our conversations with a “goodbye” to let the person we are talking to know that the
conversation is over.
This is the essence of a protocol. A communication protocol is a sequence of steps or
possible steps that enable two parties to communicate or interact and know the status of
the communication or interaction. Because computers cannot think or feel, computers
rely on very rigid and exact protocols to allow them to communicate with each other. In
fact, computers use hundreds of different protocols to communicate different types of
data in different ways. Most of the time, there are actually multiple protocols happening
at once.

17
© Jonathan Bartlett 2023
J. Bartlett, Programming for Absolute Beginners, https://doi.org/10.1007/978-1-4842-8751-4_3
Chapter 3 How Computers Communicate

Figure 3-1. Even Answering the Phone Has a Protocol

Think about writing a letter. When you write a letter, there is a basic protocol that
governs the form of a letter—at minimum it should have a date, a greeting, and a closing.
However, if you decide to mail the letter, you have to send it through the mail service,
which has its own protocol. To send the letter through the mail, you need to take the
letter, fold it up, and put it in an envelope. What you write on the envelope is governed
by another protocol designed by the US Postal Service. Their protocol requires a return
address on the top left corner of the envelope, a destination address in the middle of the
envelope, and a stamp in the top right corner. Now you have two protocols happening
simultaneously—the letter-writing protocol and the envelope-addressing protocol.
These protocols are layered, which means that one of the protocols runs fully inside
of the other protocol. In computer jargon, we would say that the envelope protocol
encapsulates the letter protocol. The envelope protocol takes the results of the letter
protocol, packages it up, and puts its own protocol on top.

18
Chapter 3 How Computers Communicate

3.1 The Layers of Internet Communication


On the Internet, there is a similar layering of protocols occurring. The difference is that
on the Internet, there are many more layers interacting at once, and they all have funny
names like HTTP, TLS, TCP, IP, IEEE 802.3, SMTP, and FTP. The International Standards
Organization developed a way to help you think of these layers called the OSI Model,
which identifies seven different layers of protocols that may need to be active when
communicating on a computer network. To understand what these layers are doing,
let’s look at the questions that have to be answered in order for one computer to talk to
another.
Let’s say that we have a chat application that sends messages to another computer.
What must happen to get that message to another computer?

1. The computers must be physically connected to the Internet.


“Physical” can include both wired connections and wireless
connections. This is called the physical layer.

2. The computers must know how to move data on those physical


connections. It is not enough for the wires to be connected;
they must also know the protocols for sending messages on that
physical medium. Each computer has to be able to identify other
physically connected computers, be able to signal to them that
they are sending data, and know which computer they are sending
it to, among other details. This is called the data link layer.

3. Once the computers know how to talk to the other computers


they are physically connected to, they need to be able to talk
to computers which they are only indirectly connected to.
For instance, most locations get their Internet connection by
connecting a router to their DSL or cable line, and then the other
devices in the home connect to that router. The devices in the
home are all connected physically and communicate using the
data link layer. However, only the router is physically connected
to the Internet Service Provider (ISP). The other computers must
adopt a protocol in order to tell the router to relay their messages
on to the rest of the network. The rest of the network, likewise,
must be able to follow the same protocol. In addition, in order

19
Another random document with
no related content on Scribd:
indisputably true, that the crude lymph is sufficient to give the
infection, and that there is no necessity to draw blood at the time of
incision. Add to this, the frequent tumour of the lymphatic glands in
the axilla soon after the operation.
From these premises, it seems rational to conclude, that the
general success of inoculation is chiefly to be attributed to our mixing
the fixed variolous ferment with the lymph on the surface of the body,
by which means the viscera, most essential to our existence, are
less affected, and the poison rendered less virulent by dilution. But
the wonderful success of the present practice of inoculation remains
yet to be accounted for.
I have told you, that the most malignant diseases may be rendered
less malignant by proper treatment. The malignancy of the small-pox
hath been considerably abated by inoculation, and that malignancy
hath been still farther diminished by the gradual introduction of the
anti-phlogistic and antiseptic plan. So that in all places where
inoculation hath been long practised, and the patients thus treated,
the small-pox will naturally become a mild disorder, and the ignorant
operators themselves will be surprised at their unexpected success.
This, gentlemen of the jury, I conceive to be a true picture of the
present state of inoculation in these kingdoms. You will now lay your
heads together, and weigh well the evidence you have heard. If you
are of opinion that the articles of the indictment have been
sufficiently proved; that the Prisoner hath in an especial manner
preserved the lives of his Majesty’s liege subjects, by secret
medicines and modes of practice unknown to all other practitioners,
you will then find him guilty. If on the contrary, you think that these
things are not true, and that this is a malicious prosecution, you will
in that case acquit him.
The jury having laid their heads together, without going out of
Court, were called over, and answered to their names.
Cl. of the Cr. Gentlemen of the jury, are you agreed in your
verdict?
Jury. Yes.
Cl. of the Cr. Who shall say for you?
Jury. Our foreman.
Cl. of the Cr. Daniel Sutton, hold up your hand. You of the jury,
look upon the Prisoner. How say you? Is Daniel Sutton guilty of the
high crimes and misdemeanors of which he stands indicted, or not
guilty?
Jury. Not guilty.
The Prisoner was acquitted, and discharged accordingly.

FINIS.
Transcriber’s Notes
A few minor errors in punctuation were fixed.
A few minor inconsistencies in the treatment of speaker names were fixed.
Page 8: “extreamly full” changed to “extremely full”
Page 16: The missing catchword “the” from the previous page was added before
“colour of Madeira wine”.
Page 22: “he ingredients” changed to “the ingredients”
Page 26: “gentletlemen” changed to “gentlemen”
Page 39 & 69: “administred” changed to “administered”
*** END OF THE PROJECT GUTENBERG EBOOK THE TRYAL OF
MR. DANIEL SUTTON, FOR THE HIGH CRIME OF PRESERVING
THE LIVES OF HIS MAJESTY'S LIEGE SUBJECTS, BY MEANS
OF INOCULATION ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying copyright
royalties. Special rules, set forth in the General Terms of Use part of
this license, apply to copying and distributing Project Gutenberg™
electronic works to protect the PROJECT GUTENBERG™ concept
and trademark. Project Gutenberg is a registered trademark, and
may not be used if you charge for an eBook, except by following the
terms of the trademark license, including paying royalties for use of
the Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is very
easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund from
the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law in
the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms of
this agreement by keeping this work in the same format with its
attached full Project Gutenberg™ License when you share it without
charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the terms
of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears, or
with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
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.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning of
this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1 with
active links or immediate access to the full terms of the Project
Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or expense
to the user, provide a copy, a means of exporting a copy, or a means
of obtaining a copy upon request, of the work in its original “Plain
Vanilla ASCII” or other form. Any alternate format must include the
full Project Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in paragraph
1.F.3, the Project Gutenberg Literary Archive Foundation, the owner
of the Project Gutenberg™ trademark, and any other party
distributing a Project Gutenberg™ electronic work under this
agreement, disclaim all liability to you for damages, costs and
expenses, including legal fees. YOU AGREE THAT YOU HAVE NO
REMEDIES FOR NEGLIGENCE, STRICT LIABILITY, BREACH OF
WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE
PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE
FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving it,
you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or entity
that provided you with the defective work may elect to provide a
replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.
1.F.6. INDEMNITY - You agree to indemnify and hold the
Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and distribution
of Project Gutenberg™ electronic works, harmless from all liability,
costs and expenses, including legal fees, that arise directly or
indirectly from any of the following which you do or cause to occur:
(a) distribution of this or any Project Gutenberg™ work, (b)
alteration, modification, or additions or deletions to any Project
Gutenberg™ work, and (c) any Defect you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many small
donations ($1 to $5,000) are particularly important to maintaining tax
exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.

Project Gutenberg™ eBooks are often created from several printed


editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like