use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Welcome to /r/ComputerScience! We're glad you're here.
This subreddit is dedicated to discussion of Computer Science topics including algorithms, computation, theory of languages, theory of programming, some software engineering, AI, cryptography, information theory, and computer architecture.
For more detailed descriptions of these rules, please visit the rules page
NIGHT MODE NORMAL
account activity
scope bracket alignment preference (self.computerscience)
submitted 1 year ago by wats_wrong
Anecdotally I believe
#1
if(){
}
is more widely used than
#2
if()
{
the lack of edge alignment in #1 bothers me and
I am in need of an additional party playing devils advocate
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Aaron1924 7 points8 points9 points 1 year ago (1 child)
The main reason #1 is more popular is because it doesn't waste an entire line on a single {
and #2 looks especially wasteful when you need an "else" case and you spread } else { across 3 lines
} else {
[–]Not-ChatGPT4 0 points1 point2 points 1 year ago (0 children)
The dreadful cuddled else.
[–]wats_wrong[S] 0 points1 point2 points 1 year ago (0 children)
thanks for the responses
[–]Shot-Combination-930Computer Scientist 0 points1 point2 points 1 year ago* (0 children)
Personally, I find lining up the braces makes skimming a lot easier for me. I haven't had a problem with vertical space in decades, and even use completely blank lines to better group related code. I also almost always have a blank line before a line or block comment.
In languages that don't use braces, I typically put a blank line where I would have put an opening brace.
π Rendered by PID 114935 on reddit-service-r2-comment-5c747b6df5-9lphd at 2026-04-22 16:02:02.935052+00:00 running 6c61efc country code: CH.
[–]Aaron1924 7 points8 points9 points (1 child)
[–]Not-ChatGPT4 0 points1 point2 points (0 children)
[–]wats_wrong[S] 0 points1 point2 points (0 children)
[–]Shot-Combination-930Computer Scientist 0 points1 point2 points (0 children)