Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (2 votes)
172 views

Download Complete Programming for Absolute Beginners: Using the JavaScript Programming Language 1st Edition Jonathan Bartlett PDF for All Chapters

JavaScript

Uploaded by

jikisobanafa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
172 views

Download Complete Programming for Absolute Beginners: Using the JavaScript Programming Language 1st Edition Jonathan Bartlett PDF for All Chapters

JavaScript

Uploaded by

jikisobanafa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Download the full version of the ebook at

https://ebookmass.com

Programming for Absolute Beginners: Using the


JavaScript Programming Language 1st Edition
Jonathan Bartlett

https://ebookmass.com/product/programming-for-
absolute-beginners-using-the-javascript-
programming-language-1st-edition-jonathan-
bartlett/

Explore and download more ebook at https://ebookmass.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

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/
testbankdeal.com

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/
testbankdeal.com

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/
testbankdeal.com

The AWK Programming Language, 2nd Edition Aho

https://ebookmass.com/product/the-awk-programming-language-2nd-
edition-aho/

testbankdeal.com
C Programming Absolute Beginner’s Guide (3rd Edition)
Perry

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

testbankdeal.com

Go Programming Language For Dummies 1st Edition Wei-Meng


Lee

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

testbankdeal.com

C Programming for Beginners by Sett John Hafeez


Abdulmutolib

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

testbankdeal.com

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/
testbankdeal.com

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/

testbankdeal.com
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
Visit https://ebookmass.com
now to explore a rich
collection of eBooks and enjoy
exciting offers!
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
Visit https://ebookmass.com
now to explore a rich
collection of eBooks and enjoy
exciting offers!
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
Random documents with unrelated
content Scribd suggests to you:
inspiration; a quintet by Ernst von Dohnányi. Sgambati has written a
quintet without distinction. Mr. Dunhill tells us in his book[83] on
chamber music that there is an excellent quintet by a young British
composer, James Friskin. Moreover the sextet for piano and strings
by Joseph Holbrooke, in which a double bass is added to the
quartet, deserves mention. And among American composers Arthur
Foote and George Chadwick should be mentioned, the one for his
quintet in A minor, opus 38, the other for his quintet in E-flat major,
without opus number.

Only a few piano quartets have been written since those of Brahms
and Dvořák which are significant of any development or even of a
freshness of life. Those of Fauré have already been mentioned as
being perfect in style, but on the whole they seem less original and
less interesting than the quintet by the same composer. Saint-Saëns’
quartet, opus 41, is remarkable for the brilliant treatment of the
pianoforte, and the fine sense of instrumental style which it reveals,
but is on the whole uninteresting and is certainly insignificant
compared with the quartets of Fauré or those of d’Indy and
Chausson. D’Indy’s quartet, opus 7, in A minor is no longer a new
work, nor does it show in any striking way those qualities in French
music which have more recently come to splendid blooming. But it is
carefully wrought and the three movements are moderately
interesting. The second is perhaps the best music, the third is
certainly the most spirited. There is more of the manner though
perhaps less of the spirit of César Franck in Chausson’s quartet in A
major, opus 30.

In the North we come across an early work by Richard Strauss, opus


13, in the form of a pianoforte quartet, which is exceedingly long, but
interesting to the student who wishes to trace the development of
Strauss’ art of self-expression. The pianoforte is not given undue
prominence and the scoring is worthier of more interesting material.
Still farther north one meets with Christian Sinding’s quartet in E
minor, which is chiefly a tour de force for the pianist.
Excepting sonatas for pianoforte and various other instruments, the
great amount of chamber music into which the piano enters consists
of trios, pianoforte quartets and pianoforte quintets. Mention must
not be omitted, however, of Schubert’s quintet for piano and strings
in which the cello is replaced by double bass. The employment of the
air of one of his songs (Die Forelle) as the subject for the variations
in the slow movement has given the work the name Forellen Quintet.
The treatment of the piano in the variations is exceedingly effective.

