[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Programming Philosophies

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 69
Thread images: 6

File: file.png (71KB, 626x626px) Image search: [Google]
file.png
71KB, 626x626px
The great debate, which one?

if (myVal > 1) {
// Do Stuff
}

or


if (myVal > 1)
// Do Stuff


>ITT post shit like this that despite looking different do the same
>pick sides
>>
>>57113311
Aaaaand I fucked up the code tags.
>>
>>57113311
no curly braces if the language supports it

also open brace on new lines you fucking animal
>>
>>57113330
Nice, you just created another one faget:
if (myVal > 1) {
// Do Stuff
}


or

if (myVal > 1) 
{
// Do Stuff
}


1st is superior :^)
Also, curly braces masterrace.
>>
>>57113365
>newline or not
I actually don't care. As long as the entire project is consistent. If it's not, then it's pure hell
>>
>>57113524
You can't actually imagine how many people came to me asking how the hell X worked if there was no brackets because they completely overlooked it.
>>
>>57113730
Then those guys are either stupid or new to programming.
>>
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}


VS

print "Hello World!"


Second is for babbies.

First is for real men.
>>
>>57113811
Pls go javafag
>>
>>57113779
It's not a matter of stupidity, it's about overlooking stuff.
People get so used to do shit their own way that they expect something, and when something is missing they filter out the rest of the information.
>>
>>57113839
>Implying Java is bad
>>
>>57113853
True.
>>
>>57113811
Wut, aren't both the same shit except for the following:
- 1st targets the assembly directly (System.out)
- 1st uses println which does a new line, while 2nd uses print which does the same line
- 1st is inside curved brackets (which imo is superior) while 2nd isn't

Shouldn't you had it compared like this?:
println("Hello World!");


VS

print "Hello World!"


Am I being autistic?
Is this actually what you meant?

If so, 1st is superior to 2nd, fuck everyone that doesn't use curved brackets, lot easier to read with them.

Same shit gets on my nerve when people do:
return true;


instead of

return (true);


REEEEEEEEEEEEEEEEEE
>>
>>57113922
>Shouldn't you had it compared like this?:

If you do

println("Hello World!");


It won't compile in Java.

But the second example:

print "Hello World!"


Is a valid Ruby program
>>
>>57113958
wat

Is Java so shitty that it can't handle assembly referencing on a document level?

I don't want to declare it every single time ;_;
>>
>>57114002
In Java 8 there's a way to do it I believe but I'm not familiar.

Generally everything has to be inside a class and a method in Java.

I'm just a beginner so some more knoweldgeable anons can clarify.
>>
>>57113311
OP if you are talking about C, then depends on how you or your team writes multi-line macros.
If the multiline macro has a block of commands, then the first is more readable.
>>
>>57114076
*I actually meant the second of your post
if (test)
/*Do stuff*/
>>
(variable) ? doThis() :  orThisInstead();
>>
>>57113365
K&R
&
R

if (x) {
// Do this
// Do that
}

