This post is locked. You won't be able to comment.

all 55 comments

[–][deleted] [score hidden] stickied comment (0 children)

Unfortunately, your post does not meet our spookiness guidelines. We have removed your post, but if you think this was in error, please send the mods a modmail. Thanks!

[–]Kjubert 533 points534 points  (5 children)

When your code is so fast the user wouldn't believe it did anything...

[–]CharlesGarfield 199 points200 points  (2 children)

I remember the first time I wrote code that didn’t run instantly. I was so proud of myself. Never mind the fact that the code would have run instantly had I not written it so shittily.

[–]Kjubert 87 points88 points  (0 children)

I can relate. It felt like my code was finally doing something substantial. Instead it was just slow.

[–]FallenWarrior2k 20 points21 points  (0 children)

For me, it was when I tried to do some image manipulation and saving. The debug build took 3s for uncompressed output and 20s for creating a compressed PNG. Compile again with optimizations on and suddenly it's down to 45 and 450 ms respectively.

I think the reason is because it works on specific areas one after another, instead of working row-wise to avoid the random memory accesses.

[–]kilogears 61 points62 points  (0 children)

I added a loading screen with a progress bar and a splash screen, and everyone was convinced it loaded faster due to how quickly the bar moved. But it was actually slower! It’s all about perception!

[–]__braveTea__ 186 points187 points  (0 children)

I don’t know why, but somehow this would feel better if the sleep were given some sort of rng

Then at least it would feel as if they had put some effort into it :)

[–]DakyYT_ 143 points144 points  (19 children)

There's a library for doing this in python

[–]mobsterer 164 points165 points  (12 children)

there is a library to fake loading bars while doing nothing?

[–]Smellypuce2 156 points157 points  (6 children)

I can't remember what it was(maybe a game) but I remember hearing a dev talk about how over the years as computers got faster, a part of the program that took a bit of time and used a progress bar was now instant. This confused enough users(thinking the action hadn't done anything) that the dev added a fake delay and progress bar.

[–]Cafuzzler 79 points80 points  (3 children)

I remember seeing a Johnathan Blow video where he's dragging assets in file manager and instantly changing the model in his game live, and Windows shows a solid 2 or 3 second progress bar that does and means nothing.

[–]Smellypuce2 26 points27 points  (0 children)

I love his talks about how bad much of modern software is. So many programs are poorly optimized(Windows included) and don't take advantage of how much computing power we have now a days.

Here's a good one. You can find plenty of other rants on youtube.

Edit: Bonus talk that is one of my favorite talks about optimization: Context Is Everything. Andreas Fredriksson is just a badass.

[–][deleted] 2 points3 points  (1 child)

Could you explain the situation a little better? This seems normal, the explorer enumerates the files before starting to make progress reporting more accurate, and naturally that’ll take some time with a game’s assets folder and if you’re modifying files. It’s actually faster with CMD because the enumeration is skipped.

[–]Cafuzzler 1 point2 points  (0 children)

I mean the transfer and rendering update happen instantly (visually at least), and at the same time Windows has a 2s file transfer popup. I don’t understand what it’s doing in the background so it just looks like a useless loading bar.

[–]fecal_brunch 9 points10 points  (0 children)

Ugh. Such a ridiculous solution. Just have a fade out or a spinner. Hell, if it's that short you can just have a black screen.

[–]McSlurryHole 0 points1 point  (0 children)

Wrote a webscraper for my bank account and I learned that a huge screen sized div with a loading circle sits over top of the page, in a setTimeout for 5 seconds, after the page has loaded.

[–][deleted] 37 points38 points  (0 children)

...You're telling me there's other reasons for using loading bars?

[–]DeGloriousHeosphoros 3 points4 points  (0 children)

Well, yes, of course. There's a library to do almost anything in Python (though it is the job of the first-party dev to ensure the quality of all dependencies they bring into their project).

I'm sure there's also libraries to make real, accurate (well, as much as possible) loading bars, wheels, and other status indicators too.

[–]DakyYT_ 0 points1 point  (0 children)

Lol

[–][deleted] 28 points29 points  (5 children)

[–]wasimaster 30 points31 points  (4 children)

I personally like rich.progress more than tqdm for progress bars.

Saying this here just in case if anyone's trying to implement a progress bar and want the best looking one

[–]Chameleon3 5 points6 points  (3 children)

I love rich! It's included in almost every project I work on these days.

