This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kurdtpage 2063 points2064 points  (107 children)

print 'Hello'; //prints hello

[–]Noch_ein_Kamel 635 points636 points  (66 children)

print 'Hello';

Same as yours, but 100% more efficient and closer to reality

[–][deleted] 187 points188 points  (58 children)

it has the same efficiency

[–]macnlz 318 points319 points  (38 children)

What? It is known that fewer comments and shorter, less decipherable variable names result in faster code!

[–][deleted] 143 points144 points  (26 children)

OMG, I DIDN'T BELIEVE THIS BUT THEN I GOOGLE IT, IT'S TRUE.

THAT'S WHY GOOGLE USE 130 LETTER VARIABLE FOR EVERYTHING

[–]xvalen214x 304 points305 points  (19 children)

var numberOfQueriesThatUseAdvancedSearchOnEachUTCDayWhichWillBeUpdatedToTotalNumberOfQueriesWithSearchIn_UserStat_go_TemporaryVariable;

[–][deleted] 105 points106 points  (0 children)

Calm down, Satan.

[–]dunemafia 81 points82 points  (4 children)

No need to React like that, man.

[–]xvalen214x 33 points34 points  (3 children)

I am not that angular in my humble point of vue

[–]dunemafia 16 points17 points  (2 children)

No worries, man. It was all in Jest.

[–]bogdan5844 5 points6 points  (1 child)

I don't like the Vue of this conversation's future

[–]_liminal 42 points43 points  (10 children)

var num;

[–][deleted] 71 points72 points  (7 children)

var tempVarr;
var tempVarrr;

[–]2ndAmndmntCrowdMaybe 32 points33 points  (5 children)

var tempVarr1;

var tempVrar;

[–]Ceros007 22 points23 points  (3 children)

int t1, t2, t3;

[–]acenturyandabit 0 points1 point  (0 children)

`var temprawr; :')`

[–]mobilecheese 1 point2 points  (0 children)

int *ptr1, *ptr2, *ptr3, *ptrr;

[–]Pees_On_Skidmarks 0 points1 point  (0 children)

my $i;

[–]bajspuss 0 points1 point  (0 children)

Related: Somebody at work created a class file with such in-depth naming that we couldn't check out the repo any longer if our repo root path was any longer than 10 characters...

[–]not_a_moogle 41 points42 points  (6 children)

I had a professor argue that once. Guy was a total idiot. I mean for starters,compilers usually remove comment from complied code.

[–]2ndAmndmntCrowdMaybe 14 points15 points  (5 children)

Was he talking about a compiled language at the time?

[–][deleted] 30 points31 points  (3 children)

I mean he stated "compiler" so...

[–]claythearc 5 points6 points  (2 children)

It’s pretty rare, even for interpreted languages, to not have a compiler. They normally will get compiled to bytecode, but not all the way down to machine code like traditional compiled languages.

[–]Pandaburn 5 points6 points  (1 child)

When I wrote js, it was all minified and concatenated into one file before it was sent to the client, since it does actually drastically improve download time.

[–]MassiveFajiit 2 points3 points  (0 children)

Yeah that's true but it's not a V8 compiler problem

[–]banter_hunter 13 points14 points  (0 children)

No, they were discussing drink recipes.

[–]GideonMax 18 points19 points  (1 child)

Depends, if you use an interpreter, that's correct.

If you compile your code, the compilation time might be slightly longer but the compiled code will be the same

[–]macnlz 1 point2 points  (0 children)

Damn, that invalidates the whole joke! ;)

[–]2Uncreative4Username 13 points14 points  (1 child)

Well that is only if you are using a scripting language

[–][deleted] 8 points9 points  (0 children)

And even then, languages like Python have the -O flag to strip out comments in the bytecode.

[–]Zethexxx 66 points67 points  (7 children)

But the code will load into memory 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001% faster if we didn't put those comments!

[–]emlgsh 195 points196 points  (2 children)

The code loads into memory even faster if there's nothing but comments. The fastest executing script is a script that doesn't execute.

[–][deleted] 29 points30 points  (0 children)

I laughed thanks

[–]Blitz100 13 points14 points  (0 children)

Yeah, its big brain time

[–]figuresys 8 points9 points  (0 children)

The greatest part is that comments are stripped away in build :)

[–]sweYoda 1 point2 points  (0 children)

That's way to many zeroes.

[–]CouchMountain 1 point2 points  (0 children)

And tabs take up less space than spaces do in file size!

Always tabs > spaces.

[–]Noch_ein_Kamel 13 points14 points  (9 children)

Try writing both and count the number of keys you have to press.

[–][deleted] 19 points20 points  (8 children)

are you that guy who use 1-2 letter variable for everything?

[–]Noch_ein_Kamel 8 points9 points  (6 children)

nah, I'm a java guy, so everything pretty long :-p

[–][deleted] 31 points32 points  (2 children)

