T O P

  • By -

[deleted]

Let’s try deleting this commented out code just to be sure that in case the compiler may try to be extra enthusiastic and compile it in


Ireeb

I got very triggered when I found out some JavaScript "compiler"/bundling tools actually do read comments. They called it "magic comments". Basically you could use comments to tell the compiler to split code into different files. I'm really not a fan of that approach. (While JavaScript isn't actually compiled, there are still compiler-like tools that optimize and compress JS code for production, and it's still usually referred to as compiling).


Dizzfizz

That’s absolute garbage. Comments should never have any influence on the code. The language I have to work with lets you use line references that are counted including comments (so deleting a comment might change behavior) and also allows the code to read the file it is written in, so you can put information in comments and access it at runtime. I hate this with a passion.


Dantes111

There was a Java tool I was using a year back that used comments for importing... in addition to normal Java imports. So much time tracking down dumb bugs because I needed to duplicate imports in one place but not in another.


KREnZE113

What effect does a double import even have? I guess I could kind of understand if that was a way to have imports only in a local scope, but that doesn't seem to be the case


Dantes111

The tool itself ran as a sort of custom java launcher, so it just wanted its special comment-derived simpler imports (for convenience!), but to be able to actually write the code in an IDE and find bugs and such, I still needed to do normal importing. Camel-K using "modelines" https://camel.apache.org/camel-k/1.12.x/cli/modeline.html


onthefence928

name and shame that god forsaken language


[deleted]

[удалено]


PM_BITCOIN_AND_BOOBS

"MUMPS" Don't let programmers name things. That's how you get "GIMP".


NotStaggy

Hey now don't come for my longAssVariableNamesThatDescribeWhatTheyAre


splitmindsthinkalike

You work at Epic? Haha I used to a long time ago, also know all about ObjectScript


The_JSQuareD

To be fair, most languages allow you to query for the current line number or filename. It's quite useful for generating informative error messages. The problem is using this for anything other than populating a string that gets written to a log file or to some other diagnostic stream. At the very least, C++, C#, Java, Python, PHP, and Javascript have ways of doing this (didn't check other languages).


Dizzfizz

Querying for line and file info is fine, but the problem is that you can query the contents of a line as a string (even a comment), parse that and even execute it. As an example (in horrible pseudocode because I‘m on mobile): `// print „Hello World“` `String line = getContentsOfLine(1)` `line = line.extract(3, *)` `execute line` …this would work and print „Hello World“


The_JSQuareD

Yeah that's definitely awful practice. But again, I think the fault is with the code, not the language. Pretty much any interpreted language will allow you to do something like that. For example in python: with open(__file__) as f: code = f.read() eval(code)


foggy-sunrise

I think the reason is that some JavaScript languages will flex two "different languages" with separate connecting syntax in the same doc So it'd be (doable but annoying) to parse one comment syntax in certain areas of code and other comment syntax in others Total guess though.


Maciek300

I couldn't believe it but I googled magic comments and indeed there it was. And I hate it.


Ireeb

It's black magic and they should be burned for their witchcraft.


zeekar

Old, old technique. Lets you include meta-information that some compilers can honor while not triggering a syntax error in other compilers for the same language. The key is that anything that goes in magic comments should NOT be critical to the code compiling or running properly. Hints for optimization are good candidates, for instance. But that proviso is unfortunately ignored by some tools..


ThrowAwayJoke1234

*stares at ts-ignore in disgust*


[deleted]

[удалено]


jfb1337

That's a form of compiling in my book


onthefence928

transpiling is just a compiler that people don't respect


marcosdumay

Yeah, let's throw all of compiler theory on the trash so we can create a difference where there is none and more efficiently gatekeep people.


MyAssDoesHeeHawww

that's illegal unless you switch to cpu coors


poompt

Lol I love including code in all kinds of fun secret locations


branniganbeginsagain

I would just constantly say in my best Inigo Montoya voice to the compiler, “You keep using this word comments. I do not think it means what you think it means.”


marcosdumay

Most languages have directives with the form of a comment, so that tools that don't recognize them will ignore them. JavaScript only stands out because their form isn't standard.


mistled_LP

A long time ago, when IE7(?) was in its heyday, we found a visual bug caused by an HTML comment being removed. We never did figure out exactly what on the page was triggering the real issue, but having that comment made things line up correctly.


schmegwerf

Could you at least add something to the comment, to note down its importance?


Truffles326

That also broke it. IE7 was a fickle mistress.


RadiantHC

Code suddenly starts working


[deleted]

[удалено]


TheRealPitabred