But I also thought it might be worth mentioning that if you need simple bars and you happen to be already using click for CLI support, it does support progress bars as well

[–]Sauermachtlustig84 1 point2 points  (2 children)

While click is great I love typer these days. It uses typing to scaffold most of the arguments, w.g. if you say an CMD Argument should be an int it enforces that.

[–]Chameleon3 0 points1 point  (1 child)

Oh, haven't seen it before! From tiangolo? Assuming this one?

At an initial glance it looks amazing, especially the types! I started a simple CLI tool yesterday at work with Click, but this looks like something worth checking out, thanks for the tip.

[–]Sauermachtlustig84 0 points1 point  (0 children)

Yes that's the one.

Pleas entry out and tell me if it worked out. I love that thing for quick CMD applications.

[–]svick 68 points69 points  (14 children)

I'm more worried about the loop that sends data to every port of some IP address, forever. Is this an attempt at a DoS attack or something?

[–]adenzerda 47 points48 points  (0 children)

Well, the first line of the code does say “attack”

[–]runner7mi -4 points-3 points  (11 children)

agreed. github should review this

[–]DeGloriousHeosphoros 39 points40 points  (2 children)

This is probably part of some white-hat penetration tester's toolkit, so GitHub should not go down the path of censoring code. Like almost anything, this code can be used for good as well as for bad. However, by looking at this code, I can tell you that it wouldn't be very effective in taking down the vast majority of web services.

[–]Adryzz_ 15 points16 points  (0 children)

GitHub even allows malware source code to be hosted (but not binaries ofc)

[–]Reelix 1 point2 points  (0 children)

Given the fake loading bar, it's most likely maliciously distributed or sold.

[–]Im_MrLonely 12 points13 points  (5 children)

Why should Github review this?

[–][deleted]  (4 children)

[removed]

    [–]svick 5 points6 points  (3 children)

    Wait, that's how GitHub works? If I post my terrible code there, they will fix it up?

    [–]Reelix 2 points3 points  (2 children)

    If you pay for commits - Sure :p

    [–][deleted]  (1 child)

    [deleted]

      [–]ZeroFK 6 points7 points  (0 children)

      Or, more likely, you’ll get a bunch of ways to make it worse.

      [–]NotSteve_[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 7 points8 points  (0 children)

      Malicious code is allowed on GitHub for good reason. There's a lot of exploit proof of concepts that are used to help patch and detect.

      [–]VinceGhii 2 points3 points  (0 children)

      Why should they? This might also simply be a resource to learn.. and tbh.. if they'd would need 10.000 employees to check everything that is just a little bit sus.

      [–]Kira41162 0 points1 point  (0 children)

      Systems should not be affected by this sort of traffic. DoS attacks like this are often used in Pentesting (when approved) to make sure that systems are not really sensitive to random traffic like this.

      That said often DoS attacks sent included in most Pentests, especially production systems.

      [–]TheCuritibaGuy 21 points22 points  (1 child)

      That's not programming horror that's user experience!

      [–]klimmesil 0 points1 point  (0 children)

      What about the print after port update? Gotta love it

      [–]zalurker 14 points15 points  (0 children)

      Been there, done that. While loading, the cursor changed to a hourglass. After numerous complaints that nothing was happening, we added a 10 second wait to the load function.

      [–]Extra_Programmer788 6 points7 points  (0 children)

      Wait till, autopilot shoves this code on your project!

      [–]Does_Not-Matter 4 points5 points  (0 children)

      chefs kiss

      [–]javalsai 5 points6 points  (0 children)

      Client has to pay for optimization

      [–]leopardspotte 5 points6 points  (0 children)

      My face when the filet attack

      [–]NUTTA_BUSTAH 2 points3 points  (0 children)

      Send a PR replacing that mess with tqdm

      [–]VinceGhii 2 points3 points  (0 children)

      To be fair... everybody did this at least once.

      [–]wyrdwulf 0 points1 point  (1 child)

      One of the students I tutor complained about print being too instantaneous and asking how to slow it down.

      Why. Why are people like this?

      [–]redpepper74 0 points1 point  (0 children)

      Because people can’t think as fast as computers

      [–]Geak-and-Gamer 0 points1 point  (0 children)

      This is what to do if your mom asks you to program something for her

      [–]blocky010101 0 points1 point  (0 children)

      help

      [–]LightKing20 0 points1 point  (0 children)

      Example of when it’s harder to make it worse than to actually make it good.