III
As to sonatas, those for violin and piano are treated elsewhere.
There are too many to be discussed in this chapter. There are fewer
for the cello and the best of these may here be mentioned. Skill in
playing the violoncello was slower to develop than that in playing the
violin. This was probably because the viola da gamba with its six
strings was easier to play and was more in favor as a solo
instrument. The baryton was a kind of viola da gamba with
sympathetic strings stretched under the fingerboard, and even as
late as the maturity of Haydn this instrument was in general favor.
But the tone of the viola da gamba was lighter than that of the
violoncello, and so by the beginning of the eighteenth century the
cello was preferred to the gamba for the bass parts of works like
Corelli’s in concerted style. Little by little it rose into prominence from
this humble position. Meanwhile the immortal suites for the
violoncello alone by Bach had been written. Bach was probably
advised in the handling of the instrument by Abel, who was a famous
gamba player; so that it seems likely that these suites were
conceived for the gamba as much as for the cello.[84] The last of
them, however, was written especially for the viola pomposa, an
instrument which Bach invented himself. This was a small cello with
an extra string tuned to E, a fifth above the A of the cello.

Among composers who wrote expressly for the cello were Giorgio
Antoniotti, who lived in Milan about 1740, and Lanzetti, who was
'cellist to the king of Sardinia between 1730 and 1750. Later the
Italians A. Canavasso and Carlo Ferrari (b. 1730) became famous as
players, and Boccherini also was a brilliant cellist.

However, the cello sprang into its present importance as a solo


instrument largely through the Frenchman Jean Louis Duport (1749-
1819), whose understanding of the instrument led him to a discovery
of those principles of fingering and bowing which have made modern
virtuosity possible. His Essai sur le doigter du violoncelle et la
conduite de l’archet was truly an epoch-making work. That a new
edition was issued as recently as 1902 proves the lasting worth and
stability of his theories.

Frederick William II, King of Prussia, to whom Mozart dedicated


three of his string quartets, was a pupil of Duport’s. Mozart’s
quartets, written with an eye to pleasing the monarch, give special
prominence to the cello. Hence through Duport we approach the
great masters and their works for the cello.

Beethoven wrote five sonatas for cello and piano. The first two, opus
5, were written in 1796, while Beethoven was staying in Berlin,
evidently with the intention of dedicating them to Frederick William II,
and for his own appearance in public with Duport. They are
noticeably finer, or more expressive works, than the early sonatas for
violin, opus 12; perhaps because the cello does not suggest a style
which, empty of meaning, is yet beautiful and effective by reason of
sheer brilliance. The violin sonatas, all of them except the last, are
largely virtuoso music. The cello sonatas are more serious and on
the whole more sober. This may be laid to thoroughly practical
reasons. The cello has not the variety of technical possibilities that
the violin has, nor even in such rapid passages as can be played
upon it can it give a brilliant or carrying tone. By reason of its low
register it can be all too easily overpowered by the piano. Only the
high notes on the A string can make themselves heard above a solid
or resonant accompaniment. Hence if the composer desires to write
a brilliant, showy sonata for pianoforte and cello, he can do so only
by sacrificing all but the topmost registers of the cello. Even at that
the piano is more than likely to put the cello wholly in the shade.

To write effectively for the combination, therefore, and in such a way


as to bring out the variety of resources of the cello, limited as they
may be, one must not write brilliantly, but clearly, in a transparent
and careful style. Of such a style these early sonatas of Beethoven
offer an excellent example, though the music itself sounds today old-
fashioned and formal.

The best of the first sonata, which consists of a long slow


