Appendix B. A brief history of the 3 languages


The Go language was designed at Google and officially released in 2009. It was created to improve upon the shortcomings of C/C++. Its guiding principles include simplicity, safety, readability, and minimalism. Of the three languages in this book, it’s the youngest.

Go’s design principle of simplicity means that many features present in other languages (including languages which inspired it) are absent in it, viz:

  1. Generics 1

  2. Different ways to write a loop

  3. Classes (in the C++/Java sense)

  4. Inheritance

  5. Implicit conversion between types

  6. Pointer arithmetic

However, many useful features are part of the core language that aren’t in other languages, such as:

  1. Concurrency

  2. Package management

  3. Formatting (go fmt)

  4. Static code analysis (go vet)

  5. Most significantly for this book: unit testing!

A major source of confusion (and some rancor) is what is the proper name of the language? 2 The official name of the language is simply “Go”, although — probably because this is ironically a difficult thing to Google and because the official website of the language is  — it’s also referred to as “Golang”. I have gone with the official name and called this language Go in this book, with the “G” always capitalized. I hope this doesn’t irk you too much. Look at it this way: if this is the biggest source of our disagreement, we’ve much to be grateful for!

This book uses version 1.16 of Go.


This book uses the flavor of JavaScript that’s provided by Node.js, specifically version 14 or 16 of Node.js. This flavor of JavaScript is mostly compliant with ECMAScript. ECMAScript is a language standard published by Ecma International (formerly ECMA - European Computer Manufacturers Association). The ECMAScript standard evolves relatively fast (compared to say, Java). In fact, the latest version of the standard is officially referred to as “ES.Next”. You have to applaud the energy, enthusiasm, commitment, and focus of a technical committee that incorporates a variable in its standard’s name! 3

It’s important to note that ECMAScript is a standard as well as a language. This is no different from many other languages, such as C++, Java, or Fortran. As of this writing, the most recent updates to the ECMAScript standard are part of what’s called ECMA-262 — “the twelfth edition of the ECMAScript Language Specification”.

JavaScript can be thought of as a dialect of the ECMAScript standard. There are other dialects, too; such as Adobe’s ActionScript and Microsoft’s JScript. However, it’s no exaggeration to say that JavaScript is the most popular and oft-used implementation of ECMAScript, perhaps bordering on a monopoly. Part of this popularity is historical: JavaScript was created in the mid 1990’s by Netscape to provide a way to create dynamic web content by allowing code to run right inside Netscape’s Communicator web browser. JavaScript was the first scripting language to make it to user’s desktop browsers — the first one to go live. (Its original name — LiveScript — pays homage to that bit of history.) In a sense, JavaScript jostled onto the field and got adopted before there was any standard for a web-scripting language. If you excuse a labored sports analogy: JavaScript scored the first goal and got the first applause from spectators before the referee blew the whistle to officially start the game!

By late 1996, when Ecma got to standardizing “a cross-platform scripting technology for creating applications on the Internet and Intranets”, JavaScript was already running inside hundreds of thousands of users’ browsers. In fact, the meeting happened in part because Netscape submitted JavaScript to Ecma for consideration as an industry standard.

In other words: ECMAScript evolved as a standard out of the reality of JavaScript. There is no chicken-and-egg conundrum here: the history is clear on which came first.

History may be boring, but naming things conveniently so we can talk about them is important. Strictly speaking, I should have used “Node.js implementation of ECMAScript” in this book instead of “JavaScript”. However, that would be confusing and way too pedantic. The facts are that:

  • Modern JavaScript supports the ECMAScript standard

  • The name “JavaScript” retains a clear meaning in the minds of many (perhaps most) developers — they know what language is being spoken of when they hear it

  • The Node.js implementation has a very high degree of compliance to the ECMAScript standard 4

For these reasons, I’ve chosen to use “JavaScript” to refer to the thing which in reality is “the Node.js implementation of the ECMAScript 262 standard”. I hope you appreciate and approve of the brevity!

A few features used in this book are particular to Node.js.

The assert module

There are many good testing libraries and frameworks for JavaScript. In alphabetic order: AVA, Jasmine, Jest, Mocha, tape, teenytest, and Unit.js are a few testing frameworks that could have been used to demonstrate TDD in this book. Many of them are very popular — indeed, it may be asked why one or the other of them wasn’t chosen?

Here are my reasons for not choosing any of them.

Syntactical differences

The frameworks, while all capable of providing the support, have quite different syntaxes (stemming from varying design philosophies). Compare the following two tests, for example, each of which compares two strings. Notice the different flavors of the syntactical sugar.

// filename: tape_test.js
// to run test: node tape tape_test.js
let test = require('tape'); 1

