Introducing
The Slant team built an AI & it’s awesome
Find the best product instantly
Add to Chrome
Add to Edge
Add to Firefox
Add to Opera
Add to Brave
Add to Safari
Try it now
4.7 star rating
0
What is the best alternative to Whitesmiths style?
Ad
Ad
Allman Style
All
3
Experiences
Pros
2
Cons
1
Top
Pro
The block of code is disconnected from the control statement
The block of code itself is disconnected from the control statement which allows developers to comment out or remove entirely a control statement without having a large risk of encountering syntax errors because of extra or missing braces.
See More
Top
Con
Uses more vertical space than other styles
Since each bracket is its own line, the Allman style takes more vertical space than other indent styles. This is one of the reasons that a lot of book authors do not prefer to use Allman style in their texts.
See More
Top
Pro
Easy to find matching braces
The code is clearly set apart from the statement by lines that are almost completely whitespace and the fact that the opening braces line up in the same column as the closing braces makes it easier to match them.
See More
Hide
Get it
here
65
2
K&R (Kernighan & Ritchie) Style
All
6
Experiences
Pros
4
Cons
2
Top
Pro
Consumes minimal vertical space while keeping opening/closing syntax of code blocks on separate lines from their contents
Ensuring that control structures don't share lines with the content they define is important. Lines are the "boxes" or categories into which related syntax goes. In the case of a code block, all the syntax related to a given statement goes on the same line. This not only helps visual comprehension, but ensures that line-wise operations (user inputs like a triple-click or middle button click to select a line, delete a line, cut a line, duplicate a line, etc.) remain meaningful and effective.
See More
Top
Con
May be hard to insert new lines inside statements if there are no braces
The K&R style uses braces only when necessary. So for example: if(condition) doSomething(); But this can be annoying if you need to put something inside that if statement, because you have to go and add braces to make sure that will be grouped correctly with the statement that was before.
See More
Top
Pro
Size symmetry between the opening/closing of clode blocks
Symmetry in size is important because it provides a visual cue that two things are similar in effect/importance. For example, in written text, lines of a paragraph are the same space apart. The space between paragraphs is larger, but also the same between each. The space between subsections, sections and chapters are progressively larger still. The space between things indicates their relatedness, and helps the reader to implicitly grasp the relationships between elements in the document.
See More
Top
Con
Hard to read when the opening statement has multiple lines
If the opening block statement has multiple lines, it really decreases the code legibility because now you have your code block mixed with the opening statement.
See More
Top
Pro
No meaningless lines avoids artificial distance between related things
Each line tells the reader something they wouldn't otherwise know, and they can therefore progress from line to line next gathering new information at each without pausing at lines which only contain a brace indicating that a code block is about to begin or just ended.
See More
Top
Pro
No space is wasted with the opening brace
With this style, one of the advantages is that the opening brace does not take a whole line for itself, wasting a lot of space. The closing brace though is indented on the same level as the control statement it belongs to, making it easier to understand which block of code it's closing.
See More
Hide
FREE
19
6
Built By the Slant team
Find the best product instantly.
4.7 star rating
Add to Chrome
Add to Edge
Add to Firefox
Add to Opera
Add to Brave
Add to Safari
Try it now - it's free
{}
undefined
url next
price drop