introduction, an allegro, and an allegro vivace, all in F major, is the
last movement. This is in mood a little scherzo, in form a rondo.
Particularly the chief subject is delightfully scored for the two
instruments at the very opening. The second sonata, in G minor,
begins like the first with a long slow introduction, in which the piano
has some elaborate figuration. There follows an allegro molto, rather
a presto, in 3/4 time, the opening theme of which has almost the
spontaneous melodiousness of Schubert. The pianoforte has a great
deal of work in triplets, which are high on the keyboard when the
cello is playing in its lower registers, and only low when the cello is
high enough to escape being overpowered. This constant movement
in triplets will remind one of the first pianoforte sonata. The final
rondo is on the whole less effective than the rondo of the first sonata.
Toward the end, however, there is considerable animation in which
one finds cello and piano taking equal share. The piano has for
many measures groups of rapid accompaniment figures against
which the cello has saucy little phrases in staccato notes. Then the
cello takes up the rolling figures with great effect and the piano has a
capricious and brilliant melody in high registers.

The next sonata, opus 69, in A major, was not written until twelve
years later. A different Beethoven speaks in it. The first theme,
announced at once by the cello alone, gives the key to the spirit of
the work. It is gentle (dolce) in character, but full of a quiet and
moving strength. After giving the first phrase of it alone the cello
holds a long low E, over which the piano lightly completes it. There is
a cadenza for piano, and then, after the piano has given the whole
theme once again, there is a short cadenza for cello, leading to a
short transition at the end of which one finds the singing second
theme. This is first given out by the piano over smooth scales by the
cello, and then the cello takes it up and the piano plays the scales.
Nothing could be more exquisite than the combination of these two
instruments in this altogether lovely sonata, which without effort
permits each in turn or together to reveal its most musical qualities.
Sometimes the cello is low and impressive, strong and independent,
while the piano is lively and sparkling, as in the closing parts of the
first section of the first movement. Again the cello has vigorous
rolling figures that bring out the fullest sonority the instrument is
capable of, while the piano adds the theme against such a vibrant
background, with no fear of drowning the cello, as in the first portions
of the development section.

The scherzo is the second movement, and here again each


instrument is allowed a full expression of its musical powers. The
style is light, the rhythm syncopated. There is fascinating play at
imitations. And in the trio the cello plays in rich double-stops. There
is but a short adagio before the final allegro, only a brief but telling
expression of seriousness, and then the allegro brings to full flower
the quiet, concealed, so to speak, and tranquil happiness of the first
movement.

Finally there are two sonatas, opus 102, which are in every way
representative of the Beethoven of the last pianoforte sonatas and
even the last quartets. The first of these—in C major—Beethoven
himself entitled a ‘free sonata,’ and the form is indeed free, recalling
the form of the A major pianoforte sonata, opus 101, upon which
Beethoven was working at the same time. In spirit, too, it is very like
the A major sonata, but lacks the more obvious melodic charm. The
sonata begins with an andante, in that singing yet mystical style
which characterizes so much of Beethoven’s last work, and the
andante does not end but seems to lose itself, to become absorbed
in a mist of trills, out of which there springs a vigorous allegro vivace,
in the dotted march rhythm which one finds in the later pianoforte
sonatas. After this, a short rhapsodical adagio brings us back to a bit
of the opening andante, which once more trills itself away, seems to
be snuffed out, as it were, by a sudden little phrase which, all
unexpected, announces the beginning of the final rondo.

The second of the two, in D major, is more regular in structure. There


is an allegro con brio in clear form, an adagio, and a final fugue,
following the adagio without pause. In both these sonatas every
trace of the virtuoso has disappeared. Both are fantasies, or poems
of hidden meaning. Because of this mysteriousness, and also
because the lack of all virtuoso elements seems to leave the
combination a little dry, the sonatas are not quite so satisfactory as
the opus 69.

Besides the sonatas Beethoven wrote three sets of variations for


cello and piano, only one of which—on the air Ein Mädchen oder
Weibchen from Mozart’s ‘Magic Flute’—has an opus number. These
are early works and are without special interest or value.

It is remarkable how little chamber music has been written for