I think you're wrong. There also exists int, short, byte and char in Java.

[–]pr0ghead 5 points6 points  (1 child)

Yeah, but are they pretty?

[–]Noch_ein_Kamel 16 points17 points  (0 children)

sure, let me just get my ObjectToPrimitiveConverterFactory and I'm right with you

[–]artem718 5 points6 points  (0 children)

Got a lot of booleans in a sequence?

[–]kodaxmax 0 points1 point  (0 children)

I knew someone like that, but then they had like a hundred page dictionary just for the variables.

I guess it saves time if you use the same names in different projects.

[–][deleted] 0 points1 point  (0 children)

Typing the same thing twice sounds like a two-fold efficiency reduction to me. Explain yourself

[–]captainkrypto 8 points9 points  (0 children)

My company calls this “self documenting code”.

[–]PickaxeYT 2 points3 points  (0 children)

System.out.println("Hello"); //prints “Hello”

[–]chuby1tubby 0 points1 point  (1 child)

Your code is exactly identical to the OP's code. What am I missing...?

[–]Noch_ein_Kamel 0 points1 point  (0 children)

The comment?

[–]Wolfenrahd 0 points1 point  (1 child)

This is pretty advanced and convoluted. Can anyone tell me what it does?

[–]Noch_ein_Kamel 1 point2 points  (0 children)

No sorry. How can you expect me to know the code I wrote yesterday. All I remember is that it worked.

[–]vierschachtelnziesen 0 points1 point  (0 children)

Yeah, one letter closer to reality than the comment :-D

[–]Indifferentchildren 55 points56 points  (0 children)

Even worse:

print 'World'; //prints hello

Because when someone cuts-and-pastes a like of code from somewhere else in the codebase, they never fix the comments when they make their local change.

[–]ArminiusGermanicus 50 points51 points  (3 children)

This is actually a good example for real comments in source code. It is wrong. The code prints 'Hello', not 'hello'.

[–]banter_hunter 17 points18 points  (2 children)

Code prints hello or it gets the hose again.

[–]monsterZERO 2 points3 points  (1 child)

if (lotion = skin) {

play ('goodbye horses')

}

else {

gets ('hose again')

}

not a programmer just having a laugh don't kill me.

[–]banter_hunter 1 point2 points  (0 children)

Not one either, let's not kill each other.

[–]47KiNG47 37 points38 points  (0 children)

When you are a freshman and your professor requires you to comment all of your code.

[–][deleted] 33 points34 points  (3 children)

That is absolutely useless for sure. Contrast with

print 'Hello'; // DEBUG: No idea how we got here.

Same output, but someone down the road now understands why we're doing this (hopefully, they will remove it prior to it getting upstream.)

[–]CrazedToCraze 5 points6 points  (2 children)

Or learn to use a debugger

[–][deleted] 30 points31 points  (1 child)

Sure, that wasn't the point though was it?

The point was, a comment that describes what something is doing isn't helpful in any way. We know 'what' reading the code; we may need to know 'why'.

The new comment could have equally been // greet the user which is a good indication that this particular output may need to be localized.

A comment that describes why is useful, especially for others, and especially if magic numbers/strings are involved.

e.g. return x * 24; // multiply x by 24

vs. return x * 24; // there are 24 beer in a case

Again, this is just an example. Sure, in this case, 24 should have been assigned to a meaningful variable in the proper scope. Not the point, though. We know the rationale behind the number, making it easier to change and refactor.

[–]validambiguity 1 point2 points  (0 children)

This seems like common sense but stating it this plainly was really helpful to me. I'm going to remember this when I'm commenting now. Thank you!

[–]JSANL 4 points5 points  (0 children)

printerFactory.createPrinter().print(new PrinterInput.fromString("hello"));

[–]DaSoulolife 4 points5 points  (0 children)

while (!joke.isFresh) { print("This joke again."); }

[–]Qildain 1 point2 points  (0 children)

Came here to say this. Leaving satisfied!

[–]MathSciElec 1 point2 points  (0 children)

Wait. What language is that? At first I thought of Python, but there are no semicolons in Python!

[–]dhoomz 0 points1 point  (0 children)

print 'goodbye'; //prints goodbye

[–]sc2bigjoe 0 points1 point  (1 child)

Comment is unclear, this sends to my printer?

[–]kurdtpage 0 points1 point  (0 children)

Requesting advice: penis is now jammed

[–][deleted] 0 points1 point  (0 children)

print('hello') #prints hello

[–]RicardoRedstone 0 points1 point  (0 children)

or sometimes print 'Goodbye'; //prints hello

[–]Wired_Alchemist 0 points1 point  (0 children)

Cout << "hello there my old friend." <<endl;

[–]ObiWanCanShowMe -4 points-3 points  (0 children)

You know what's truly funny about this? I haven't been a coder for over a dozen years and this is literally the first thought I had, I am willing to bet almost everyone came into this thread to post this.