12
$\begingroup$

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."

$\endgroup$

closed as off-topic by David Richerby, chi, Raphael May 10 at 19:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about computer science, within the scope defined in the help center." – David Richerby, chi, Raphael
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 15
    $\begingroup$ I don't think "please give me a list of programming languages with feature X" is a computer science question. $\endgroup$ – David Richerby May 9 at 20:07
  • 2
    $\begingroup$ Why, there's the Whitespace language itself that requires proper indentation for it's core method of expression. $\endgroup$ – penguin359 May 9 at 23:49
  • 1
    $\begingroup$ Long-form YAML is probably worth mentioning even though it's not a programming language in the strictest sense, as it's probably one of the next most likely languages with this feature for someone to encounter after Python. $\endgroup$ – Austin Hemmelgarn May 10 at 0:51
  • 1
    $\begingroup$ @penguin359 I also thought of Whitespace. It's not an answer to the question because indentation is, afaict, not used to define blocks; but it's certainly the language in which white space is most significant overall. $\endgroup$ – Peter A. Schneider May 10 at 9:34
  • 1
    $\begingroup$ @DavidRicherby Grouping by attribute (i.e. categorization) is definitely a part of science: E.g. an interesting question for a Biology StackExchange could be: "What other animals walk on two legs?" Therefore I consider the above question very appropriate for the Computer Science StackExchange. $\endgroup$ – halloleo May 10 at 16:54
23
$\begingroup$

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.

$\endgroup$
  • 2
    $\begingroup$ The off-side rule is an exciting find! $\endgroup$ – halloleo May 10 at 2:42
  • 3
    $\begingroup$ Don't know if it is a language as you or wikipedia understands it, but Makefiles use indentation too. $\endgroup$ – TheWildHealer May 10 at 7:22
  • $\begingroup$ @TheWildHealer The wikipedia article also has a section with non-programming languages (including stuff like Make, YAML, RST). I didn't quote that because OP asked about programming languages. $\endgroup$ – Bergi May 10 at 10:27
  • $\begingroup$ You are right, next time I'll be sure to open my eyes, thanks. $\endgroup$ – TheWildHealer May 10 at 10:31
10
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ Also Miranda, the language Haskell was based on. $\endgroup$ – kne May 9 at 16:59
  • 1
    $\begingroup$ Agda has a very Haskell-like syntax, and is sensitive to both indentation and spaces: (x-y) is not (x - y)) even if it might not be "practical" enough for the OP. $\endgroup$ – chi May 9 at 18:30
  • 1
    $\begingroup$ Also, CoffeeScript and the hardly-known CokeScript $\endgroup$ – Bergi May 9 at 19:22
  • 5
    $\begingroup$ If YAML counts, then I suppose Makefiles must as well $\endgroup$ – Izkata May 9 at 19:48
  • 1
    $\begingroup$ There is also PureScript. $\endgroup$ – duplode May 9 at 21:35
4
$\begingroup$

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.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.