[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Search] [Home]
Board
Settings Home
/g/ - Technology


Thread archived.
You cannot reply anymore.



File: FB_IMG_1555625820807.jpg (13 KB, 500x652)
13 KB
13 KB JPG
>giving a curly bracket its own line
>>
>>70974336
Pretty common practice that increases readability without any negative consequences on compiled languages.
>>
File: yash.png (407 KB, 921x458)
407 KB
407 KB PNG
>>70974336
plz
>>
>>70974342
it's a waste of space for something that adds negligible results in readability. the bracket isn't any less visible when next to the main function.
>>
not putting curlies on their own line is something pajeets do to make their java spaghetti code seem less bloated
>>
>>70974358
only a pajeet would use the term pajeet to cause a shitstorm since they live in shit all the time, pajeet. your poo tactics won't work here.
>>
>>70974336
Stop being so childishly picky
>>
File: qt.png (103 KB, 212x198)
103 KB
103 KB PNG
>>70974358
Curlies are on new lines for: structs, classes, objects, functions

Curlies are not on new lines for: if, else, while, do..while, try, catch, finally, etc.
>>
>>70974361
>>70974358
I sit on the toilet as I read this
>>
File: 1468811698955.jpg (6 KB, 220x250)
6 KB
6 KB JPG
>>70974389
Number 1 or number 2?
>>
>>70974350
>its a waste of space
Which means NOTHING.
>>
File: 1495590818034.jpg (162 KB, 725x725)
162 KB
162 KB JPG
>>70974458
If you were a curly bracket would you fuck a curly bracket? Also, would you be the start or end curly bracket?
>>
>>70974336
It depends on what language you're using and whether you care about following their general practices.

