13

Python quite famously uses indentation to syntactically define blocks of code. (See Compound statements in the Python Language Reference). After years of using Python I'm still intrigued by and very fond of this syntax feature.

But I wonder: Apart from Python and its "predecessor"(*) language ABC which other programming languages are out there using indentation for definition of code blocks? Code blocks means here "multiple statements which in some way are treated as one component".

I'm particularly interested in practical programming languages, but esoteric languages might be worth mentioning as well.


(*): "Predecessor" is my choice of word in default of knowing here a better one. Guido van Rossum, the creator of Python, described the relationship between Python and ABC regarding indentation in an interview like this: "The choice of indentation for grouping was not a novel concept in Python; I inherited this from ABC."

halloleo
  • 257
  • 2
  • 5

3 Answers3

24

Wikipedia has an extensive list of languages that use the off-side rule1:

  • ABC
  • Boo
  • BuddyScript
  • Cobra
  • CoffeeScript
  • Converge
  • Curry
  • Elixir (, do: blocks)
  • Elm
  • F# (if #light "off" is not specified)
  • Genie
  • Haskell (only for where, let, do, or case ... of clauses when braces are omitted)
  • Inform 7
  • ISWIM, the abstract language that introduced the rule
  • LiveScript
  • Miranda
  • Nemerle
  • Nim
  • occam
  • PROMAL
  • Python
  • Scheme, when using e.g. SRFI 119
  • Spin
  • XL

1: I've never heard this term before myself.

Bergi
  • 610
  • 3
  • 12
10

There are: Elm, Haskell, its predecessor Miranda and its predecessor ISWIM, YAML where spaces are crucial for syntax and tabs are forbidden, OCCAM, Coffee script and Cokescript both are language to language compilers with JavaScript as target and esoteric Whitespaces.

There is also Agda - interactive theorem prover, which is probably not what you had in mind, but its lexer is very sensitive to white-space.
Makefile, which gathers targets with tab-based intends.

Evil
  • 9,525
  • 11
  • 32
  • 53
4

Make fits your description, even though it probably isn't quite what you have in mind, with its limited syntax and power.

It infamously indicates its code blocks (recipes) with a particular form of whitespace: one tab character. Alternative ways are available (e.g. GNU Make supports using an alternative character), but rarely used in practice.

Another example hovering at the edge is Ansible playbooks. They are specified in YAML, which is heavily indentation dependent. YAML is not a programming language, but Ansible playbooks can be regarded as domain-specific programs.

reinierpost
  • 6,294
  • 1
  • 24
  • 40