Programming language · MIT license

Code you can read. Errors you can act on.

pin is a programming language with indented syntax. It compiles to TypeScript, so its output runs wherever TypeScript runs. Each idea has one spelling, and many compile errors tell you what to change.

One spelling for each idea

A name is a line with an equals sign. Strings take values with #{...}. A comprehension builds a list in one line.

name = "Ada"
line = "#{name} has #{3 * 2} tickets"
squares = [n * n for n in [1 .. 10] when n % 2 is 0]
console.log(line)

There is no second way to write the same line. The reader learns each idea once.

Immutable by default

A plain name cannot change. Write mut when a value must change, and the reader knows where to look.

x = 1
x = 2
Compiler message2:1: x is an immutable binding and cannot be reassigned; declare it with mut x = ... to allow reassignment

Errors that say what to do next

Each compile error names its line, and many also state the fix. The message below comes from the compiler, not from this page.

price = regex:
  \d+
Compiler message2:3: a regex row needs a pattern and then a name, like \d+ digits

Regex that checks its own examples

A regex block names each part of a pattern. Its matches and rejects lines run when the program compiles, so a wrong pattern stops the build.

price = regex:
  \$?                     dollar
  \d{1,3}(?:,\d{3})+|\d+  amount
  (?:\.\d{2})?            cents

  matches "$1,249.50" "42"
  rejects "1,2345" "$"

Output you can ship

pin compiles to TypeScript with source maps and a .d.ts file, so TypeScript callers see typed signatures. Plugins for Vite, Rollup, webpack and esbuild import .pin files like any other module.

TypeScript

Readable output, source maps, and a .d.ts file for every module.

WebAssembly

Mark a numeric function @wasm to compile it to WebAssembly.

Bundlers

Vite, Rollup, webpack and esbuild plugins are in the repository.

Specification

Every rule is a scenario, and each scenario is written in one file: language.md.

What pin does not have yet

pin has no editor extension and no language server. It has no published benchmark against TypeScript, and no published users. Read the status page for the full list.