int shit(int x)
{
// Stuff
return 0;
}
>>
>>57113922
>return true; instead of return (true);
REEE yourself, return isn't a function call, I don't put arbitrary parentheses around values.
>>
File: HLG.gif (194KB, 228x160px) Image search: [Google]
HLG.gif
194KB, 228x160px
>not aligning your braces
>>
>>57114084
goto fail;
>>
File: DIE.jpg (141KB, 502x494px) Image search: [Google]
DIE.jpg
141KB, 502x494px
>>57114091
>>
>>57114131
>He doesn't like K&R
Protip: Linux (the kernel), the biggest free software project in the world, uses K&R syntax
Get with the times, gramps
>>
>>57114091
explain this
>>
>>57114144
Inconsistent bracialism. No explanation, only excuses.
>>
>>57114144
functions are different (you can't nest them in [non-GNU-extended] C)
>>
Not using the superior style:
if (x)
{
/*Do stuff*/
}
int
func (int x)
{
return 0;
}
>>
>>57113922
So you want to return a 1-element tuple of your return value?

def pooFunction():
poo_location = 'loo'
return (poo_location)


If you want to know what the second letter of the location where your poo has gone is:
pooFunction()[1]

will result in an index out of bounds error because the tuple (return value of pooFunction) only has one element with the index 0. So you'll need to
pooFunction()[0][1]
.
>>
>>57114243
>not using the actual superior style
if (x) {  /*Do stuff*/ }int func (int x) {  return 0; }
]/code]
>>
File: 1465775935152.jpg (17KB, 378x378px) Image search: [Google]
1465775935152.jpg
17KB, 378x378px
>>57114259
>]/code]
>>
>>57114268
not my fault, it's because of the shitty italian setup
>>
opening brace on new line is cancer. It's visually repulsive.
>>
>wasting an entire line just for {
>>
>>57114253
Oneples aren't declared like that, need a trailing comma inside the brace.
>>
>>57114311
Fugg. In my defence, I'm tired as fuck.
>>
>>57114090
Ternary masterrace
>>
>>57114354
Hard to read though, sometimes it's the best shit ever, but definitely shouldn't be used all the time.
>>
my professor was kind of absent minded today at the beggining of the lecture so he used his password as his username. I don't think anyone really cared enough at that point of the class but basically I have his password atm.

What should I do with it? I was thinking some meme announcement
>>
>>57114387
Wrong thread buddy.
>>
>>57114387
Respectfully inform him of his mistake so he can change it
>>
>>57114259
you joke, but
if (one_liner) { single_function() }


actually superior format as long as you only have the one line of code in there
>>
>>57114387
This
>>57114412
>>
>>57114440
I usually do:
if (one_liner) single_function()


I have to admit that yours is easier to read though.
>>
button.Click += (se, ev) =>
{
// Do stuff
};


VS

button.Click += new RoutedEventHandler (button_Click);

private void button_Click(object sender, RoutedEventArgs e)
{
// Do stuff
}


:^)
>>
>>57114299

>Jenkins, you fucking idiot, we're out of lines! You wasted them all on curly braces! We're ruined!
>>
I tend to use a new line for curly braces in a function declaration, but curly brace on the same line for conditionals, etc. I.E.


def some_function(x)
{
if (x == a_number){
//do the thing
}
else{
//don't do the thing
}
}

>>
>>57114847
I do this as well. I think I read somewhere it was the convention.
>>
>>57114440

Why bother enclosing the single function in curly braces?
>>
>>57114091
>not Stroustrup
wew lad
>>
>>57113311
if (myVal > 1) // Do Stuff;
// Do Stuff And Confuse The Maintainer;
>>
>>57113311
Second, clearer and way better for further developing of the code.

>>57113365
first, much more aesthetic

>>57113811
epic

>>57113922
return is not a function

>>57114090
good for small chunks of code / codegolfing

>>57114091
>not being consistent

>>57114536
depends on the length and reusability of the code

>>57114847
K&R

>no cuddled elses

>>57118001
patrician
>>
>>57113311
Second literally caused Heartbleed. I honestly prefer it, but I see why first can be better.
>>
>>57119586

This is why I put braces around everything.
>>
int
main(int argc, char *argv[])
{
if(one_line)
foo();

if(multi_line) {
bar();
foobar();
}

return 0;
}
>>
<?php 
if(expression):
// process
endif;
?>
>>
>not
> cond
>{ // whatever
>}
>>
>>57114144
>>57114091
That style arose from the "old" style function definitions in C:
int main(argc, argv)
int argc;
char *argv[];
{
if (argc != 2) {
/* do stuff */
}

return 0;
}

and stuck around, even after ANSI functions were introduced.

The rationale these days is that functions in C are "special" and do not nest, so it's fine to treat them differently.
>>
>>57113330
Heretic
>>
>>57113311
>Programming
>image of xml syntax
When will this meme die¿
>>
>>57122307
what about XSLT?
>>
You should use braces even if they are optional Except for Python obviously
>>
File: 1476753296212.jpg (301KB, 782x788px) Image search: [Google]
1476753296212.jpg
301KB, 782x788px
>>57113330
The CTO decrees that curly braces are mandatory, Anon.
>>
File: image.jpg (16KB, 261x173px) Image search: [Google]
image.jpg
16KB, 261x173px
>>57113811
>Python 2.x
>>
>>57113811
https://gist.github.com/lolzballs/2152bc0f31ee0286b722
>>
>>57122307
There is a Turing-complete subset of XML.
>>
>>57113311
<code>
if (> myVal 1)
// do stuff
</code>

:D
>>
>>57125765
ayy
Thread posts: 69
Thread images: 6


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.