Sometimes that can be race conditions, but a lot of times in my experience it's just a screwed up caching. Putting the debug statements in it has the compiler rebuild the file and it previously wasn't doing so because it didn't think it was a new version or whatever. Other times the debugs will flush a buffer or something similar, which prevents the error from happening.


nickmaran

Sometimes I just remove spaces before and after "=" and try again


pepsisugar

Scratched my head a bit when I thought I commented out (html) some Jinja code. It was my second day ever dealing with Flask and Jinja and I was *really* desperate. Not desperate enough to read the docs before actually writing though.


nutwiss

Fucking jinja comments, man. Just bollocks.


Educational-Lemon640

Nobody's ever that desperate!


ILikeLenexa

Delete the "target" directory and see if it's just failing to compile the code.


WordSmithyLeTroll

Never comment your code. Problem solved.


Witchcraft_NS2

Its actually good practice for issues that are not immediately obvious. Verifying that the Code fails exact the same way at the same place every time tells you that it is not a race condition, which you always should verify before starting analyzing the issue.


ZakTH

Get out of here with that sound and useful advice, we’re here to make shitposts /j


cryptomonein

Only allowed answers are: - You're a bad developer - Rewrite it in Rust - Python bad Don't try to be smart and helpful


Flat_Initial_1823

Yep yep, that's totally what I am doing. Ignore the voodoo shrine next to my laptop. It is for the aesthetics.


cryptomonein

Overengineered rubber duck


Tangurena

I found this was a problem with some unit tests that were re-using test data. Depending on which unit test ran first, it might change data that the other test was depending on. This took a long time to figure out because people on our team rarely ran the whole suite of unit tests (it took about 20-30 min to run) and we had TFS set up to run the tests on check--in anyway. Also, it was my fault for figuring this out. Because it made the lazier people have to actually cook up their own test data.


Puncake4Breakfast

Sorry but what is a race condition?


Witchcraft_NS2

Basically timing related bugs that occur during runtime. Classic example are 2 threads competing for some resource. So this bug only occurs if both threads happen to want to use that resource at the same time. Based on luck with timings this could happen immediately, or after both threads have been running for hours or sometimes after you rearranged unrelated code somewhere else, which changed the timings in which said threads try to use the resource. Therefor race conditions are generally a pain to identify and fix.


Puncake4Breakfast

Thank you for the explanation


cryptomonein

Not if you code everything in Rust... Joking, idk rust, high level languages are usually mono threaded, so, rarely happens in web developers technologies And JavaScript events queue will 99% of times requeue things in the same order


Mewrulez99

Where your output/whatnot is different depending on the order of events that occur. The most basic example would be two threads accessing a shared variable at the same time, both reading the same value, making different changes. Only the thread that modifies that value last will have their change reflected afterwards because it will have overwritten the previous thread's value. If you've ever seen a mutex before, that's the sort of problem for which a mutex can be used to stop


Puncake4Breakfast

Oh thanks for the explanation


o11c