pianoforte and cello by subsequent composers. By Schumann there
is only a set of five short pieces, in Volkston, opus 102. Some of
these are charming, but all are, of course, slight. Schumann uses the
cello in very high registers, notably in the first, third, and fourth. In
the second part of the third he even writes sixths for the cello in such
high registers. The low registers are rather neglected, so that the set
is monotonous in color.

Mendelssohn wrote some Variations concertantes, opus 17, for


piano and cello, and two sonatas, opus 45 in B-flat, and opus 58 in
D. The piano predominates in the variations. The second and fourth
are hardly more than piano solos; but in others the cello is effectively
handled. The third, the fifth with its pizzicato, which, by the way
Mendelssohn stood in a fair way to overwhelm entirely by a noisy
piano, and the eighth, with its long held note, later its wide rolling
figures and powerful sixths, account in a measure for the wide
popularity which this work once enjoyed among cellists. But the life
has gone out of it. Of the sonatas little can be said but that they are
generally well scored, and that they display the qualities of the cello
in its various registers. The piano is less well treated, for
Mendelssohn had, after all, little instinct for a variety of pianoforte
effects. The theme in the last movement of the first sonata has
something of a vigorous swing. The chief theme of the first
movement of the second sonata, too, though it will irritate those to
whom Mendelssohn’s mannerisms have become distressing, has a
breadth of line, and rises up quite manfully to its high point. But the
second theme rather proves that there can be too much of a good
thing. The allegretto is not dangerously fascinating, but it has a sort
of charm. Mendelssohn’s treatment of the cello is generally suited to
the salon. He brings out many of its qualities, but in a way which
seems to accentuate the shortcomings of the instrument. In his
hands the cello is a sentimental singer with a small voice.

With Brahms the cello is more an instrument of mystery and gloom.


His fondness for low notes here causes him to write constantly for
the two lower strings, and his sonatas may suffer in the opinion of
some by the lack of a more vehement expression which is in some
measure possible to the upper strings. The first sonata, opus 38, is
in E minor and is more acceptable to the unfamiliar ear than the later
one in F major, opus 99. But the tone of the great part of the E minor
sonata is gloomy, though the second theme of the first movement
has warmth and the allegretto quasi menuetto a certain light
movement. The F major sonata was probably written with the playing
of Robert Hausmann (b. 1852) in mind. Mr. Fuller-Maitland finds in it
a ‘mood of wild energy such as is not frequent in Brahms’ later
works.’ For all the gloominess of the first and the sternness of the
second of these sonatas there is a splendid dignity in both which
must ever give them a firm place in the literature for the violoncello. It
may be that they lose in grace because Brahms has so carefully
shunned any brilliant display; but on the other hand what they lose in
grace is more than made up by what they gain in virility. The
sentimental qualities in the cello have been so much emphasized
that without these sonatas of Brahms, and those of Beethoven, one
might well believe that it had none other than a sugary voice.
Great Violoncellists: Jean Gerardi, David Popper, Pablo
Casals.
Among more modern sonatas only two stand out with any
prominence. One of these is by Grieg. It is in A minor, full of passion
and swing. No doubt it owes its prominence to the charm of the
Norwegian material out of which Grieg has made it. There are
incisive rhythms that make one aware of the strength of the cello.
The piano is a little too prominent in certain parts. Grieg has favored
its brilliance. But nevertheless the sonata is a manly and refreshing
work.

A sonata for cello and piano in F major, opus 6, by Richard Strauss


has been gratefully adopted by cellists. Musically it is neither
profound nor interesting, though there is no lack of technical skill, as
in the fugal parts of the first movement, and though there are some
passages of great beauty. The second theme of the first movement
is what one might call luscious; there is a glorious theme in the last
movement contrasting with the light motives which generally
predominate; and the climax of the slow movement is passionate.
The pianoforte is not well handled, and there is a sameness in
rhythms; but the balance between the two instruments is remarkably
well kept. In the development of second theme material in the first
movement there are passages in which the cello is made boldly and
passionately to sing, and the use of its very low notes in the climax
of the slow movement, as well as the light figures in the last, leave
no doubt as to the variety which is in spite of all possible to it.

