chapter

menu1. Welcome to Programming

1 Welcome to Programming

1.1 What Programming Actually Is

Programming is the art of giving clear, precise instructions to a computer so it can perform tasks on your behalf. At its core, it’s a conversation—one where you learn to speak in a language the computer understands, and the computer responds by doing exactly what you asked. Not “sort of” what you asked, not what you meant to ask, but precisely what your instructions describe. That precision is what makes programming both powerful and occasionally humbling.

When you write a program, you’re breaking a problem into smaller steps and expressing those steps in a structured, logical way. A recipe is a program. A set of directions is a program. Even a morning routine is a kind of program. The difference is that computers don’t fill in the gaps the way humans do. If a recipe says “cook until done,” a person can figure that out. A computer cannot. It needs explicit steps, in order, with no ambiguity.

This is why programming is more than learning syntax or memorizing commands. It’s learning to think in a way that a computer can follow. You start noticing patterns, designing solutions, and imagining how a machine might interpret your ideas. Over time, you develop a kind of mental toolkit: how to break problems down, how to test your assumptions, how to build something small and expand it piece by piece.

JavaScript, the language we’ll use throughout this book, is a particularly friendly place to begin this journey. It runs in every modern web browser, which means you already have everything you need to start experimenting. You can write a line of code, press Enter, and immediately see the result. That instant feedback loop is one of the reasons JavaScript has become one of the most widely used languages in the world.

But before we dive into the details, hold onto this idea: programming is not about being a genius or memorizing arcane rules. It’s about learning to express ideas clearly, test them, refine them, and build things that didn’t exist before. It’s a creative craft, a problem‑solving discipline, and a surprisingly fun way to make computers work for you.

By the time you finish this book, you won’t just know JavaScript—you’ll understand how to think like a programmer.

1.2 How Computers Think

If programming is learning to communicate with a computer, then it helps to understand the mindset of the thing you’re talking to. And “mindset” is almost a misleading word, because computers don’t think the way people do. They don’t guess, they don’t infer, and they definitely don’t read between the lines. A computer’s version of thinking is closer to following a recipe with absolute, unwavering obedience.

A computer processes information through a long chain of tiny electrical decisions—billions of them every second. Each decision is incredibly simple: yes or no, true or false, on or off. From these microscopic building blocks, everything else emerges: games, websites, spreadsheets, music players, navigation apps, and the entire internet. It’s astonishing how much complexity grows out of such simple roots.

Because computers operate on these strict, binary rules, they require instructions that are equally strict. When you write a program, you’re giving the computer a sequence of steps that must be unambiguous and complete. If you leave out a detail, the computer won’t fill it in for you. If you phrase something vaguely, it won’t interpret your intent. It will do exactly what you wrote—even if that means doing something completely different from what you wanted.

This is why programmers spend so much time breaking problems down. A task that feels obvious to a human—like “sort these names alphabetically”—needs to be expressed as a series of tiny, precise operations the computer can follow. Compare each pair of names. Decide which comes first. Swap them if needed. Repeat until everything is in order. What feels like one action to us becomes dozens or hundreds of micro‑steps to a machine.

The upside is that once a computer understands those steps, it can execute them with incredible speed and consistency. It never gets tired, never gets distracted, and never forgets a detail. That reliability is what makes programming so powerful: you can encode a process once, and the computer will carry it out perfectly every time.

As you learn to program, you’ll start to adopt a bit of this computational way of thinking. You’ll learn to break problems into smaller pieces, to express ideas clearly, and to anticipate edge cases. You’re not trying to think like a computer—you’re learning to think for a computer, giving it the structure it needs to do the work you want.

Once you grasp this, programming stops feeling mysterious. You’re no longer trying to guess what the computer wants. You’re learning how to guide it, step by precise step, toward the results you imagine.

1.3 Why JavaScript Is a Great First Language

Choosing your first programming language is a bit like choosing your first musical instrument. You want something approachable, versatile, and rewarding—something that lets you make real, satisfying progress early on. JavaScript fits that role beautifully, which is why millions of beginners start their programming journey with it.

One of JavaScript’s biggest strengths is its accessibility. You don’t need to install special software or set up a complicated environment. If you have a web browser, you already have everything required to write and run JavaScript. You can open a console, type a line of code, and see the result instantly. That immediate feedback makes learning feel playful rather than intimidating.

JavaScript is also everywhere. It powers the interactive parts of websites, runs on servers, controls mobile apps, automates workflows, and even drives hardware projects. Learning it gives you a passport into many different areas of technology. You can start small—maybe by changing the text on a webpage—and gradually build up to full applications without ever switching languages.

Another reason JavaScript works so well for beginners is its forgiving nature. It doesn’t force you to understand every detail before you can write something useful. You can experiment freely, make mistakes, and learn by doing. At the same time, it’s a language that grows with you. As your skills develop, JavaScript reveals deeper layers: modern syntax, powerful libraries, and sophisticated patterns used by professional developers.

Perhaps most importantly, JavaScript has a massive, welcoming community. If you get stuck, chances are someone else has asked the same question, written a tutorial, or shared a solution. That ecosystem of support makes the learning curve feel far less steep.

By starting with JavaScript, you’re choosing a language that rewards curiosity, encourages experimentation, and opens doors to countless possibilities. It’s not just a tool for building websites—it’s a foundation for understanding how modern software works. And as you’ll see throughout this book, it’s a remarkably fun language to learn.

1.3.1 Beyond the Browser: Where JavaScript Can Run