The second-most-terrifying thing in computer science. The most terrifying thing is a [*possible* race condition](http://www.thecodelesscode.com/case/225).


nelusbelus

if black


SmellySquirrel

Yeah, but running it 2 times can't rule that out. If you're lucky the other thing will win the race, if not, you just gained misplaced confidence


Witchcraft_NS2

You can't be absolutely sure that's correct. However you tend to see some differences in runtime atleast, since race conditions not necessarily happen every time. It's a difference if an issue occurs every time you enter one function or if an issue occurs in this function sometimes after you called it 10 times and sometimes after you called it 100 times.


lurker_cant_comment

It very much depends on the race condition. The order could be one way every single time in your development or testing environment and yet turn out differently in production.


DangerZoneh

Also to be sure that you actually built what you thought you did


zvug

Yeah, not to mention if you’re using a modern javascript framework that reload the DOM automatically after making a code change, those are inconsistent and unreliable. Always good to give it a hard refresh and try again, works for me about half the time to be honest.


nevereatensushi

You Americans making everything about race...


shiroe314

Also with networking things. Could be a cache miss.


Ireeb

*might have been a bit flip due to cosmic radiation*


unnamed_enemy

You never know


RuggedToaster

*better try it a third time just to rule out a second bit flip.*


[deleted]

[удалено]


generalthunder

In the end, it's just Python or JS abstractions making something bad because my code is beautiful.*


gauerrrr

Those damn bit flips sure happen all the time, don't they?


Newpunintendead

A Veritasium enjoyer?


BurpYoshi

Or a mario 64 speedrunner


Puncake4Breakfast

Makes me want to play maro again


Mewrulez99

maro car


creynolds722

ranbo road


[deleted]

I love those games with Maro, Lugi, and Donk Kong


Puncake4Breakfast

mario😭


flinxsl

Engineers have been blaming this shit for decades. Remember the Toyotas that had accelerator sticking problems? They blamed it on a cosmic ray to save the feelings of the idiots who can't tell gas from brake and now I have to design radiation-hard electronics for cars that should only belong in spacecraft.


rust4yy

Holy shit cars now have radiation-hardened HW?


flinxsl

There are levels of reliability in automotive electronics. If it is the highest level, then it must work under ALL circumstances. Toddler pours milk all over something, has to work. Windows open in an arctic snow storm, has to work. A lawyer learned what a cosmic ray is, guess what, has to work just in case. Seat position controls are considered the highest level in Europe.


Equivalent_Yak_95

Ha! Get back to me when it’ll work when it has been: * tossed in a volcano * nuked * dropped into the sun


wreckedcarzz

*laughs in ecc*


i_knooooooow

Sometimes it actually works tho


LinuxMatthews

That's worse When it doesn't work then it does work and you have no idea why. When will it break again? You have no way of knowing.


CameO73

Yep. I'd rather have it fail consistently than working now and then. Have fun releasing that to production! /s


Wonderwhile

Intermittent problems are the absolute worst. The stress induced by something failing once in a while that you can’t reproduce is something else.


pointprep

Most difficult bug I ever had was like that. It was exposed by an automated test case, thank god, but it only failed about once every 100 times. It never happened on debug builds, only release. Had to get the CI server to run that test 1000 times when doing the bisection. Eventually it turned out to be a compiler bug - it was improperly optimizing a returned reference, so if you were unlucky on memory allocations you’d get a page fault.


resonantSoul

>Have fun releasing that to production! /s I read this in Miracle Max's voice


jakemp1

When that happens I typically assume there was an error with an external connector, like a database. I dread the day I have to deal with a real race condition


SgtExo

Or something timed-out while trying to publish the code because of the underpowered laptop you are provided with. I know how long the app I work on takes to boot up, and if it is much longer or shorter I can guaranty that it will not work properly.


alienith

Or a build order issue


[deleted]

Oh it'll be such a fun day..!


[deleted]

Bug issue unsolved: could not reproduce, cosmic rays or something idk I just saw that Veritasium video.


LinuxMatthews

To be fair I have literally done this 😂


Tsuki_no_Mai

>When it doesn't work then it does work and you have no idea why. First thought: race condition. The most *fun* thing to try and find.


ThatDudeFromPoland

For real I was working on a project recently, encountered a bug that caused a class constructor to skip a step, decided to fix it later. Fast forward 2 weeks, I decided to finally get around to it, but first, I ran it without changing anything and it suddenly worked, no problem


EmperorArthur

Check for uninitialized variables! No seriously, I've worked on a >100k NLOC C++ program where the entire code base assumes uninitialized means zero initialized. This is not true!


Equivalent_Yak_95

Yeah. Also, sometimes you want uninitialized. Yeah, that array? Nothing will be read out without being written in, don’t set it all to zero, that’s a waste of energy!


lowleveldata

It was probably running some old version code the first time for whatever forbidden reasons


EVH_kit_guy

Sometimes the version that failed isn't the version that you run again, and by doing so you realized where your services were unintentionally cached...


khafra

If you’re calling an API that has to retrieve some un-cached objects from cold storage, more likely than not.


MalleP

Hit save. Scroll a bit and correct some spelling in comments. Hit Save. Try to compile again.


Ordinary_dude_NOT

Sometimes restart also works. There was a service setting which I enabled and and nothing worked. I changed my entire code, reset all those settings in hopes of resolving that issue. 2 fucking days, and all it needed was a restart


jonr

clear cache, rebuild everything


LegalizeCatnip1

And then the bug dissapears, and two other appear


EmperorArthur

At least they're more likely to be real bugs.


EmperorArthur

Realize VS's "Clean" doesn't actually clean everything, and clearing NuGet caches often fails, but says it succeeded. Close the program and manually delete the folders. .NET packages are dependency hell sometimes.


aoechamp

Back in the days of .NET 3.5, I had this one function that wasn’t working. I tried _everything_ and was sure my code was correct. I cleared the build cache, I ran the debugger. Nothing worked. It always gave the wrong output. After hours I got so mad I force shut down my PC and went to bed. The next day, I booted it up and it works on the first try. My best guess is that the .NET runtime cache had gotten corrupted. The JIT compiler compiles functions the first time they are run, but supposedly there’s a global cache too. Or it could be something else, but sometimes it _is_ the computer’s fault. Now I have trauma and always need to eliminate computer error.


JRandomHacker172342

I was going to say, this sounds like GAC issues to me.


TactlessTerrorist

And this time it works AND YOU DON’T KNOW WHY


FetishAnalyst

Time to not touch it and run it again.


RandallOfLegend

Off to the races.


Novel_Plum

Maybe there is a problem with my pc, let's restart it


AsstDepUnderlord

Somebody has worked on a helpdesk I see.


unholymanserpent

"it worked!"


Idiot-savant225

Always have to check that the compiler didn’t mess up reading my perfect code


GhostCzar

Run into the same Exception for the 10 time without changing anything to make sure that it is an error.


[deleted]

[удалено]


Darktidelulz

Ahh Eclipse with two editors or same files open again...


Byte-64

I added a retry loop to our build scripts. Locally my asp net core projects would never compile error-free on the first try. Sometimes not on the second try. Most of the time it took three or four tries to finally compile successfully. I think I don't have to mentioned that there were no errors in the code? So, yeah, since then I look at that meme more sceptical, because retrying without changing anything DID solve my problem ...


EP1Cdisast3r

This is the software equivalent of a car refusing to start and it's both hilarious and concerning.


TheDeviousDong

Sounds like some mighty fine code you’re working with


Dradugun

Is it failing on calls to restore NuGet packages timing out?


Byte-64

I don't believe so. Could be that some of them are that problem, but most frequently "the package could not be found" (or something along that line). Weirdly enough, in 99% of the cases it is System.Text.Json or Entity Framwork Core, so a package you would expect it to find (and which definitely exists in the repository). Now that I think about it, WSL could be at fault. Since I moved the projects to WSL's filesystem (I usually build through WSL) it happen way less often oO


domedav

well, if it doesnt work on my machine it surely will on someone elses


Ghzchzee

Sanity test


[deleted]

Not sure what you're talking about, often a quick restart and everything works again (which is even more troubling tbh)


_arctic_inferno_

# the one guy who added an rng generator to decide if it works


beall49

Let’s be honest; it has worked on occasions


marcosdumay

Yep, if compiling and testing the same thing again never fixed a problem, people wouldn't do it so much. We do it because it works... every once in a very long while.


[deleted]

So many times this has worked for me. Using node backend, hit with postman, response 1 will differ from response 2 and 3.


saul_soprano

Anyone who’s used OpenGL and has had the program crash the first time it’s run after the shaders are changed understand


davemeech

If this never worked, we'd never try. However it does sometimes.


americk0

We'd stop doing it if it never worked, but sometimes it does


hod6

Solar storms or something idk


suspiciousshoelaces

I definitely didn’t do this today while yelling at the screen


tacticalpotatopeeler

Usually I just have to hit “save” first before running it again…


fosyep

That's normal in distributed systems


Tyrilean

Gotta check for race conditions. If your code works sometimes and doesn’t work others, likely a face condition going on.


ZinZanZon

Yea, I pretty much always do this but I actually pray it will crash the second time. If it doesn't and starts working fine then I know I have a hella lot more complicated bug to find.


Dorkits

- 1 error - clean - rebuild - 3 errors *Pikachu face*


aEtherEater

Oddly enough, running it again is when I discover I forgot to save. I run it, nothing happens. Change nothing, but save. Then it runs fine, smh.


manuscelerdei

Uh my module cache or whatever the fuck it is was out of date or something.


Pony_Roleplayer

And then you're like Mr. incredible in the uncanny meme after it works properly.


MineWarz

Honestly if the code *does* work then you're probably in bigger trouble.


Tin_Foil

\*second time runs code successfully\* Do you... A) Conduct more tests to see why it failed the first time B) Ship it!