For microsoft platforms (C++, C, C#) coding style favors next line. Most other languages do same line. but even then companies do whatever the hell they want and collaborators on a project should just stick to the consistency of the rest of the code.

it's that simple. now stop pretending it's this le epic war you tards
>>
new line makes it more consistent and beautiful for me, but i'm fine either way, really depends on company's internal coding standards
>>
>>70974395
>he sits down for number 2
>>
>>70974635
If Carmack jumped off a bridge, would you do it?
>>
>>70974349
sorry but python is not a programming language
try again
>>
>>70974342
>increases readability
How?
>>
>>70974644
You can't sit down if you use designated street.
>>
>>70974721
I think it leads to better spacing and clearer structure consistency. Along with a consistent indentation it makes it easier to read the code and modify it.
>>
>herding whatever square/round/curly brackets you can into their own line
>>
>>70974395
Had a nice shit thanks.
>>
>>70974336
Whitesmiths style all day erry day
>>
>>70974721
Clearer notation of where the beginning and ends of blocks of code are.
>>
>>70974336
>line is something pajeets do to mak
Your brain recognizes shapes first, symmetrical shapes in particular. You read the words second, maybe third or fourth.
The placement of the bracket, on it's own line, is arguably more important for reading the code, than the actual code.

These other annons can go practice writing search trees or something.
>>
>>70974336
Curly braces are for faggots. All you need is (begin ...)
>>
{ if(foo):
bar();
}


heres the solution that satisfies both camps
>>
>hav to add one more statement
>4got brackets
>>
>>70975814
It's like saying that futanari satisfies both homo and hetero.
>>
>>70975919
I wasn't very serious about it but it's been a while since I saw such a perfect analogy
>>
>>70974336
1TBS only!
>>
if(condition) {
<code>
}

This is the best looking way.
>>
>The other issue that always comes up in C styling is the placement of braces. Unlike the indent size, there are few technical reasons to choose one placement strategy over the other, but the preferred way, as shown to us by the prophets Kernighan and Ritchie, is to put the opening brace last on the line, and put the closing brace first, thusly:
if (x is true) {
we do y
}


>However, there is one special case, namely functions: they have the opening brace at the beginning of the next line, thus:
int function(int x)
{
body of function
}
>>
>if condition is so long that you have to linebreak inside the parentheses, fucking up the appearance of your code
FUCK
>>
int function(int x){
//that's how it's done.
}


If you disagree with this, you're a fag.
>>
>>70974644
You shit standing? Respect.
>>
>>70976572
>technical reasons
Compiler doesn't care. But go ahead, surprise me.
>>
>>70976826
fn function(x: i32) -> i32 {
// The Chad Way
}
>>
>>70977369
That's literally taken from the Linux kernel coding style.
>>
if condition then
branch
else
branch
end
>>
>>70977369
Size of the standard terminal in ancient times.
>>
I got bullied into doing
int function()
{ return 0;
}
>>
>>70974349
>using a phone to take a screenshot
>>
>>70977480
based lua
>>
>>70974336
not having to, ever, cos i use python
>>
Honestly, i cant fucking stand people who put the curly brace on the same line.

>Bbut it takes up less space
FUCK YOU you dumb cunt programming is not about using as little space as possible its about writing READABLE code.

>It doesn't matter because the compiler dont care anyways
FUCK YOU TOO you are just as dumb as the first guy. IT ABSOLUTELY FUCKING MATTERS.

Readability should be above all else (even performance in most cases) and a bracket on a newline is both symmetrical AND it makes your code more organized.

People who put the bracket on the same line are the people who was taught to do it that way when they first began programming and now are too arrogant to admit that its inferior.
>>
>>70974545
That explains why I only ever see that in Visual Studio shops
>>
>>70974545
Except in Razor views where on line is preferred to reduce whitespace in the resulting HTML.

Either way is fine just stick with it.
>>
>>70974350
>waste of space
rate my new program, its space efficient and everything!
int n=13;int main(void){for(int i=4;i<n&&i>3;++i)if(i%n==2) printf("%d mod %d is %d",i,n,i%n);return 1;return 0;}

no wasted space!
>>
>>70974721
You can easily see blocks of code as you scroll around, without even needing to try, best advantage imo
>>
>>70975814
>>70975919
>>70975933
I haven't kek'd this hard in ages
>>
>>70978956
Now THIS is a top meme.
>>
>>70977480
what is the purpose of then? its literally bloat
>>
>>70980060
its useful as an optional keyword because it helps maintain clarity for one-liners
>>
>>70979965
>throwing a hissyfit because someone made a fair point

let me guess. you're a woman?
>>
>>70979965
aids/10
>>
>people claiming giving it a line makes your code readable

instant sign that nobody here codes. it makes zero difference.
>>
Opening curly brackets for code blocks I put on the same line.
But opening curly brackets for objects I put on a separate line.

Is this weird?
>>
>>70974350
Function declarations and conditions look the same as other code when you are speed reading.
If braces are at the end of a line i have to move my eyes over to see them interrupting flow.
>>
if(foo){
//you're a faggot if you don't do it like this
}
>>
>>70980081
>>70980090
>aids
>fair point
its still shitposting even if you're being ironic
>>
>>70974336
The superior way:

ret_t
fname(arg_t name) {
if (condition) {
// do work
} else {

}
}
>>
>>70974458
Means you lose readability because you have to scroll more.
Ideally every function should fit on one screen for maximum readability, which becomes a lot harder when you're wasting screen real estate on student form nonsense.
>>
>>70980120
if you need brackets to interrupt your reading flow, then you're likely reading at a pace where you aren't gonna catch errors or grasp what to do.
>>
File: 323.jpg (25 KB, 500x378)
25 KB
25 KB JPG
>>70980193
most likely bait but still
>>
>>70976826
>>70980189
>>
>>70980221
how is what he said is bait? being able to see the function as a whole on one page is more readable than having to scroll up and down repeatedly. is your IQ in the negative range or something?
>>
>>70980221
>Hurrrr depr I am retarded

This is why nobody wants to hire you, now you know.
>>
>>70980266
if(1 > 2)
{
Console.WriteLine("C#");
}
else
{
Console.WriteLine("is");
}
// Redundant impossible boolean case removed.

Memes aside, I've come to really enjoy the C# (with brackets) and python (without brackets) way of handling it.
>>
>>70980257
>>70980304
see
>>70979965
how readable is that?

Its true you should try to avoid big functions, but thats because big complex function lack reusability. Not because they make you have to fucking scroll more.
>>
>>70980343
Oh shit you really are retarded.
I am sorry.

We did not say put all the code on a single line.
>>
>>70974336
>>
>>70974350
>it's a waste of space
whitespace doesn't use resources, you retarded faggot.
>>
>>70980478
screen space is a resource
>>
>>70980511
In that case, it's an effective use of a resource since you're utilizing screen space for readability and not cramming it all into a corner so you can post another shitty screenshot on /wsg/, you faggot.
>>
>>70980386
you're implying that if a function takes up more space than whats available on the screen then you should make the code more compact in order to fit.

I'm showing you that compact code makes something much less readable.
>>
>>70974336
>giving an independent syntactic element its own line
lrn2grammar
>>
>>70975814
if only emacs could be made to understand horstmann style.
>>
>>70980578
inb4
>hurrrrr thats not what im imlying
>hurrr in that case you should split the function up into multiple functions hurrr

You were literally advocating for using brackets on the same line (a more compact style convention). So that IS what you are implying.
>>
>>70980543
except you're expanding the amount of scrolling around you're doing just to see the full extent of your code, you double faggot.
>>
>>70980445
public boolean passed(char[] answers, char[] correctAnswers){
int correct = 0;
for(int i = 0; i < 20; i++) if(answers[i] == correctAnswers[i]) correct++;
if(correct >= 15) return true;
else return false;
>>
>>70980641
yeah but then when shit gets more complex your lines will be like 100 characters wide
>>
>>70977422
>beginning lines with spaghet
>hiding return values at the end of lines
>never used text proc in his life
based bootcamp coder
>>
>>70980189
>return type on separate line
Always hated that in GNU style
>>
>>70980060
it ends the conditional expression. it's just a nice looking ";" really.
>>
>>70974336
{
>>
>>70980689
you can grep for function names that way.

> grep -re '^func_name' src/
>>
>>70980689
thats kernel style. it's so you can `grep ^funcname *.c` and find exactly where the function is defined. `/^funcname` zips straight to the definition in vim. forward declarations are normal `type funcname (paramlist);`
>>
>>70974336
There's nothing wrong with legibility. There's no limit on how many lines you can have, and you can always scroll.
>>
File: CambridgeNights.jpg (26 KB, 480x365)
26 KB
26 KB JPG
>>70976572
K&R indentation was inherited from BCPL.
Like many profoundly homosexual aspects of Anglosphere culture, it originated in Cambridge.

It's a flithy, filthy perversion and anyone who promotes it will burn in hell.
>>
>>70980618
(defun horstman-style-curly-brace ()
(insert-char ?\s))
(global-set-key (kbd "{") 'horstman-style-curly-brace)

You're welcome
>>
>>70974336
what's the story behind that picture?
>>
>>70981840
circa 2012, jamal kang is using his black magic to curse the fools who stole his bucket of chicken wings.
>>
>all these retards saying "it increases legibility"
it decreases legibility

imagine a book where every "a" and "the" and "it" gets its own line. there, you have allman bracing.
>>
>>70980221
"every function should ideally be less than one screen in length" is in MISRA and JPL and Linux programming standards. it's reasonable.
>>
>>70982583
A better example would be a name of the chapter separated by an empty line.
And that totally makes sense.
>>
static Conv*
protoclone(Proto *p, char *user, int nfd)
{
Conv *c, **pp, **ep, **np;
int maxconv;

c = 0;
qlock(&p->l);
if(waserror()){
qunlock(&p->l);
nexterror();
}
ep = &p->conv[p->nc];
for(pp = p->conv; pp < ep; pp++){
c = *pp;
if(c == 0){
c = newconv(p, pp);
break;
}
if(canqlock(&c->l)){
if(c->inuse == 0)
break;
qunlock(&c->l);
}
}
if(pp >= ep) {
if(p->nc >= MAXCONV){
qunlock(&p->l);
poperror();
return 0;
}
maxconv = 2 * p->nc;
if(maxconv > MAXCONV)
maxconv = MAXCONV;
np = realloc(p->conv, sizeof(Conv*) * maxconv);
if(np == nil)
error(Enomem);
p->conv = np;
pp = &p->conv[p->nc];
memset(pp, 0, sizeof(Conv*)*(maxconv - p->nc));
p->nc = maxconv;
c = newconv(p, pp);
}

c->inuse = 1;
kstrdup(&c->owner, user);
c->perm = 0660;
c->state = Idle;
ipmove(c->laddr, IPnoaddr);
ipmove(c->raddr, IPnoaddr);
c->lport = 0;
c->rport = 0;
c->restricted = 0;
c->headers = 0;
c->sfd = nfd;
if(nfd == -1)
c->sfd = so_socket(p->stype);

qunlock(&c->l);
qunlock(&p->l);
poperror();
return c;
}
>>
>>70982651
What sort of bizarre code do work with where blocks are as commonplace as chapter beginnings?
>>
>>70974342
this
>>
>>70982756
you use c#
>>
File: purplebrain.jpg (10 KB, 223x226)
10 KB
10 KB JPG
>>70974336
>using newlines ever
>>
>>70974336
cool! yet another retarded teen just started using python and can't write code in any other language

we need more of these threads every fucking day
>>
>>70982824
cool! yet another retarded teen just started using C# and can't write code in any other language
>>
>>70982749
It's not about quantity, it's about purpose.
That's the only way your analogy could even work and not be completely ridiculous.
>>
function doShit() 
{
if (condition) { doOtherShit(); }
if (other condition) {
doSomething();
doAnotherThing();
}
}

*sips tea*
>>
>>70982856
It's
- not -
about quantity,
- it's -
about purpose.
- That -
- is -
- the -
only way your analogy could even work
- and -
not
- be -
completely ridiculous.
>>
>>70982868
alright
>>
>>70982940
Argument:
{
It's not about quantity, it's about purpose.
Remark:
{
That's the only way your analogy could even work and not be completely ridiculous.
}
}
>>
>>70982992
Argument: {
It's not about quantity, it's about purpose.
Remark:
That's the only way your analogy could even work and not be completely ridiculous.
}
>>
>>70983020
The first example makes it very easy to see where stuff starts and where it ends at a glance.
You cannot argue against that.
>>
>>70983057
It's right there, it's literally right fucking there.

Scatterbrained code for scatterbrained faggots.
>>
>>70983068
It's actually pretty ironic seeing you redditspace and talking shit about bracket on the separate line.
But i guess you shouldn't expect any kind of consistency from dumb reddirt niggers.
>>
>>70983120
2005 and counting, i have less life than you

suck it redditor
>>
>>70983199
2005 as an year of your birth?
After seeing your arguments and your total inability to speak like normal human being, i would totally believe that.
4chan is 18+ thou.

>no u
Another sick argument.
>>
>>70974336
ahh.. the python "programmer" complaining about trivial, unimportant stuff

not fucking retarded at all
>>
>>70983250
very clever. keep pooing, pajeet



Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.