Skip to content
wannacode

The language you are learning

Problem

Why JavaScript

There are hundreds of programming languages. Each one is good for something, but not equally good for everything. Before you spend months on one of them, it is fair to know where you will use it.

JavaScript is the language of the web browser. Every browser runs it, and you do not need to install anything:

  • websites: the buttons, menus, forms and everything that changes on the page without reloading it;
  • servers: with Node.js the same language runs outside the browser too, on a server and on your computer;
  • desktop and phone apps: the Visual Studio Code editor, for example, is written in TypeScript (JavaScript with types) and runs as a JavaScript program;
  • the tools of web developers: almost everything used to build a website is written in JavaScript.

JavaScript dates from 1995. Its name sounds like Java, but the two languages have nothing in common apart from a similar syntax.

The idea

From text to program

The program you write is plain text in a file. Here is a whole program:

shop.js
console.log("Order #1024 has been accepted.");
Output
Order #1024 has been accepted.

Yes, that is the whole program: one line. We will get to the words in it in the lesson "Your first program". What matters here is something else: the computer's processor does not understand this text. Something has to translate it.

  1. You write the source code in a file named shop.js.
  2. You run it with the command node shop.js. Node.js checks how the whole file is written and translates it into bytecode. This happens in memory, every time you run the program: there is no separate compile step for you to run.
  3. Node.js runs the bytecode, and it also translates the parts that run often into machine code, so they go faster.

There is a Node.js for Windows, macOS and Linux, and browsers run the same language on their own. That is why you can take shop.js itself to another computer and it runs without any change. This is called platform independence.

console.log("Order #1024 has been accepted.");
Step by step, in words
  1. You write the source code: plain text in the file shop.js.
  2. There is no separate compiler for you to run: Node.js will read the file itself.
  3. So what goes to another computer is shop.js itself, not a compiled file.
  4. The same shop.js goes unchanged to Windows, macOS and Linux.
  5. Node.js on each system checks the file, translates it and runs it. The output is the same.
More precisely, if you are curious
  • The check covers the whole file. If a parenthesis is missing on the second line, the program prints nothing, not even the first line: Node.js stops with a SyntaxError before it runs anything at all. A misspelled name (totl instead of total) is different. That error (ReferenceError) shows up only when the program reaches its line, and the lines above it have already run.
  • Node.js is built on V8, the JavaScript engine of the Chrome browser. V8 translates parts of the program into machine code while it runs, and it optimizes harder the parts that run most often. This is called JIT compilation (just-in-time).
  • Memory. Every program takes up memory for its data. In languages like C, the programmer frees the memory that is no longer needed, and if they forget or get it wrong, the program starts taking more and more memory or crashes. JavaScript does this for you: the garbage collector finds the data the program can no longer reach and frees its memory.

The idea

What you will learn

The course is made of modules. Each module uses only things from the ones before it:

  1. Language basics: variables, input and output, calculations, conditions, loops, arrays, text.
  2. Functions: code you write once and call many times.
  3. Classes and objects: your own types, such as Order or Student.
  4. Inheritance and polymorphism: what several types share, in one place.
  5. Errors and exceptions: what the program does when something goes wrong.
  6. Text and files: working with strings, search patterns (regex) and files.
  7. Collections: arrays, stack, queue, Map, Set.
  8. Modern JavaScript: arrow functions, processing data in steps and the newer features of the language.
  9. Real-world programs: tests, concurrency, networking, databases.

Off the main path there are games and projects: whole programs you build step by step.

In this course JavaScript runs with Node.js, in the terminal, not in a browser page. That way you learn the language itself, without HTML and CSS around it. Working with a page in the browser comes easily after that, because the language is the same.

The idea

How you learn here

Each lesson is a series of cards, one idea per card. It usually starts with a real-world problem, then shows what is really going on, often with an animation next to the code. After that comes a small task: predict the output, fill in what is missing, find the bug. At the end there is an exercise you solve in your own editor, and a short quiz.

Your progress is saved in the browser: the lesson picks up from the card you reached.

The map of the whole course is on the course home page.

Do not skip the exercises. Reading code and writing code are different skills, and the second one comes only from writing.

The idea

Errors are part of the job

Your first programs will often not start. You will forget a quote or a brace, and Node.js will refuse to run the file.

This is not a grade on you. The error message is there to help: it tells you which line the problem is on and what it is. Experienced programmers see these messages every day too. The difference is that they have learned to read them calmly. We will start reading them in the very first lesson with code.

If something will not work for a long time, leave it and come back a bit later. Often you spot the error right away when you look at it again.

In short

In short

  • JavaScript runs in every browser, and with Node.js also on the server and on your computer.
  • You run the source code (shop.js) with node shop.js: Node.js checks the file, translates it and runs it. The same file runs on any system.
  • Memory is freed automatically by the garbage collector.
  • The course is made of modules, and each lesson of cards. The exercises are in your own editor.
  • An error message is help, not a grade.

Next comes getting your computer ready: what to install so you can run your first program.

Made by Ivo Gergov as part of Evo Tech's campaign for accessible programming education ·