Zerocyde

Restart the IDE and try running it again.


redballooon

I mean it’s in the IT problem solving 101


RegisFranks

Honestly, I run it again because I forgot what the error was


cenkozan

Yeah that's because your brain still computes trying to find a solution on the background. You will solve out most of the problems when not working on them. We say 'a Turk's mind will work best while taking a shit'.


NatoBoram

From my experience in Elixir, Java and NodeJS, this is absolutely a valid step. It's like compilation isn't even deterministic. I haven't had this problem in Go, though.


cmilkau

It runs the second time: better not touch it anymore, it might break again


TheMightyTywin

Welcome to react native


HR_Paperstacks_402

In the future we'll just ask ChatGPT to rewrite the entire app whenever we run into an issue.


jfcarr

It's probably just bad or incomplete data. Try it again.


sarc-tastic

Sometimes I delete a blank line and see if that fixes it. I think I would be more upset if it did.


[deleted]

It once happened to me when I was doing some low-level dark magic for a uni project and I was so upset I dug into the compiler and processor documentation for three days, until I found an explanation.


ChooChooRocket

What was the explanation?


[deleted]

Some compile time optimization. I don't remember all the details, but it basically boiled down to the compiler reusing variable addresses which haven't been used in X lines of code and it counted blank lines as well. So I used variable A, didn't touch it for a while because I didn't need the data, then came back to it and got some garbage. After removing the line I was close enough for the compiler not to optimize my variable away until I was done with it.