test('hello world', function (t) { 2
    t.plan(1); 3
    t.equal('hello', 'world'); 4

The tape library exports a function named Test, which is assigned to a variable named test here


Each test is implemented as a call to test with two parameters, a human-readable name and an anonymous function with one parameter


Number of assertions to run, in this case 1


The thing to assert, a failing comparison in this case

// filename: __test__/jest_test.js 1
// to run test: jest
test('hello world', () => { 2
  expect('hello').toBe('world'); 3

Default location where Jest looks for test files


Each test is implemented as a call to test with two parameters, a human-readable name and an anonymous function with no parameters


The thing to assert, a failing expectation in this case


The Node.js system already includes an assert module which, even though it’s not a full-fledged testing framework, is sufficient to demonstrate the principle of unit testing.

As we saw in several chapters, particularly Chapter 6, using our own test harness kept us close to the code and allowed us to build parts of the test harness using test-driven development. 5


By adopting none of the testing frameworks, the JavaScript code in this book leaves the option open to you: you are free to refactor to any of the frameworks, now that you know the tests inside out.

By keeping the syntax of the tests simple, by staying away from the intricacies of individual frameworks, and by building the (small) test harness ourselves, we know exactly what we need from any testing framework. Therefore, the adoption of any of the aforementioned frameworks (or even other others not mentioned here) becomes conceptually easier.

The module mechanism

The JavaScript module mechanism is discussed in detail in Chapter 6. For historical reasons, support for modules came late to the ECMAScript standard. By the time the ESModules feature was standardized in ES5, there were already many competing standards in existence that defined modules. As is the case for using the assert that’s part of Node.js, this books uses the CommonJS module standard that is also a the default in Node.js.

Chapter 6 describes the other module mechanisms in some detail, including source code for UMD and ESModules.


Python was created by Guido van Rossum at the research institute he was working at, Centrum voor Wiskunde en Informatica (CWI) in Amsterdam. It evolved from an earlier language named ABC. Like many other languages, simplicity was the fulcrum around which the language’s design evolved.6 In the case of Python, simplicity meant incorporating these features:

  1. Scripting language. The need for automating tasks necessitated a language geared towards writing scripts.

  2. Indentation. In marked contrasts with many other languages, Python uses whitespace instead of visible symbols (such as braces {}) to group blocks of code.

  3. “Duck” typing. Variable types aren’t explicitly declared; they’re inferred from the values the variables hold.

  4. Obvious operators. Operators like *, +, -, / work naturally across data types. Some data types don’t support some operators, e.g. strings do not support -.

  5. Extensibility. Programmers can write their own modules and extend the behavior of the language.

  6. Interoperability. Python can import and use modules written in other languages like C.

The “duck” typing and obvious operators allow us to do nifty tricks in Python, as shown in the following code snippet. You may run this using the python REPL directly in your shell: type python3 and hit enter to get the interactive REPL.

>>> arr = ["hello", True, 2.56, 100, 2.5+3.6j, ('Tuple', True)] 1
>>> for v in arr: 2
...   print(v * 2)
hellohello 3
2 4
5.12 5
200 5
(5+7.2j) 5
('Tuple', True, 'Tuple', True) 6

. An array of elements with different types: string, boolean, floating-point number, integer, complex number, and tuple


. Iterating over each element of the array and multiplying it by 2


. String multiplication yields a repeated string


. Boolean True is treated like the number 1 when being multiplied


. Numeric types, including complex numbers, are multiplied according to rules of arithmetic


. A tuple is also multiplied according to arithmetic rules: repeating its elements in order

The traditional implementation of Python, available at its website, is called “CPython”. There are other active implementations as well, viz: . Jython - a Java implementation of Python, intended to run on a JVM. . IronPython - an implementation that runs on the .NET platform. . PyPy - a fast compliant implementation of Python using a Just-in-time (JIT) compiler.

These implementations build on the interoperability feature of Python, allowing Python code to be used alongside code in another language.

One of the biggest change in Python’s history came about in 2008 with the release of Python 3, which is incompatible in significant ways with the preceding Python 2. Python 2 was sunsetted on January 1, 2020: no more updates or patches are planned for Python 2.

This book uses the most recent stable version of Python, 3.9.

1 Support for Generics in Go is a fast evolving feature:

2 “@secretgeek” tweeted this updated version of the late Phil Karlton quote, which does double duty as dev humor: “there are two hard problems in computer science: cache invalidation, naming things, and off-by-one errors!”

3 You could say C++ has a variable in its name too; and one whose value is literally being modified as you read it!

4 Node’s latest versions have a 98% support score for the ECMAScript standard:

5 This practice — of using the very thing you’re making — is often called “eating your own dog food”. It’s a healthy habit, even though it may not sound palatable!

6 This 2003 interview of Guido von Rossum mentions his motivation to seek simplicity in Python’s design.

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

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