Foreword
This book teaches the Mar programming language, but it is not a reference manual. It is a book about why.
Mar makes a series of unusual choices. Values cannot be changed after they are created. Functions are not allowed to secretly talk to the network. There is no null, no exceptions, and no floating-point numbers. The user interface is built from a fixed vocabulary instead of HTML and CSS. The backend and the frontend live in the same codebase and compile together.
Each of these choices sounds like a restriction, and each one is. The purpose of this book is to show what you buy with them: whole categories of bugs that stop being possible, a compiler that acts like a careful reviewer, an app that runs on the web, on iOS, and on a server without three teams keeping them in sync.
Who this book is for
You already know how to program. You have shipped things in JavaScript, Python, Java, C#, Go, Ruby, or something like them. You are comfortable with functions, objects or structs, HTTP, and databases.
What we do not assume is any experience with functional programming. Words like “immutability”, “pure function”, and “pattern matching” are explained from zero, always with the same question in mind: what problem does this solve for someone building a real app?
How to read it
- Part I, Thinking in Mar, is the heart of the book. It covers the ideas that make Mar feel different: immutable values, pure functions, expressions, types, and Mar’s unusual choice of only exact numbers,
IntandDecimal, with no floating point. Read it in order. - Part II, The Architecture, explains how those ideas assemble into applications: the Model-View-Update loop on the frontend, and services, entities, tasks, and auth across the stack.
- Part III, The Surface, covers what you see and ship: the UI vocabulary, the canvas and sound modules that power games, and deployment.
- Part IV closes with an honest discussion of trade-offs.
Code samples are real Mar, matching the language as it exists today. When a sample is a fragment, it is a fragment of a shape you will recognize from the chapters before it.
One warning before we start: Mar will occasionally refuse to compile a program you are sure is fine. Stay with it. In almost every case the compiler has found a future 2 a.m. incident and is declining to schedule it.