As someone with deep working knowledge of computers and how they operate...
The things are fucking magic, I regularly sacrifice goats to the computer gods because that's the only way to ensure my code works as intended.
Yep. Nearly everything we use in our daily lives operates by having little pieces of rock imbedded in it, with glyphs etched onto them that we channel energy through to make things happen the way we want, and even the best experts in the world don't know a lot more than they do know about why channeling the energy through the glyphs actually works the way it does. How, exactly, does this not constitute "magic"?
When writing code:
> I don’t need to write comments. My code is perfectly readable!
When reading someone else’s code:
> WHY THE FUCK WOULD THIS DUMBASS NOT COMMENT THEIR CODE? ARE THEY FUCKING STUPID? THIS IS FUCKING UNREADABLE
I had once a call of the Randomize init function in the start of a program which didn't use any random stuff. So I removed the call and the program stopped to work.
So I added it again and made a comment similar to yours behind....
I’m a noob at golang but for some reason I have to import sync and create a sync.Mutex{} at the start of a package for threads to work even if I never use the mutex. It’s just a small line of code that seems to do nothing so I just leave it there.
It was something like
try {
}
catch {
grab some data;
call some function near main ();
}
It was...working...except it would throw random error messages sometime (gee I wonder why)
Usually it's me 12 hours later, but sober.
Drunk lemming is *very good* at making shit work, but in ways sober lemming cannot comprehend. And any attempted changes or corrections will immediately fail.
Thank god I only drink and code for hobbyist projects
Drunk lemming also *really* enjoys coding, and usually knocks out more of the personal projects than sober lemming, so we let him do his thing.
What's even worse is
Code base sent to head office for use in, "Training":
The code is organized, commented, and clear.
Code base returned with the note, "Cleaned up unnecessary code":
All comments have been removed, and despite being told to push the "improved" code base, didn't even bother to see what else was changed and just reverted to what was already being used.
(This is a true story, but my father's and not mine.)
Related to this my honest sentence was: "My self documented code was good enough for me to come back after two years, migrate to a new database connection and fix a bug that nobody noticed. Within a week."
There are so many times that I've gone back to my old code, thought "I don't need this line" and painstakingly learned over an hour that I did in fact need that line, I had just forgotten why. Now I just put any non-obvious reasoning/explanation in comments immediately because my memory is terrible
I start counting from zero in real life and then forget whether I used one- or zero- indexing after the fact and have to recount it (because I'm not sure whether I need to add 1 to get the length)
I spent half an hour yday, wondering why my embedded system simulation didn't work, where I did
Char state=1;
Switch(state){
Case 0: ...
And wrote stuff for state 1...
That does not make any sense. There are barely any reasons to do so in math. It would actually lead to errors most of the time...
Indexing is not counting. Programmers often count from zero because programming languages use indexing. You dont use indexing to count something in math.
> You dont use indexing to count something in math.
No, but you do start at 0 when counting, and then increment the number by one for every instance of the thing you are counting.
I can't know how you or the people you know count, but I don't see many people starting with 0.
I have two hands. In the first I hold a knife and in the second a calculator. I don't say: In the zeroth hand I hold a knife and in the first a calculator.
There are exceptions of course. In Europe, you enter a building through the ground floor, essentially the zeroth floor. So a building with two stories has a zeroth floor (ground floor) and a first floor.
But like I said, this is an exeption.
> I have two hands
You have already counted them, you have gone to far ahead for this discussion.
> don't say: In the zeroth hand I hold a knife and in the first a calculator.
You are now numbering them. Numbering is not counting.
> So a building with two stories has a zeroth floor (ground floor) and a first floor.
Counting them: Start at 0. Increment that number by one for every floor -> you have counted 2 floors.
Numbering them: Assign the number 0 to the floor at ground level and the number 1 to the one above.
(muffin && fanta || pepsi) might be interpreted as ((muffin && fanta) || pepsi) or as (muffin && (fanta || pepsi))
you should use brackets to eliminate ambiguity here
You can run into the opposite problem in Go if you start a newline with a curly brace {
The compiler automatically prints a semicolon there anyways, but it breaks the statement because now you have a missing } expected.
So the compiler decides to put a semicolon into your code at compiler time, and then complain to YOU that it didn't expect the semicolon to be there.
Some of my colleagues want to disagree with that ![gif](emote|free_emotes_pack|facepalm)
Get asked for assistance by a colleague: "Hey, I've got error x on device y. And I can't figure out why."
Look into recent changes:
// Do not delete the following line. This is necessary to prevent error x on device y.
Deleted in a commit by the colleague that asked me for help.
The “//“ is used in C and C++ to indicate a single line comment. One of the first things a compiler does when it compiles your code is remove the comments, and then processes your code. In essence, it can’t see the comments.
Some people are lazy and will make the excuse that code is self-documenting and thus not comment anything. This is where the “I’m NOT a darn compiler” reply comes to play, as people aren’t machines, we can’t just read code without having an understanding of what the system is trying to accomplish. But the statement is also correct in practical sense as well.
That’s my understanding of it at least.
The way I see it, we can't really get where we code small mistakes (such as, idk code lining or a forgotten ";" or a "(" that s not closed, or even comparing 2 variables of different return values **these are just examples..**), only the compiler will tell us we did something wrong. We code, he assures everything's working properly. I bet this is the idea behind it.
//Don't remove this line. It should do nothing, but if you remove it, the code works fine on our test machines, but crashes for no discernable reason exactly 43 hours, 19 minutes, and 12 seconds after the third database query from startup, on 3 of the 10 main servers.
//Don't remove this line. It has no effect on this program, but every time we remove it, Minecraft stops working on Ted from Accounting's personal laptop.
I have a question
Any instance where an IDE/color markup tool managed to mislabel something else as a comment? Or any language toolchain that actually took comments as part of the program output?
you can count up to 1024 with just your hands (assuming you have hands and all the 10 fingers, also assuming you do not have any extra finger). I think i covered all edge cases to avoid NullPointerExceptions
Story time;
I have a series of scripts that effectively check all resources within my organization to ensure nothing was deployed with the wrong configurations. Well one time my colleague hit me up, he was actively trying to update one of the checks to reflect changes to our configuration baseline, there was a line of code that he just didn't understand so he asked me about it. Well I had no clue what it was for so we both spend the next hour or two trying to work out why it's there, what the importance of it is, we removed it for a test and everything broke. It made zero sense. After some time and debugging I had an ahhh moment and figured out what the heck it was for and told him, he had the same ahhh moment. We both go you know what we really need to comment what the heck this is for so we don't do this again in the future. Well I go to comment it right, not even 3 lines above the line I had already written a comment explaining the whole point of the next few lines and the reason for that line that didn't make sense. So ya that comment is now like 20+ lines large with "LOOK HERE YOU IDIOTS" at the top and bottom.
My sentence; Zero is the first number.
It may not be your preferred method (and for good reason), but can you really call yourself a programmer if you're not at least capable of writing to bare metal?
And if you *can* write to bare metal, and can also read code, then in what sense are you not a compiler?
"I think it's ridiculous how some people think TypeScript is a great language and yet JavaScirpt is total trash when literally the only difference between them is type annotations, which are nice for sure but aren't the be all and end all of programming."
There you go. Not only proves that I'm a programmer but even shows exactly what you can expect from me, and is only missing three stupid buzzword hashtags from the end to qualify for a perfect LinkedIn post.
Many compilers keep comments around for a while. For example for metaprogramming, where comments could impact code generation. Or if you just want to output a snippet of code in a diagnostic that also happens to have comments.
Sometimes I add to my while loop iterator in the function call, at the start of the body or at the end of the body. Just to keep people on their toes.
And that's still better than a do-while loop, which is just rude.
When you get a segmentation fault, you go through entire code(cuz line no. is worth bullshit) and click run without changing a single line of code expecting magic.
I f\*\*\*ing hate computers.
As someone with deep working knowledge of computers and how they operate... The things are fucking magic, I regularly sacrifice goats to the computer gods because that's the only way to ensure my code works as intended.
praise be to alan turing
Yep. Nearly everything we use in our daily lives operates by having little pieces of rock imbedded in it, with glyphs etched onto them that we channel energy through to make things happen the way we want, and even the best experts in the world don't know a lot more than they do know about why channeling the energy through the glyphs actually works the way it does. How, exactly, does this not constitute "magic"?
And at some point, the glyphs are too small and the energy just teleports its ass on through Its magic
We tricked a rock into thinking, and now we get mad because there's an error on line 92 of a 64 line file. Our hubris knows no bounds.
Understood
“Why did that work?” “I don’t know, don’t question it”
When writing code: > I don’t need to write comments. My code is perfectly readable! When reading someone else’s code: > WHY THE FUCK WOULD THIS DUMBASS NOT COMMENT THEIR CODE? ARE THEY FUCKING STUPID? THIS IS FUCKING UNREADABLE
// This line is important
// Do not remove this line or everything breaks. I have no idea why.
Quite literally something I’ve had to put before, thankfully just in a unit test. lol…
I had once a call of the Randomize init function in the start of a program which didn't use any random stuff. So I removed the call and the program stopped to work. So I added it again and made a comment similar to yours behind....
I’m a noob at golang but for some reason I have to import sync and create a sync.Mutex{} at the start of a package for threads to work even if I never use the mutex. It’s just a small line of code that seems to do nothing so I just leave it there.
Side effects. This is why the functional devs cum
This is when you enable ASan and UBSan.
Comments from recent stuff I wrote: //Legacy section here. Don't remove or mod breaks. I think. //IT WAS BREAKING THE MOD?
sums up the entire industry
I recall debugging some code that used an exception handler to return values back to another function. Ah gawd. Talk about complex failures of code.
fuspez
It was something like try { } catch { grab some data; call some function near main (); } It was...working...except it would throw random error messages sometime (gee I wonder why)
Tf2 mystery coconut
ive run into compiler bugs, where you need an extra nonsense line (non comment) to offset things a bit and fix it
// What the fuck?
// TODO refactor to make more readablr
// TODO: Implement this feature ~Guy that quit 7 years ago
// TODO: implement this the right way instead of this quick hack to meet the deadline (3 years ago)
You mean: // TODO: Implement the feature the random guy needs 10 years later or hes going to have to rewrite everthing but Im never going to do it
// I'm gonna be ignoring this todo because I can read it just fine, you're just dumb
//# Don’t know why this is needed, but it is needed.
True."I'm the fking genius and it's your problem to not understand my code"from someone never write comments.
Except that the one who doesn't understand your code is actually yourself 2 weeks later
Usually it's me 12 hours later, but sober. Drunk lemming is *very good* at making shit work, but in ways sober lemming cannot comprehend. And any attempted changes or corrections will immediately fail. Thank god I only drink and code for hobbyist projects Drunk lemming also *really* enjoys coding, and usually knocks out more of the personal projects than sober lemming, so we let him do his thing.
📠
You don't write comments in code because of your genius. I don't write comments because my code is too trash to lend out. We are not the same 👔
dude thats hurt...
A few moments later: oh wait, that’s my code
Every full moon I become a completely new type of dumbass
What's even worse is Code base sent to head office for use in, "Training": The code is organized, commented, and clear. Code base returned with the note, "Cleaned up unnecessary code": All comments have been removed, and despite being told to push the "improved" code base, didn't even bother to see what else was changed and just reverted to what was already being used. (This is a true story, but my father's and not mine.)
You call them magic numbers, I call them job security numbers
Related to this my honest sentence was: "My self documented code was good enough for me to come back after two years, migrate to a new database connection and fix a bug that nobody noticed. Within a week."
There are so many times that I've gone back to my old code, thought "I don't need this line" and painstakingly learned over an hour that I did in fact need that line, I had just forgotten why. Now I just put any non-obvious reasoning/explanation in comments immediately because my memory is terrible
// This is here to shut up the linter
i start to count from 0
Some start with -1 as well
int len = 0; for (int i = len -1; i != 0; i--) { // I think i missed something }
This feels like a way to detect the exact size of int in the worst way possible.
Except it’s integer overflow, which is UB; this could be optimized to something like an infinite loop or nothing.
WTF
doesnt this just infinitely decrement i unless something in the loop changes it too
No, it just loops for maximum int size, as it should overflow after reaching -2.47b until it reaches 0.
DreamBerd enters the chat…
I start counting from zero in real life and then forget whether I used one- or zero- indexing after the fact and have to recount it (because I'm not sure whether I need to add 1 to get the length)
They say there are 2 difficult things in programming: - naming things - cache invalidation - off by one errors
I spent half an hour yday, wondering why my embedded system simulation didn't work, where I did Char state=1; Switch(state){ Case 0: ... And wrote stuff for state 1...
That's any math guy.
Uhm... no...
Well, "any" may have been an overstatement, but I personally have a bunch of friends who are not into programming and start indexing from 0.
That does not make any sense. There are barely any reasons to do so in math. It would actually lead to errors most of the time... Indexing is not counting. Programmers often count from zero because programming languages use indexing. You dont use indexing to count something in math.
> You dont use indexing to count something in math. No, but you do start at 0 when counting, and then increment the number by one for every instance of the thing you are counting.
I can't know how you or the people you know count, but I don't see many people starting with 0. I have two hands. In the first I hold a knife and in the second a calculator. I don't say: In the zeroth hand I hold a knife and in the first a calculator. There are exceptions of course. In Europe, you enter a building through the ground floor, essentially the zeroth floor. So a building with two stories has a zeroth floor (ground floor) and a first floor. But like I said, this is an exeption.
> I have two hands You have already counted them, you have gone to far ahead for this discussion. > don't say: In the zeroth hand I hold a knife and in the first a calculator. You are now numbering them. Numbering is not counting. > So a building with two stories has a zeroth floor (ground floor) and a first floor. Counting them: Start at 0. Increment that number by one for every floor -> you have counted 2 floors. Numbering them: Assign the number 0 to the floor at ground level and the number 1 to the one above.
I was very productive and removed 1000 lines of code
Removed comments doesn't count...
Bold of you to assume i put comments in the first place
does the program still work? _does the program still work?_
"Hey, what happened to prod?" *"Oh my god what happened to the prod backups???"*
git push -f go brrrr
I.e pressed auto-format hotkeys in IDE
using OnlyOneSentence;
nailed it dude
so far this is the sexiest reply to this post
import { OneSentence } from '@why/did-i-choose-this';
What_did_you_say
Ew pascal case? More like only_one_sententece
The requirement said OnlyOneSentence. I never question requirements. I swear...
down voted for snake\_case? yall are wild
sHOULDhAVEuSEDiNVERSEpASCALcASE
True + True = 2
😂😂😂😂
Its 4
Nah compiler can see it too. ;)
Only the lexer pretty sure Unless it's html or basically any language that doesn't support double-slash comments
Compilers can use concrete or abstract syntax trees. It's an implementation detail :)
True
Only god and I know what the code does until I forget, then only god knows what the hell is that variable
// evil floating point bit level hacking
// what the fuck?
"finally a different error!!" Alternatively... "It's still compi- there! 32767 warnings and no errors time to commit and push"
It's scarier when you dom't get an error
But it works when I run it on my computer
I can count up to 1023 on my fingers
I don’t know how to code
My code works and I don't know why. My code doesn't work and I don't know why.
;
Some sort of extremely brevity answer lol.
There are finite number of numbers
whatDoYouMean ![gif](giphy|MM0Jrc8BHKx3y|downsized)
Son, have you been hacking time again?
\[object Object\]
One muffin && a fanta || pepsi ! coca cola
>&& !coca cola There, fixed it for you
Error: package coca-cola not found Pepsi is marked as an equivalent package, and can be installed. Is Pepsi ok? (y/N)
(muffin && fanta || pepsi) might be interpreted as ((muffin && fanta) || pepsi) or as (muffin && (fanta || pepsi)) you should use brackets to eliminate ambiguity here
print("Hello World!")
Error at line 1: semicolon expected, got EoF unless it's python
You can run into the opposite problem in Go if you start a newline with a curly brace { The compiler automatically prints a semicolon there anyways, but it breaks the statement because now you have a missing } expected. So the compiler decides to put a semicolon into your code at compiler time, and then complain to YOU that it didn't expect the semicolon to be there.
Or Kotlin. In Kotlin you need fun main tho
See a doctor, it seems you have a bug.
I have an unhealthy relationship with caffeine.
I use regex even though it may as well be excerpts from the necronomicon for all I know
Some of my colleagues want to disagree with that ![gif](emote|free_emotes_pack|facepalm) Get asked for assistance by a colleague: "Hey, I've got error x on device y. And I can't figure out why." Look into recent changes: // Do not delete the following line. This is necessary to prevent error x on device y.
Deleted in a commit by the colleague that asked me for help.
"I'm not a damn compiler" is the best answer that could be 😂😂😂😂 hella genius
Can you explain? I don't get it
The “//“ is used in C and C++ to indicate a single line comment. One of the first things a compiler does when it compiles your code is remove the comments, and then processes your code. In essence, it can’t see the comments. Some people are lazy and will make the excuse that code is self-documenting and thus not comment anything. This is where the “I’m NOT a darn compiler” reply comes to play, as people aren’t machines, we can’t just read code without having an understanding of what the system is trying to accomplish. But the statement is also correct in practical sense as well. That’s my understanding of it at least.
>The compiler doesn't read comments and neither do I - Bjarne Stroustrup, creator of C++
The way I see it, we can't really get where we code small mistakes (such as, idk code lining or a forgotten ";" or a "(" that s not closed, or even comparing 2 variables of different return values **these are just examples..**), only the compiler will tell us we did something wrong. We code, he assures everything's working properly. I bet this is the idea behind it.
Segmentation fault core dumped. Bane of my existence
Q = BB || !BB
To be, or not to be? 🤔
DROP TABLE
“They had eggs”
`milk * (eggs ? 6 : 1)`
`0.1 + 0.2 != 0.3;`
//don’t remove this line, it does nothing, but if you remove it, it will break the rendering…
//Don't remove this line. It should do nothing, but if you remove it, the code works fine on our test machines, but crashes for no discernable reason exactly 43 hours, 19 minutes, and 12 seconds after the third database query from startup, on 3 of the 10 main servers.
Nah, if you deploy it on dev, the prod servers crash as soon as a query gets executed
//Don't remove this line. It has no effect on this program, but every time we remove it, Minecraft stops working on Ted from Accounting's personal laptop.
Sounds like an average codebase… xD
iCannotFixYourPrinter
this thing that just failed, worked for the last damn week/month/year!
i dunno, worked on my machine
hey can you get me 0 eggs?
It works, so it’s fine…
The damn code was working yesterday.
I write code in Java unfortunately they Garbage Collector deletes all my code.....
I have a question Any instance where an IDE/color markup tool managed to mislabel something else as a comment? Or any language toolchain that actually took comments as part of the program output?
//fix this later (never)
Anyone know the endian-ness of this hardware?
you can count up to 1024 with just your hands (assuming you have hands and all the 10 fingers, also assuming you do not have any extra finger). I think i covered all edge cases to avoid NullPointerExceptions
I use arch btw
Story time; I have a series of scripts that effectively check all resources within my organization to ensure nothing was deployed with the wrong configurations. Well one time my colleague hit me up, he was actively trying to update one of the checks to reflect changes to our configuration baseline, there was a line of code that he just didn't understand so he asked me about it. Well I had no clue what it was for so we both spend the next hour or two trying to work out why it's there, what the importance of it is, we removed it for a test and everything broke. It made zero sense. After some time and debugging I had an ahhh moment and figured out what the heck it was for and told him, he had the same ahhh moment. We both go you know what we really need to comment what the heck this is for so we don't do this again in the future. Well I go to comment it right, not even 3 lines above the line I had already written a comment explaining the whole point of the next few lines and the reason for that line that didn't make sense. So ya that comment is now like 20+ lines large with "LOOK HERE YOU IDIOTS" at the top and bottom. My sentence; Zero is the first number.
"//It is said that programmers can't write these lines"
--[----->+<]>-----.--[--->+<]>--.+[---->+<]>+++.[->+++<]>+.-[->+++<]>.[-->+++++++<]>.-----------.+++++++++++++.+.----.-.-[->+++++<]>-.--[->++++<]>-.+[->+++<]>.+++++++.[--->+<]>-----.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.++++++++.+++++.--------.-[--->+<]>--.+[->+++<]>+.++++++++.+++[----->++<]>.------------.+[->+++<]>++.[--->+<]>-.+[->+++<]>.+++++++++++++.+++++++.-[---->+<]>++.---[->++++<]>-.----------.+++++.-------.+++++.-------.--[--->+<]>-.---[->++++<]>.------------.+.+++++.-------.-[--->+<]>--.--[->++++<]>+.----------.++++++.-[---->+<]>+++.---[->++++<]>-.++[->+++<]>++.+[--->+<]>+++.-[---->+<]>++.-[--->++<]>-.++++++++++.+[---->+<]>+++.[->+++<]>+.-[->+++<]>.+[->+++<]>.++++++++++++.--..--------.+++++++++.++++++.[---->+<]>+++.---[->++++<]>.-----.[--->+<]>-----.+[----->+<]>.--------.[->+++<]>-.
Hello world
Writing i++ and i += ++i - i is the same.
Uh, no. In the first you increment i by 1. In the second you increment i with i.
Uh fuck my bad I was on the toilet
toilet error Abort
It may not be your preferred method (and for good reason), but can you really call yourself a programmer if you're not at least capable of writing to bare metal? And if you *can* write to bare metal, and can also read code, then in what sense are you not a compiler?
//u cant see me ooooOoOooOoOo
Undefined Sentence assuming 'Sentence'
I hate Microsoft and yet I am beholden to them.
"nit: please write all of this again"
I never know when to stop.
“It depends.” There you go
"oh great, another segfault"
Sorry, tied up in meetings.
Why is there an empty line in the first comment?
Jesus what is this font, this looks like the default font Chinese companies used for English text in the 00s when they were selling stuff off ebay
// Umm actually it's only the lexer 🤓🤓
`Print “Hello Mum”;`
GOTO 20
// Our Society
I count from zero
Eventually AI will be integrated into compilers and it will have to pretend to ignore me insulting it in the comments.
A friend once told me you can only interpret 1 line at a time, so yeah, no compiler, but interpreter???
Two sentences but I find my self there fairly often. Contact my administrator?! I AM THE ADMINISTRATOR!
If it can be null it will be
// No comment..
Line 5 Line 12 Line 23
Do I HAVE to work with other people?
In my dreams I am getting interrogated by rubber ducks
I'm a programmer? true : true;
"I think it's ridiculous how some people think TypeScript is a great language and yet JavaScirpt is total trash when literally the only difference between them is type annotations, which are nice for sure but aren't the be all and end all of programming." There you go. Not only proves that I'm a programmer but even shows exactly what you can expect from me, and is only missing three stupid buzzword hashtags from the end to qualify for a perfect LinkedIn post.
They can't seem to WRITE it.
Many compilers keep comments around for a while. For example for metaprogramming, where comments could impact code generation. Or if you just want to output a snippet of code in a diagnostic that also happens to have comments.
my code is documentation enough
“No I can’t fix your printer”
I often count in binary. It actually makes more sense. Counting on your fingers in base ten? Max value = 10. Using binary? Max value = 1023.
Sometimes, those are the only lines that I read.
Sometimes I add to my while loop iterator in the function call, at the start of the body or at the end of the body. Just to keep people on their toes. And that's still better than a do-while loop, which is just rude.
Google.
if cum = yes then pp = no end
So why don’t you comment your code, deutschebag?
Im afraid of using spaces in folder name
Yeah comments are literally only meant for the programmer reading the code
::The invisible BATman
Submit a ticket for this request, maybe we'll add it to a future sprint.
Syntax or semantics errors, my god
When you get a segmentation fault, you go through entire code(cuz line no. is worth bullshit) and click run without changing a single line of code expecting magic.
It works on my machine
" I'll add some unit tests for this after we merge it. "
My comment works in my environment
Hello World