There remains only to mention the sonata by Max Reger, opus 78,
two sonatas by Emanuel Moór, one by Guy Ropartz in G minor, two
by Camille Saint-Saëns, opus 32 and opus 123, as among those
which make a partial success of the extremely difficult combination.

If excellent music for cello and piano is so rare, music for the viola
and piano is almost entirely wanting. The two instruments do not go
well together. Practically the only example of the combination in the
works of the great masters is furnished by Schumann’s
Märchenbilder, which are but indifferent music. York Bowen, an
English composer, has considered it worthy of the sonata, and has
written two for it, one in C minor and one in F major. Mr. Benjamin
Dale has also written some agreeable pieces, including a suite and a
fantasy.

IV
There are relatively few works also in which the piano has been
combined with wind instruments. The wind instruments which have
been most employed in chamber music are the flute, oboe, clarinet,
and bassoon. Occasionally there is a short bit for horn, or for English
horn, and rarely something for trumpet or saxophone. No special
combination of these instruments either by themselves or with the
piano has obtained signal favor, and we may therefore confine
ourselves to mentioning with brief notice the various works of the
great masters in turn. We will include likewise here their chamber
works for wind instruments without pianoforte.

Of Haydn’s works we will only mention the two trios for flute and
violin and the octet for two oboes, two clarinets, two horns and two
bassoons. Most of Mozart’s works for wind instruments bear the
mark of some occasion. There are a great many Serenades and
Divertimenti, which can hardly be called representative of his best
and can hardly be distinguished from each other. Among the
interesting works are the concerto for flute and harp (K 299), the trio
for clarinet, viola and piano (K 498), the quintet for pianoforte, oboe,
clarinet, horn and bassoon (K 452), and the quintet for clarinet and
strings (K 581). The trio was composed in Vienna in August, 1786,
and is conspicuous for a fine handling of the viola. The clarinet is not
used at all in the lower registers, lest it interfere with the viola.
Mozart considered the quintet for piano and wind instruments at the
time he wrote it the best thing he had written. It was composed in
March, 1784, for a public concert and was received with great
applause. Jahn wrote of it that from beginning to end it was a true
triumph in the art of recognizing and adapting the peculiar
euphonious quality of each instrument. Doubtless it served as a
model for Beethoven’s composition in the same form.

Mozart was the first among composers to recognize the beauty of


the clarinet. Among his warmest friends was Anton Stadler, an
excellent clarinet player, and the great clarinet quintet was
composed for Stadler and is known as the Stadler quintet. The
clarinet, owing to the peculiar penetrating quality, is somewhat
necessarily treated as a solo instrument; but the background
supplied by the strings is no mere accompaniment. The whole work
shows the finest care and may well rank with the string quintets
among Mozart’s greatest and most pleasing works.

Beethoven’s works for wind instruments in chamber music are not


numerous. In the expression of his forceful and passionate ideas he
demanded a medium of far greater technical ability than he could
ask of the wind players of that day. There is an early trio for piano,
flute and bassoon, written before he left Bonn; an octet in E-flat for
two oboes, two clarinets, two bassoons, and two horns, written in
1792, but published as opus 103; and a few other early works
without value; a sextet for two violins, viola, cello, and two horns,
written in 1795 and not published till 1819, then as opus 81; another
early sextet, opus 71, for two clarinets, two bassoons, and two
horns; and finally the most considerable of his compositions for an
ensemble of wind instruments, the quintet in E-flat major, opus 16,
for piano, oboe, clarinet, horn, and bassoon, the septet in E-flat,
opus 20, for clarinet, horn, bassoon, violin, viola, cello, and double-
bass. The sonata in F, opus 17, for horn and piano was written in a
night, according to a well-known story, for the horn player Punto—
originally Stich—and can hardly be considered as more than a bit of
pot-boiling.

