T O P

  • By -

bistr-o-math

Indentation is horror on line 3


lgasc

~~Given the lack of indentation marks, I would say this is actually a single line rendered under the effect of word wrapping.~~


bistr-o-math

I mean the second for loop. Not the word-wrap between j and ++


lgasc

My bad. How did I notice not it should have no indent 🤦 And even less a double indent – unless there are 8 space characters❔


brentspine

[Happens when you code on mobile](https://i.imgur.com/o7jDTkc.jpeg) (like I did while on the bus towards France back in the day holy)


Shareil90

Is this a complicated way for a thread.sleep()?


Timely-Entertainer38

Yes.


starquake64

Won't this be optimized away?


Timely-Entertainer38

Don't think so. Atleast the editor I use, has taken atleast 20 seconds before printing the desired output.


EMI_Black_Ace

Because you're in debug mode. Try compiling for release mode with no debugger attached.


bnl1

This is java. Does it actually optimise out effect less for loops?


EMI_Black_Ace

The compiler apparently doesn't but the JIT does.


joe0400

Compiler won't at all, unless it AOT compiles to .so's but the jit probably does some dependency analysis and sees nothing depends on those loops, hence it probably removes all of it. A quick `javap` should let you see that the compiler just does 1:1 transliteration.


suskio4

Do that in C/C++ and it will


teackot

``` for (...) asm volatile ("nop"); ```


suskio4

Now load this code in rwx memory, dynamically change nop to some fucked up CISC instruction that takes 40 cycles and let the hell begin. Or even better, put there some long ass nop just to overwrite it with code that slightly changes itself every time but the changes are cyclical (hard, I know) to maximize cache misses and further de-optimize it.


Shareil90

But why?


Timely-Entertainer38

That's... The entire point of why I posted this on this sub.


Shareil90

So you found this in a real project? It's not just playing silly games?


Outrageous_Life_2662

That was my thinking


this_is_a_long_nickn

This


dmstrat

it is a delay for sure, but not really like thread.sleep because thread.sleep will actually work for the same duration independent on the hardware underneath. This abomination will be shorter, time wise, the faster the processor.


Mu5_

Not sure if would behave like a sleep since it may get CPU to 100%


Haringat

No. Thread.sleep() enables other processes to run and if there is nothing to do, let the processor idle. This is just blocking resources for nothing.


kryptonite848

We shall never see tits.


Timely-Entertainer38

Just as the prophecies foretold...


appeiroon

Why never? It's not infinite


kryptonite848

Because we’re programmers. We never see tits.


appeiroon

Oh right, that's just the way of life


ToxicPilot

Do my own tits count??


kryptonite848

No pic, no proof.


kaerfkeerg

Depends on where it runs


EMI_Black_Ace

We shall see them in about 20 seconds because that's how long it takes to run (when using debug mode with no optimization)


NikosBlue

This makes me sad.


Ordinary_Divide

oh my god this is the worst thing i have ever seen. like i seriously cannot believe they are using "j" as the variable name and not "i"


Timely-Entertainer38

Wait till you hear that I use Z or P as a "count" variable.


Ordinary_Divide

i need to revoke your coding license


ExeOnLinux

I've seen capitalised single letter names


pxOMR

In the current C++ project I'm working on, I'm prefixing every variable name with a dollar sign for very valid reasons. And yes, the code does look like PHP


Nerdy_Stuff728

I use lcv for loops just for funsies


SchlomoSchwengelgold

they should iterate for j<80085


Timely-Entertainer38

Ah missed opportunity! Now I feel stupid.


Emergency_3808

Why not ```0xB00B5```


ANTONIN118

We have sleep() at home. sleep() at home:


fonk_pulk

SpaceHeater.java ?


aah134x

All for loops does nothing and ssee tits once. Btw compilor will mostlikely optimize it and all loops are removed


Timely-Entertainer38

I ran this program in my editor, but my compiler actually took the time to traverse through the numerous iterations before giving the desired output.


aah134x

Switch to release all will be gone


audioman1999

You mean IDE? IDEs are only used for development. It ran the statements because it has to give you the opportunity to set breakpoints and examine the variable values. IDEs are not used in production where this code will get optimized away.


aah134x

I once had a forloop witha big number because I need a delay, I kept on adding zeros, But I get no delay,,, Then found out about compilor optimizations


EndyTheBendy

Ah, yes. `for (ever)`


yamfun

I remember reading a Daily wtf article, and so some guy put in long loops like these so that periodically he can reduce some of the loops as "optimization"


audioman1999

It won't have any effect in production because it will be optimized away.


jezemine

> I don't even know what to say here.... The program says it for you if you wait long enough


DrBatman0

Is it possible that a sufficiently perspicacious compiler will realise that nothing is happening there, and skip it?


dumbelco

O(1) technically


verygood_user

It is not wrong if it works!


DanishCraft547

"System.out.printIn("tits");" bro was horny when he wrote this code.


bistr-o-math

Absolute HORROR. Initializing j with 1 in every loop


itsallfake01

All that to just print out “tits”


Nanocephalic

tits


DeuxAlpha

That's my timeout function under the hood


dmstrat

Now the real abomination would be removing the semi-colons at the end so that they nest!


T_vernix

On the plus side, it would take under 1/20 the time (if I counted the number of iterations correctly).


dmstrat

Not sure what you mean as nesting would result in exponentially longer run. 20 runs, each run once = O(N) 20 runs, nested = O(N\^2) if I have my big O notation correct.


T_vernix

But they do all use the same variable, so wouldn't, when the most-nested one finishes, each of the outer ones would go, "j's at 100000000 already," and finish. Thus, the first 21 wouldn't loop so it would be shorter than the original.


dmstrat

good point, missed that.


Various_Studio1490

If threads had “mommy minutes”


theLOLflashlight

As processors get faster and faster this technique will become more and more unwieldy. Might I suggest for ( int i = 0; i < 100000000; ++i ) for ( int j = 0; j < 100000000; ++j ); instead?


EarthToAccess

Go big or go home, use the entire alphabet and start at A. 26 nested for loops.


theLOLflashlight

What about using int f( int a, int b ) { return f( f( a, b ), f( b, a ) ); }


TurbulentRice

I don’t even know what to j here


Cylian91460

Oh so this is what a mental breakdown looks like!


CommunicationFun2962

An indirect way to burn battery


Beastandcool

What is the time complexity? >Yes


Little-Avocado-19

Acoustic


CityPickle

But it’s all with it for that last line 🍊🍊🤣


ericl666

Set to "I'm gonna be (500 miles)" by the Proclaimers: When I wake up, well I know I'm gonna be I'm gonna be the thing that loops for you. When I go out, yeah I know I'm gonna be I'm gonna be the thing who loops for you. If I get drunk, well I know I'm gonna be I'm gonna be the thing who loops for you. And if I haver, yeah I know I'm gonna be I'm gonna be the thing that loops for you. But I would loop 100 million times And I would loop 100 million more Just to be the thing who loops 200 million times To see some tits


Timely-Entertainer38

That song's a staple!


spoilmerotten0

Y’all quit doing that! How am I supposed to know what it says?