© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
J. BartlettProgramming for Absolute Beginnershttps://doi.org/10.1007/978-1-4842-8751-4_1

1. Introduction

Jonathan Bartlett1  
(1)
Tulsa, OK, USA
 

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 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!

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.

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!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.17.91