Most of these early works were written for an occasion. Prince


Maximilian Franz, in whose service Beethoven was for a time
employed before he left Bonn and came to Vienna, was especially
fond of wind instruments. His ‘Table-music’ was generally of this kind
and he had in his employ two oboists, two clarinetists, two horn
players, and two players of the bassoon. Beethoven’s early works
therefore may be considered to have been written with these players
in mind. He was sure of having them performed. In later years he
looked with no little scorn upon many of them. Even of the septet,
opus 20, he is reported to have said that there was some natural
feeling in it but little art. And of the early sextet which was published
in 1809 as opus 70 he wrote to his publishers that it was one of his
early pieces and was, moreover, written in a night, that there was
little further to say about it except that it was written by a composer
who had at least produced some better works—though many men
might still consider this the best. Yet it is to be observed that in nearly
all of them Beethoven made the best of the possibilities open to him,
possibilities which were greatly restricted by the general lack of
technical skill in playing wind instruments, and that all show at least
a clear and logical form.

The octet, opus 103, the sextet, opus 81, the sextet, opus 71, and
the quintet, opus 16, are all in the key of E-flat major, a key which is
favorable to all wood-wind instruments. The octet was written, as we
have said, in 1792. Beethoven rearranged it as a string quintet and
in that form it was published in 1796 as opus 4. In its original form
the chief rôle is taken by the oboe, especially in the slow second
movement, which has the touch of a pastoral idyl. The last
movement in rondo form offers the clarinets an opportunity in the first
episode. A Rondino for the same combination of instruments written
about the same time seems to forecast parts of Fidelio. The sextet
for two horns and string quartet is little more than a duet for the
horns with a string accompaniment.

We may pass over the trio for two oboes and English horn, published
as opus 87, and the flute duet written for his friend Degenhart on the
night of August 23, 1792. The sextet, opus 71, which Beethoven said
was written in a night, is none the less written with great care. The
prelude introduction and the cheerful style suggest some happy sort
of serenade music. The melody (bassoon) in the adagio is of great
beauty. There are, among its movements, a minuet and a lively
rondo in march rhythm.
The quintet, opus 16, in which the piano is joined with four
instruments may well have been suggested by Mozart’s quintet in
the same form; though Beethoven was a great pianist and had
already in an earlier trio and a sonata experimented in combining the
pianoforte with wind instruments. The wind instruments are here
treated as an independent group and the part for the piano is
brilliant. There is a richness of ideas throughout which raises the
work above the earlier compositions for wind.

The septet in E-flat, opus 20, for clarinet, horn, bassoon, violin, viola,
cello and double-bass, is undoubtedly the finest of Beethoven’s
works for combinations of wind instruments. It was written just before
1800 and was so full of joy and humor that those who had heard
Beethoven’s other works with a hostile ear were quite won over for
the time being by this. Technically it may be considered the result of
all his previous experiments. It is rather in the manner of a suite.
There is a slow prelude, an allegro con brio, an adagio cantabile, a
tempo di menuetto, which he later arranged for pianoforte and
incorporated in the little sonata, opus 49, No. 1, a theme and
variations, a scherzo, and a final presto, which is preceded by an
introductory andante of great beauty and of more seriousness than is
characteristic of the work as a whole. The success of the work is due
first to the freshness of the ideas, then to the skill with which they are
arranged for the difficult combination of instruments. For Beethoven
has made something of charm out of the very shortcomings of the
wind instruments. The short phrases, the straightforward character of
all the themes and motives, and the general simplicity all show these
necessarily restricted instruments at their very best.

Schubert’s octet for two violins, viola, cello, double-bass, clarinet,


horn, and bassoon is among the most beautiful pieces of chamber
music for the wind instruments. It is the first of Schubert’s
contributions to chamber music which fully reveals his genius.
Mention may also be made of the variations for flute and piano on
the melody of one of his songs Trockene Blumen.
None of the great composers was more appreciative of the clarinet
than Weber. It is made to sound beautifully in all his overtures,
notably in that to ‘Oberon.’
Arnold Schönberg.

