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 K&R (Kernighan & Ritchie) 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
Whitesmiths style
All
7
Experiences
Pros
5
Cons
2
Top
Pro
Blocks are set apart from control statements
Like the Allman style, with the Witesmiths style the blocks are clearly set apart from the control statements.
See More
Top
Con
May be confusing to the eye
The braces confuse the focus of the reader's eye and this causes the reader to look longer at the line right after the opening brace and at the line right before the closing brace.
See More
Top
Pro
Indenting the braces makes them feel that they are subordinate to the control statement
Indenting the braces makes them feel that they are subordinate to the control statements. Which helps the reader understand which block belongs to which control statement.
See More
Top
Con
The closing brace does not line up with the corresponding statement
The closing brace does not line up with the statement it belongs to.
See More
Top
Pro
Easy to see how blocks of code belong together.
The fact that the code lines up up with the braces makes this by far and away the easiest style to read. The code flows much more naturally, there is zero doubt about which block the codes belongs to, your eyes are quickly drawn to what belongs where.
See More
Top
Pro
Makes a clear divider on multi line control statements
Sometimes a control statement can take a lot of arguments and go over many lines. It frees your mind from doing the work to separate arguments and code block.
See More
Top
Pro
Indenting Braces removes noise from the vertical line
When scanning vertically through large sections of code to review the code execution flow, having the braces indented means less noise to filter out. The execution flow statements stand alone on the vertical line and are thus far more quickly picked out by the eye.
See More
Hide
See All
Experiences
21
4
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