When most people think of JavaScript, they picture it running inside a web browser, powering buttons, animations, and interactive pages. And that is where JavaScript began. But the language has grown far beyond its original home. Today, JavaScript is a kind of universal toolkit—one that can run in browsers, on servers, inside office documents, in cloud environments, and even on your own computer as a general‑purpose programming language.

This book embraces that wider world. As you learn the fundamentals of programming, you’ll also see how JavaScript adapts to different environments, each with its own strengths and possibilities.

1.3.2 JavaScript Variants and Scripting Platforms

Several modern platforms build on JavaScript to make it more powerful or more specialized:

Google Apps Script

  • A cloud‑based scripting environment that lets you automate and extend Google Workspace apps like Sheets, Docs, Gmail, and Drive. It uses a JavaScript‑like syntax and gives you direct access to Google services through simple APIs. If you’ve ever wished your spreadsheet could email you, or your inbox could organize itself, Apps Script makes that possible.

Microsoft Office Scripts

  • A close cousin to Apps Script, designed for automating Excel on the web. It uses TypeScript (a typed version of JavaScript) and lets you write scripts that manipulate spreadsheets, generate reports, and streamline repetitive tasks inside Microsoft 365.

TypeScript

  • A superset of JavaScript that adds optional static typing. While not a runtime environment on its own, TypeScript has become a major part of modern JavaScript development because it helps catch errors early and makes large projects easier to manage. Many tools—including Office Scripts—use TypeScript under the hood.

These platforms share a common theme: they let you use JavaScript to automate real‑world workflows, often without installing anything. They’re perfect for beginners because they provide immediate, practical results.

1.3.3 JavaScript Beyond the Cloud: Node.js

While browser‑based JavaScript is powerful, it’s limited by design. It can’t access your file system, install software, or interact directly with your operating system. That’s where Node.js comes in.

Node.js is a runtime that lets JavaScript run on your local machine—just like Python, Ruby, or any other general‑purpose language. With Node.js, you can:

  • Read and write files
  • Build command‑line tools
  • Create web servers
  • Work with databases
  • Automate tasks on your computer
  • Build full‑stack applications

Node.js transformed JavaScript from a browser‑only language into a universal programming platform.

1.3.4 Why These Environments Matter

Exploring these different platforms gives you a broader understanding of what programming can do. You’ll see how the same core language—JavaScript—can:

  • Automate your spreadsheets
  • Extend your email
  • Power websites
  • Run servers
  • Build desktop tools
  • Interact with cloud services

Each environment has its own flavor, but they all share the same foundation. Once you understand the fundamentals of programming and JavaScript, you can move between them with surprising ease.

As you progress through this book, you’ll get hands‑on experience with several of these platforms. You’ll learn not just how to write code, but how to choose the right environment for the job—and how JavaScript adapts to meet you wherever you want to build.

1.4 How to Run JavaScript

One of the reasons JavaScript makes such a great first language is that you can run it almost anywhere. You don’t need a special compiler, a powerful computer, or a complicated setup. In fact, you already have everything you need. This section walks you through the main ways to run JavaScript, from the simplest beginner‑friendly options to the more advanced environments you’ll explore later in the book.

1.4.1 Running JavaScript in the Browser Console

Every modern web browser—Chrome, Edge, Firefox, Safari—comes with a built‑in JavaScript console. This is the fastest, easiest way to experiment.

  1. Open any webpage.
  2. Right‑click and choose Inspect or Developer Tools.
  3. Find the Console tab.
  4. Type something like:
    console.log(“Hello from JavaScript!”)
  5. Press Enter and see the result instantly.

The console is perfect for trying out small ideas, testing snippets, or learning the basics without any setup.

A note on semicolons: JavaScript is a member of the computer-program language family called the “C-family languages,” so named because the languages share common syntax conventions that originated with a language called “C.” Many of those languages require a semicolon to separate all statements. In JavaScript, the semicolon is not required to separate statements that appear on different lines. If you want to place two statements on a single line, you can do so by separating them with a semicolon. Because many other of the C-family languages require a semicolon between all statements, many JavaScript examples you find online will have semicolons at the end of each line even though they are not required. This is a stylistic choice. In this book, we will not include semicolons where they are not required to simplify the examples. Ultimately, it is up to you to decide if you want to put semicolons at the end of your JavaScript statements.

1.4.2 Running JavaScript in other Platforms

Throughout this book, you’ll also explore environments that use JavaScript or JavaScript‑like languages to automate real‑world tasks:

  • Online Editors for testing JavaScript on the web (such as JSFiddle and CodePen)
  • On a Web Page for building interactive web sites
  • Google Apps Script for automating Google Workspace
  • Microsoft Office Scripts for automating Excel on the web
  • Cloud‑based runtimes that let you run scripts without managing servers\
  • Node.js allows you to run JavaScript locally on your computer, as opposed to in a browser

Each of these platforms has its own way of running code, but the core language remains familiar.

1.4.3 Choosing the Right Environment

There’s no single “correct” way to run JavaScript. The best environment depends on what you’re trying to do:

  • Quick experiments → Browser console
  • Interactive demos → Online editors
  • Web projects → HTML + JavaScript files
  • Local tools or servers → Node.js
  • Automation → Apps Script or Office Scripts

As you move through this book, you’ll get hands‑on experience with several of these options. By the end, running JavaScript will feel as natural as opening a document or sending an email.

Our first detailed examples will begin in Google Apps Script.