After a photo from life (1913)


He wrote two concertos for clarinet and orchestra, and a big sonata
in concerto style, opus 48, for clarinet and piano. Besides these
there is an Air and Variations, opus 33, for clarinet and piano, and a
quintet, opus 34, for clarinet and strings. Weber also wrote a
charming trio, opus 63, for flute, cello, and piano.

Spohr, too, showed a special favor towards the clarinet and he, like
Weber, wrote two concertos for it. Three of Spohr’s works which
were broadly famous in their day and much beloved are the nonet for
strings, flute, oboe, clarinet, horn, and bassoon, opus 31; the octet
for violin, two violas, cello, double-bass, clarinet, and two horns,
opus 32; and the quintet for flute, clarinet, horn, bassoon, and piano.
The two former are delicately scored, but the latter is marred by the
piano. Some idea of the fervor with which Spohr’s music was loved
may be gained from the fact that Chopin, the most selective and
fastidiously critical of all composers, conceived Spohr’s nonet to be
one of the greatest works of music. Doubtless the perfection of style
delighted him, a virtue for which he was willing to forgive many a
weakness. At present Spohr’s music is in danger of being totally
neglected.

Mendelssohn contributed nothing to this branch of chamber music,


and Schumann’s contributions were slight enough. There is a set of
Märchenerzählungen, opus 132, for clarinet, viola, and pianoforte,
which have some romantic charm but no distinction, and three
Romances for oboe. Brahms’ trio for clarinet, violoncello, and piano
has already been mentioned. Besides these he wrote two excellent
sonatas for clarinet and piano, and a quintet for clarinet and strings.
These works are almost unique among Brahms’ compositions for an
unveiled tenderness and sweetness. All three were probably in a
measure inspired by the playing of his friend Professor Mühlfeld,
who even from the orchestra made an impression with his clarinet
upon the memories of those who gathered at the epoch-making
performances at Bayreuth. The quintet, opus 115, is one of the most
poetic and moving of all Brahms’ compositions. The two clarinet
sonatas, one in F minor and one in E-flat major, were published
together in 1896 as opus 120. In these there is the same unusual
tenderness which appeals so directly to the heart in the quintet.

Since the time of Brahms most composers have written something in


small forms for the wind instruments with or without piano or strings.
Most of these have a charm, yet perhaps none is to be distinguished.
One of the most pleasing is Pierné’s Pastorale variée, for flute, oboe,
clarinet, trombone, horn, and two bassoons. But here we have in
truth a small wind orchestra. D’Indy’s Chanson et Danses, opus 50,
two short pieces for flute, two clarinets, horn, and two bassoons,
Fauré’s Nocturne, opus 33, for flute, two oboes, two clarinets, two
horns and two bassoons, and some of the smaller pieces of a
composer little known, J. Mouquet, are representative of the best
that the modern French composers have done in this kind of
chamber music. Debussy’s Rhapsodie, for clarinet and piano, is
evidently a pièce d’occasion. It was written for the Concours at the
Conservatoire. Max Reger’s sonata in A-flat, opus 49, No. 1, for
clarinet and piano, and a concerto for Waldhorn and piano by
Richard Strauss stand out conspicuously among the works of the
Germans. In this country Mr. Charles Martin Loeffler is to be
recognized as one with an unusually keen instinct for the effects of
wind instruments in chamber music. His two Rhapsodies for oboe,
viola, and piano show a delicacy of style that cannot be matched in
work for a similar combination by other composers.
FOOTNOTES:
[82] A few measures after L in the edition published by J. Hamelle, Paris.

[83] ‘Chamber Music, a Treatise for Students,’ by Thomas F. Dunhill. London,


1913.

[84] See Spitta: ‘Johann Sebastian Bach.’

You might also like