Code style discussion

So we have style on the same line:1|try {
2| foo();
3|} catch(FooFuckedUpExeption) {
4| bar();
5|}And we have brackets on their own line:1|try
2|{
3| foo();
4|}
5|catch(FooFuckedUpExeption)
6|{
7| bar();
8|}So when you read line 1 of te first one, you know line 1 opens a try block.
Now what does line 1 of the second style do?line 1 a try
line 2 opens blockWhy woud you use the second style? It's just confusing.
Another example: if (foo) {
bar();
} else {
fizz();
}
if (buzz) {
fizzbuzz();
}

if (foo)
{
bar();
}
else
{
fizz();
}
if (buzz)
{
fizzbuzz();
}You can see in the first style where the first if else logic stops and the second if begins, in the second style this is less clear so you need another newline for readability.

Can we discuss this shit? I'll try to remain civil when i prove newliners wrong.

Attached: python was right using indent as syntax.png (218x483, 7K)

Other urls found in this thread:

kernel.org/doc/html/v4.10/process/coding-style.html
twitter.com/NSFWRedditImage

your shit in unreadable . Go eliminate yourself

I'm laughing uncontrollably

I didn't expect my multi line code blocks to be inline...

Attempt 2

So we have style on the same line:
1|try {
2| foo();
3|} catch(FooFuckedUpExeption) {
4| bar();
5|}

And we have brackets on their own line:

1|try
2|{
3| foo();
4|}
5|catch(FooFuckedUpExeption)
6|{
7| bar();
8|}

So when you read line 1 of te first one, you know line 1 opens a try block.
Now what does line 1 of the second style do?
line 1 a try
line 2 opens block
Why woud you use the second style? It's just confusing.
Another example:

if (foo) {
bar();
} else {
fizz();
}
if (buzz) {
fizzbuzz();
}

if (foo)
{
bar();
}
else
{
fizz();
}
if (buzz)
{
fizzbuzz();
}

You can see in the first style where the first if else logic stops and the second if begins, in the second style this is less clear so you need another newline for readability.

Can we discuss this shit? I'll try to remain civil when i prove newliners wrong.

>python code monkey

I prefer:
if
(
foo
)
{
bar
()
;
}
else
if
(
fizz
)
{
buzz
()
;
}

for maximum readability

either that or:
if
(
foo
) { bar
(); }
else
if (fizz
) {
buzz
()
;}

In the first one, you cannot easily tell where the block ends. In the second one, you put your cursor on the openning bracket, then scroll down until you meet the end bracket. It's clearer, especially when you have nested brackets.

The answer to anything involving braces is follow whichever is the standard for the given language you're working with or the company you're working for. In JavaScript it's standard to put opening braces on the same line as the statement and use 2 spaces for indentation, while in C# it's expected to put braces on newlines and use 4-space indentation. If the given language doesn't have any preferences, just use whichever you want as long as you keep it consistent throughout the codebase.

Here, let me show you the language of practical syntax.
(if foo
'bar
'baz)

If you have one curly bracket on the same line as the declaration, why not have the closing one inline too?
And what do you actually need multiple types of brackets for? The evaluation can always follow the same rules so a distinction isn't really necessary.
And why would you have semicolons at the end of every line of code?

what did you DO user

Attached: Screenshot_20180331_231247.png (1439x599, 63K)

>Now what does line 1 of the second style do?

Personally I was taught the second way ( a seperate line for open/close brackets) in school and college but find my code goes on for pages and pages.

I personally prefer the first method as I see where brackets have opened and I prefer to close them at the end of a line.

So instead I would have
try {
foo();}
catch(FooFuckedUpException){
bar(); }

i.e. not have a seperate line for a bracket.

What language are you writting this in? It's Python syntax, but semicolons are from C....

I don't even use python that often, I'm just saying indent as syntax is a good idea for languages that do not need to be minified. Everyone already indents code.

Could you please not? I'm trying to get the fucking logic behind preferring
line 1 a try
line 2 opens block

Yes you can, we have indentation for that.

>If you have one curly bracket on the same line as the declaration, why not have the closing one inline too?
Because in
try {
foo();
}
line 1 opens a try blok, line 2 calls foo and line 3 closes the block, each line has i'ts own function. and foo();} would be a line that has two unrelated statements.

I was expecting my multi line code blocks to not be inline. I know an other website that does not have this behavior.

How is
try { foo(); }

different from
try(foo(););

?
And how is
try(
foo(
);
);

different from
try{
foo{
}
}

?

As in, what is the practical use for different types of brackets?
If there's a logical distinction between them, why is it necessary?
Why do they need different treatment? Why is just a joke if arguing about this shit makes sense at all?

In what language are brackets and parentheses interchangeable? {} is a block of code and () is a function call, you can place arguments in it.

kernel.org/doc/html/v4.10/process/coding-style.html

Ifs with only one statement should not have braces. Any modern language that doesn't support this is shit.
If there are >1 statements you can actually see well that there is a if block. Newliners are

In lisp there are expressions.
Lists surrounded by parentheses where the first element is a function name and the rest are arguments to the function. The arguments can also be expressions, lists of functions and arguments.
A block of code in a for loop or condition statements is just arguments for loops and conditional tests.

>Tabs are 8 characters, and thus indentations are also 8 characters.
>However, there is one special case, namely functions: they have the opening brace at the beginning of the next line
I disagree

Lisp is very hard to read because it uses parentheses for everything.

Both styles are objectively shit.

try {
foo ();}
catch (
FooFuckedUpExeption ){
bar ();}

What can auto format code like this?
Why woud you place () from the function call on the right?

Here's a larger example for you.

public class Permuter {
private static void Permuter (
int n, char[] a ){
if (
n == 0 ){
System.out.println (
String.valueOf (
a ));}
else {
for (
int i = 0 ;
i

i don't know how to feel about this

if (Boolean){
result;
}
else{
result
}

No.