Thoughts on these? Python is one example, and no this is not a stab against Python I like the language.

What languages have a indentation requirement?

  • 31
    Not really, but I do find people that try to start flamewars annoying though. – Lasse V. Karlsen Sep 24 '10 at 19:23
  • 9
    Proper use of whitespace is invaluable when programming. If you don't indent, why not also omit new lines? Spaces? All formatting? Python I believe is one of the few languages that enforces strict whitespace use, and good for them! I haven't found nearly as many unreadable python programs as I have JS or PHP ones. – Josh K Sep 24 '10 at 20:50
  • @Lasse: Is that an accusation? It was merely a question from someone who has not had to work with any of these on a regular basis but when I do it comes across as peculiar. @Josh, that is a great point. Should be an answer. – Chris Sep 25 '10 at 14:10
  • 1
    @Chris: The way you worded the question is very subjective and there's a history of people who have never actually used python bashing on it because of the whitespace being syntactically relevant. – Daenyth Sep 25 '10 at 14:23
  • 2
    I think the drawback in Python's case is that the lambda was really weak: In a statement-oriented language, your lambda couldn't even have an if because you could only use an expression. In expression-oriented languages like Lisp, where everything can go in an expression, this wasn't an issue. The function naming alternative for Python is a heavy drawback. – Macneil Nov 16 '10 at 15:51

10 Answers 10


In Makefiles, it's annoying. In python, I find it very apropos and it makes the syntax a lot cleaner. I think the thing that makes it better in python is that no special characters are required, the only requirement is that you be consistent. You should be doing it anyway, so you get no cost added by following it.

  • 23
    Just a note to people downvoting: If you notice, the mouseover text for downvote says "This answer is not useful". It doesn't say "I disagree" – Daenyth Sep 24 '10 at 19:43
  • 3
    The problem with makefiles is that whitespace of different sorts is significant, while in Python you can actually look at the screen and see if it looks right. Any language or format where tabs and spaces have inherently different meanings is screwed up. – David Thornley Sep 24 '10 at 20:15
  • @David Thornley: That's what I was getting at. – Daenyth Sep 24 '10 at 20:20
  • Just a note: There is only one downvote (and not from me). That person may have taken issue that you say it's annoying in Makefiles, but OK in Python, without providing any real explanation. E.g., you say it's cleaner, but don't give any examples or backup that claim. – Macneil Nov 16 '10 at 15:53
  • 3
    @David Thornley: You can not always look at python code and "see if it looks right". You can only assume it is right if it looks right, because a tab and 4 spaces will look identical to 12 spaces (assuming 8-wide tab stops). You have to make the assumption the author of the code didn't accidentally (or purposefully) mix tabs and spaces inconsistently. I would be much happier with python if it required indentation only with spaces, and flagged tabs as errors. – Bryan Oakley Dec 21 '11 at 12:21

In general, I'm against bondage and discipline features that are geared towards making it hard to write bad code. However, I don't find that Python's forced indentation fits this mold. The compiler/interpreter needs to know where blocks begin and end somehow, and about the only human-readable way to denote this is with indentation. Therefore, using indentation to denote it to the compiler/interpreter as well is a good example of DRY.

Using curly braces for the compiler/interpreter plus indentation for humans is like writing otherwise inscrutable but excessively commented code. Information is specified once for the compiler/interpreter, then again for humans. It has to be kept in sync manually and becomes almost impossible to understand if it gets out of sync.

  • 6
    +1 For putting the finger on the root to the very issue with tabs, whitespaces, curly braces and intendation. It is answers like this that makes it worth reading this site. – user1041 Dec 4 '10 at 10:35
  • This isn't a discussion about whether it's good or bad. The question simply asks for those languages that use this feature. Python has already been mentioned, so -1. – Bryan Oakley Dec 21 '11 at 12:22
  • @Bryan - the subject is "Do you find languages with indentation requirements cumbersome?" Seems like it's asking about good/bad to me... – Brian Knoblauch Dec 21 '11 at 13:36
  • 1
    @Brian: sorry, the subject changed. When I wrote the comment it was asking which languages, not whether you find them cumbersome. Unfortunately I can't change my vote until your answer is edited. – Bryan Oakley Dec 21 '11 at 13:40

I like Python's indentation rule.