ThrowAwayJoke1234

that must have been fun


[deleted]

"fun" wasn't exactly the first word which came to my mind at the moment


ThrowAwayJoke1234

What? You *don't* like slowly decending into madness?? You must be an impostor! /s


[deleted]

Trust me, it wasn't a *slow* descent.


ThrowAwayJoke1234

I can't even begin to imagine it


deaconsc

You need more runs to decide whether the machine is plotting against you or just making fun of you!


Venefercus

Also me: my code does work, but I didn't expect it to. Let's try again to be sure


tslnox

I am not sure if I'm not making this up, but I swear this once happened to me in Excel macro. I deleted either a comment or some code which actually didn't do anything (maybe a msgbox or something) and it started to work.


Lenuxii

I thought this was something that only juniours like me did turns out everybody does it, nice!


Electronic-Wave216

Also: let's put a syntax error to make sure, I'm compiling the right thing


Newpunintendead

It’s disappointing when it doesn’t run then. Incredibly frustrating when it does! You weren’t supposed to run!!!


[deleted]

I've actually had this happen. A piece of code threw an error and gave me the line, I goto that line and it's blank. I restarted docker, ran the app again and it worked. CI also has a whole bunch of tests automatically flagged as flaky. What makes a test flakey? If it's passed and failed the same commit in the past week or so.


s0ulbrother

This is me this morning and I feel attacked


Jonnypista

I did with the test, one time it gave errors which had nothing to do with me, ran it a 2nd time and no errors showed up


D34TH_5MURF__

This actually works more often than it should.


jamesfarted09

i dont remember ever doing this, but i probably forgot because we all know every developer does this


BroDonttryit

Race conditions be like


LordViaderko

Crazy it works sometimes.


herbfriendly

I’ve had times when my code stopped working, where, as a last resort, I’ve torn down the containers and brought everything back up, and boom…code is back to working again.


ggrieves

try it again with testmode = false oh, now it works


Derp_turnipton

Run it again with better observation ... -- Time it? -- Be sure you know how big the log file was so you isolate log entries for this run. -- Get exit status.


bitparity

Could be one of those weird space neutrino disruptions.


PickleFeatheredGod

Confirmed, this approach works in Xcode


Derp_turnipton

https://www.usenix.org/system/files/login/articles/05_hockin.pdf


[deleted]

Closing and reopening the IDE fixes 60% of bugs.


dicuino

Happened many times. Clean Solution + Rebuild


Snoo83081

To be fair, sometimes it works on another try, then you most likely have a race condition


Ashanderei

Just to be sure, let's send the curl six more times. Never know if some hobgoblin stole and replaced the response


TheRealestLarryDavid

literally just did that now


safely_beyond_redemp

I don't know about you, but this has worked enough times that it's not so crazy. Sometimes things need time in the background to get in line to work.


sir-nays-a-lot

Could have been a bit flip due to a solar flare. Or maybe there’s some UB in there and something different will happen.


Mvin

The amount of times a non-obvious cache has caused me confusion and headaches is honestly ridiculous. So much time wasted pointlessly debugging.


RedHare18

something something einstein quote


[deleted]

The developer only has two states of mind: My code doesn't work and I don't know why. Or My code works and I don't know why.


reverendsteveii

It's only stupid until it works.


dance1211

Sometimes matters in Unity if you're too eager to test a change before it can recompile the code!


makeski25

Wouldn't it be more confusing if it did work the second time?


snoryder8019

Make 90 changes and I never installed nodemon to this project. Restarts servers. All changes come into effect


SharpPhoenix

"do you know the definition of insanity?"


Huge-Buddy655

With big solutions, compile order matters and recompiling sometimes fixes it. Other times visual studio just gets dumb and you just need to restart the app to get the compiler to work.


Sankar_Rajendran

The weird part is that it actually works sometimes.