Indent Style

In computer programming, an indent style is a convention governing the indentation of blocks of code to convey the program's structure. This article largely addresses the C programming language and its descendants, but can be (and frequently is) applied to most other programming languages (especially those in the curly bracket family). Indent style is just one aspect of programming style.

Indentation is not a requirement of most programming languages, where it is used as secondary notation. Rather, programmers indent to better convey the structure of their programs to human readers. In particular, indentation is used to show the relationship between control flow constructs such as conditions or loops and code contained within and outside them. However, some programming languages (such as Python and Occam) use the indentation to determine the structure instead of using braces or keywords.

The size of the indent is usually independent of the style. Many early programs used tab characters for indentation, for simplicity and to save on source file size. Unix editors generally view tabs as equivalent to eight characters, while Macintosh and Microsoft Windows environments would set them to four, creating confusion when code was transferred back and forth. Modern programming editors are now often able to set arbitrary indentation sizes, and will insert the appropriate combination of spaces and tabs. For Ruby, many shell programming languages, and some forms of HTML formatting, two spaces per indent level is generally used.

The issue of using hard tabs or spaces is an ongoing debate in the programming community. Some programmers such as Jamie Zawinski feel that spaces instead of tabs increase cross-platform functionality. Others, such as the writers of the WordPress coding standards, believe the opposite, that hard tabs increase cross-platform functionality.

There are a number of computer programs that automatically correct indent styles as well as the length of indents associated with tabs. A famous one among them is indent, a program included with many Unix-like operating systems. These programs work best for those who use an indent style close to that considered "proper" by their programmers; those who use other styles will more likely become frustrated. indent has only been updated once since 2006 and does not work well either with C++ or GNU extensions to C.

Read more about Indent Style:  K&R Style, Allman Style, BSD KNF Style, Whitesmiths Style, GNU Style, Horstmann Style, Pico Style, Banner Style, Lisp Style, Ratliff Style, Compact Control Readability Style

Famous quotes containing the word style:

    In comedy, the witty style wins out over every mishap of the plot.
    Mason Cooley (b. 1927)