I said this elsewhere and will repeat here, whoever complains about Python in this respect should be asked to maintain poorly indented source code. If you understand how painful it is to read through that kind of source code, you would appreciate this rule.

  • 4
    +1. A huge benefit that people may not notice at first is that all python code looks the same. There's a universal convention in pep8, and most people follow it. Even when they don't, the whitespace rules enforce a certain minimum of readability and it's easy to fix up code that doesn't follow pep8. – Daenyth Sep 25 '10 at 18:41
  • After reading all about the whitespace controversy of Python on this forum, and realizing I was reluctant to give the language a try (because of bad experiences with some editors mixing tabs and spaces), I decided to download a Python IDE (jetbrains.com/pycharm/index.html) for Windows and give that a try, figuring they would do it right. – tcrosley Sep 25 '10 at 19:18
  • 1
    You seem to be assuming that if python didn't use whitespace the way it does that nobody would indent their python code. Good coders don't need a language to force them to indent their code. I've been indenting my code since my FORTRAN days whether the language requires it or not. For the record, I've maintained lots of poorly indented code, I've got about four solid years of professional python under my belt and I still hate the feature even though emacs almost makes it moot (love the language, hate this feature). – Bryan Oakley Dec 21 '11 at 12:25
  • @Bryan Oakley: And why do you hate this feature? – nalply Aug 12 '12 at 7:45
  • @nalply: the short answer is, it makes me less productive because I have to put more effort into writing the code. If I move a block of code to an area with a different amount of indentation it's a pain to re-indent. Also, it's difficult to copy a block of text from the middle of a program and paste it in an interactive prompt. I end up copying it to a temporary buffer, tweaking all of the whitespace, and then pasting it in the prompt. Finally, I sometimes find myself fixing indentation when someone else's editor chooses to insert tabs instead of spaces. – Bryan Oakley Aug 12 '12 at 16:45

I dislike a lot this kind of language requirement.

I think python is a great language but this is keeping me away of it !

For those complaining about not or bad formatted code, I will say: use a code formatter !

I think that this restriction is more invasive than a rule about having parenthesis, using '.' or '->' for member access or using a ';' or a '.' to end a line.

  • +1 for the formatter, and agreed in general. All good text editors have one - for example, to auto-indent an entire file in vim, it's just gg=G or G=gg – Izkata Dec 21 '11 at 19:09
  • 1
    Sometimes you need to do a quick fix on a remote server. Good luck with code formatters in this case. – nalply Aug 12 '12 at 7:46

Old-fashioned FORTRAN and COBOL had indentation requirements based on punch-card layout, which I found annoying. Indentation requirements don't seem to bother me provided I can use all columns, but having to be careful to start a line on column 7 because 6 is for line continuation is awkward.


Haskell do notation is kind of a nice balance here. If you want to do indentation based you may do so. If you want to do semicolons you may do so. Not quite the block structure since that's a different language, but the idea of "use whatever pleases you because this isn't really an important detail" is one I like.


This seems to me purely a matter of preference.

I personally don't like significant whitespace for the following reasons:

  • Mentally, whitespace to me is a "no-op". I don't like the fact that it changes behaviour.
  • Tabs and spaces look the same in an editor, but can have different meanings if whitespace is significant. Nasty!
  • I like the freedom to format my code however I like. Worrying if this will change the semantics of the program is not helpful.
  • I think that visible block delimiters, whether they are {} in C/Java or () in Lisp, are useful additional visual clues as to the structure of the code.
  • -1: The question is asking about which languages do it, not whether it's good or not, or how to work effectively with the feature. – Bryan Oakley Dec 21 '11 at 12:27
  • @Bryan - the question was changed. It was originally "Do you find languages with indentation requirements cumbersome". I've reverted this edit as it seems like pretty bad practice to fundamentally change existing questions :-) – mikera Dec 21 '11 at 13:28
  • yeah, when the fundamental question changes so much it really messes up the voting and comments :-/ – Bryan Oakley Dec 21 '11 at 13:46

You ask for languages that enforce indentation. Python and make have been mentioned. Another one is the esoteric language whitespace.

FORTRAN has also been mentioned in other answers - early versions required that code start in specific columns (or beyond, so it's not precisely the same).

It is my understanding that Haskell also enforces indentation, according to this part of it's specification: "A nested context must be further indented than the enclosing context (n>m). If not, L fails, and the compiler should indicate a layout error."


There is no free lunch; something must be used for a delimiter. Since we use spacing anyway, using EOL,space and tab characters makes sense and reduces clutter.


No. I rarely get bitten by indentation requirements (perhaps because I'm a stickler for detail). I'd indent my code anyway, so it's not a problem. (The only time it's been an issue is with some old Python code I'm working on; the previous developers wrote it with 2-space tabs (ick!), then newer developers created some files with 4-space tabs, and I have my editor set to 4-space tabs, so indentation is kind of a pain in the older files.) I've never had a problem with it in Haskell, either. It's a bit annoying in Makefiles, but I wouldn't say it's "cumbersome".

  • -1: The question is asking about which languages do it, not whether it's good or not, or how to work effectively with the feature. – Bryan Oakley Dec 21 '11 at 12:27
  • 1
    @BryanOakley: When I answered the question (over a year ago), it was simply whether you had issues with such languages. Sorry I wasn't prescient enough to anticipate the future edit for you. – mipadi Dec 21 '11 at 13:34
  • and sorry I was unaware of which version of the question you answered. Don't take it so personal. The answer isn't pertinent to the current wording of the question; it isn't an attack on your character, just a statement of fact. – Bryan Oakley Dec 21 '11 at 13:38

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