Second edition with machine learning, deep learning, LLMs & AI available now! Buy now
« Back to contents

Programming languages

Introduction

What is a programming language?

A programming language is a formal language for writing programs. It defines the syntax you are allowed to write, the semantics that give that syntax meaning and the abstractions available to the programmer.

If that sentence sounded suspiciously neat, don’t worry. The rest of the chapter is about unpacking the words hidden inside it.

A programming language is a language designed for specifying programs. We instruct computers to understand these languages and perform the computations they specify. The branch of computer science that studies programming languages is known as programming language theory (PLT). It sits at a really interesting intersection of computing, linguistics, logic and mathematics.

The standard academic analysis of programming languages generally involves working up from logical first principles. We’ll approach the subject from the other direction by making a survey of a few popular programming languages. We’ll begin by looking at how programming languages can be understood in terms of their syntax and semantics. Then we’ll examine how they can be categorised into different paradigms according to a few important, distinguishing features. Type systems are important and interesting enough to merit their own section at the end of the chapter.

Let’s begin our survey by looking at what Wikipedia has to say about JavaScript, Go and Haskell, three popular and distinctive languages:

JavaScript is a high level, just-in-time compiled, object-oriented programming language that conforms to the ECMAScript specification. JavaScript has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions.

Go is a statically typed, compiled programming language designed at Google … Go is syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style [communicating sequential processes] concurrency.

Haskell is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation.

What’s remarkable about all three of these descriptions is that they are at once highly informative to an experienced reader and utterly baffling to everyone else. By the end of this chapter, you’ll understand every bit of that techno-babble!

Defining a programming language

Programming languages are examples of formal languages: languages defined by a formal specification. They are neat and logical, in

Want the full second edition?

Buy the ebook - $29

Ebook purchase includes PDF and EPUB formats.

Not ready to buy yet?