r/programminghorror • • Feb 27 '21

This collection of curly brackets

Post image
7.2k Upvotes

114 comments sorted by

9

u/TheOneWhoWil Feb 28 '21

Is this a real rest api?

7

u/[deleted] Feb 28 '21

Yes

844

u/lor_louis Feb 28 '21

20

u/tech6hutch Feb 28 '21

I missed the “al” part of it at first glance...

6

u/ChronosCast Jul 22 '21

“Status 409” actually sounds like a cool title

4

u/QuislingsAnswer Jan 02 '22

She's real fine my Status 409?

3

u/mardabx Jun 25 '21

Nor for long.

1

u/von_roga Sep 07 '22

Who is Fake Al and why does he make bum covers?

200

u/[deleted] Feb 28 '21

[removed] — view removed comment

77

u/Papriker Feb 28 '21 edited Feb 28 '21

On it!

Edit: I came to the conclusion that I‘m bad at making music and will rather keep on doing bad programming

5

u/FreddyBannana Mar 27 '21

FreddyBannana give song as well as bannanas. FreddyBannana try

442

u/LaLiLuLeLo_0 Feb 28 '21

This looks like a lonely bit of code, floating in an empty orbit in space, millions of miles from anything else

944

u/Reeceeboii_ Feb 28 '21

.           ✦             ˚              *       

                .              .            ✦

             ‍ ‍ ‍ ‍                  ,      

.             .   ゚      .           ☀️client waiting

,       .                                  

          .           .             .

                                                       ✦

       ,               🚀 else{ res.sendStatus(409) }       ,    ‍ ‍ ‍ ‍  

            .        

   .                                             ˚ 

      ,                                       .   

                  .             .               *

           ✦                              

                .                  .           .

       .     🌑              .           . 

˚                     ゚     .               .

     🌎 ‍ ‍ caller ‍ ‍ ‍ ‍ ‍ ‍ ‍ ,                *

.                    .           ✦

˚              *       

                .              .

112

u/[deleted] Feb 28 '21

This is beautiful, thank you.

37

u/Kalle_022 Feb 28 '21

No, you're beautiful

Wheel of Time fan?

7

u/seedBoot Feb 28 '21

You WoT mate?

6

u/Kalle_022 Mar 01 '21

I WoT hard mate

4

u/Reeceeboii_ Feb 28 '21

You are very welcome

14

u/joemckie Feb 28 '21

I want this on my wall

26

u/[deleted] Feb 28 '21

🏅

5

u/[deleted] Mar 06 '21

If you make this frameable and put it on Etsy for less than $40, I WILL buy this.

3

u/[deleted] Nov 27 '21

how the hell

1

u/colby_2020 Jan 04 '24

This is the exact opposite aesthetic of r/programminghorror and I love it!

265

u/Mc_UsernameTaken [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Feb 27 '21

When I find a callback hell like that everynow and then, I'll take some time to grep it all out and see what all the curly braces looks like.

184

u/[deleted] Feb 28 '21

[removed] — view removed comment

2

u/colby_2020 Jan 04 '24

I think there’s a vscode extension to match curly braces and parentheses

55

u/pau1rw Feb 27 '21

Even without seeing the rest I know it's gonna be a horror show.

41

u/KaranasToll Feb 28 '21

And people say lisp has too many parentheses

33

u/CJSZ01 Feb 28 '21

Reminds me of Flutter

24

u/Ramaness Feb 28 '21

Ohh this looks like a piece of art

5

u/passwordisoptional Feb 28 '21

Seriously. If someone makes a full size version, I'd use it as a phone background.

104

u/PhatOofxD Feb 27 '21

That's why you async await...

89

u/BakuhatsuK Feb 28 '21

That doesn't even look like callback hell. In callback hell you have a lot of }) instead of bare }.

This looks like it needs some early returns and extracting some code to their own functions.

23

u/NiQ_ Feb 28 '21

Oh god you’re right... and they’re obviously not using a linter as the top line has }), with other nested lines having them separated.

15

u/Mckol24 Feb 28 '21

Actually there are } ) they're just on separate lines.

3

u/Denaton_ Mar 10 '21

Actually, the first one is }) and then it's

} } )

Pattern

12

u/[deleted] Feb 28 '21

There are some) in there.

1

u/Rinehart128 Mar 05 '21

What is that? What’s happening here?

22

u/jailbreak Feb 28 '21

I think you accidentally did an art

12

u/NabrenX Feb 28 '21

This is the stuff of nightmares. I would probably quit.

11

u/revrenlove Feb 28 '21

Yo dawg, I heard you like closures, so we put a closure in your closure in your closure in your...

1

u/grammatiker Feb 28 '21

Not even Closure would have this much nesting

7

u/Kaze_Senshi Feb 28 '21

Send status 409 brackets

7

u/Blexit2020 Feb 28 '21

I just want to know what the "if" was. Seeing them separated like that is just heartbreaking. They should try to work on their issues and get back together.

42

u/rogue_potato420 Feb 27 '21

Javascript do be like that sometimes

26

u/rift95 Feb 28 '21

If you write it poorly.

There's also nothing really stopping you from writing the same mess in many other language.

5

u/mgrasso75 Feb 28 '21

So lonely 😢

5

u/Sciman1011 Feb 28 '21

Looks like modern art

5

u/[deleted] Feb 28 '21

That too to send 409 my god something evil is happening there.

16

u/plainrane Feb 28 '21

Imagine being this scared of async/await

0

u/[deleted] Feb 28 '21

[deleted]

4

u/[deleted] Feb 28 '21

Perfect r/badcode candidate

4

u/shizzy0 Feb 28 '21

Son, you done used up all the curly braces.

4

u/DoobyMcFoosen Feb 28 '21

I've been working in CS for 7 years, and there's something I still don't understand about it.

  1. [ ] — brackets

  2. { } — braces

  3. < > — diamond or wickets

If we already have unique names for these grouping symbols, then why do we call (2) 'curly brackets'? What is it about the word 'brace' that's confusing?

9

u/TheOldTubaroo Feb 28 '21

They can all be called brackets as well:

  • () round brackets, or just brackets in some places

  • [] square brackets

  • {} curly brackets

  • <> / ⟨⟩ angle brackets

Personally I prefer the version with unique names, though I still call <> "angle brackets" (or occasionally "chevrons", but that usually means «»).

2

u/Nafferty Feb 28 '21

I've met people who honestly only ever heard "curly bracket", so I stick with using it to avoid confusion for them. It might be clunkier, but sometimes you don't know who the audience is going to be. Might as well not get someone who might be listening hung up on that small detail.

4

u/bilbopoop Feb 28 '21

"Refactor this method to reduce the Cognitive Complexity from 148 to the 15 allowed."

1

u/apetc Feb 28 '21

Is it weird to sometimes comment these or unindents (in Python) when there's a lot in row so I know what block is ending?

1

u/[deleted] Feb 28 '21

I just use the vscode color extension

2

u/fnordstar Feb 28 '21

It means you should be using functions.

1

u/Denaton_ Mar 10 '21

It's not matching the open and close (curly)brackets

1

u/[deleted] Jul 09 '21

There is more

1

u/Beginning-Leg-7621 Mar 17 '21

I refuse to believe this is real

1

u/[deleted] Jul 09 '21

It was

3

u/FxHVivious Feb 28 '21

Just... Why?

0

u/[deleted] Feb 28 '21

[deleted]

4

u/FxHVivious Feb 28 '21

To be honest, I'm just about to start my first job in industry, so I'm not super experienced outside of school, and I've never seen a string of brackets like this before.

3

u/la102 Feb 28 '21

. Then. Then. Then. Then. Then

2

u/Kafshak Feb 28 '21

I thought it's one of those time lapses of moon rising.

2

u/stulleman Feb 28 '21

Callback hell

2

u/tamafuyu Feb 28 '21

lmao and just that else in the middle of it

2

u/schteppe Feb 28 '21

Should have used early bailout.

2

u/ososalsosal Feb 28 '21

This is art.

It's like a haiku in code.

Or some kinda zen koan of shit.

2

u/Irtexx Feb 28 '21

Can somebody please recommend a design pattern to replace deeply nested if statements (what this pic likely is) I.e. For when you have multiple preconditions you want to check before doing something. I've tried using an "And" instead of nested ifs, but then you cannot match each if with its own else, which is useful if you want to log or print to the console the reason why the precondition failed.

2

u/ssjskipp Feb 28 '21

Couple ways, easiest is mentioned below (exit on failure and continue on not -- this is the same as making assertions instead of conditions).

Another way is similar and utilizes the idea of a Either[L, R] monad where one side is an error and the other is the value. The idea being you have assess to choose which side to map on, and can chain logic.

In JS, promises act like this (failed promises fall through to a 'catch' or a consuming 'reject'). In F# there's this bit on "railway style" https://fsharpforfunandprofit.com/posts/recipe-part2/

1

u/No_Animator_8599 Dec 15 '22

I would just break it down by calling a new method so it becomes easier to manage. I worked in multiple languages and found if/else statements with too many conditions a nightmare to work with.

0

u/[deleted] Feb 28 '21

[deleted]

2

u/Irtexx Feb 28 '21

That's a good idea, cheers.

2

u/Dr_Peopers Feb 28 '21

Just do }}}}}}}}}}}}}}}}} somewhere nobody needs to see it

2

u/thatdude473 Mar 04 '21

We’ve all been there lol

2

u/4BDUL4Z1Z Nov 23 '21

It's Just an Else Block doing Belle Dance.

2

u/Additional-Second630 May 19 '22

It’s springtime. Busy nesting period.

2

u/evilgunringer May 23 '22

This person needs to learn guard casing.

2

u/aligdev Oct 09 '22

The Galexy of curly brackets

2

u/tintin10q Mar 29 '23

The 409 makes it so much more cursed as well. Like when your sending 409 you are much deeper than is probably fun.

3

u/[deleted] Feb 28 '21

I’m conflicted about this

1

u/FrozenOnPluto Feb 28 '21

This is like Night Drover on the Atari 2600. Maybe more fun too ;)

1

u/[deleted] Feb 28 '21

I want to frame this and put it on my wall.

1

u/mrunderbriefs Feb 28 '21

I sense some conflict. ;-)

1

u/[deleted] Feb 28 '21

Taking social distancing a bit too seriously there...

1

u/Sosowski Feb 28 '21

this is why I use gotos

1

u/cyberspacedweller Feb 28 '21

Looks a lot like an old space game from the 80s

1

u/J-Squeeze Feb 28 '21

“Small SEASONED curlies”

1

u/mothzilla Feb 28 '21

Weeeee oh no weeeeee!

1

u/[deleted] Feb 28 '21
  • angry uncle bob noises *

1

u/ocramoidev Feb 28 '21

pov you "don't like" oop

1

u/robertmia Feb 28 '21

Where is the human transcriber who has to type this out?

1

u/leshrec2 Mar 02 '21

If I see someone write this we're gonna have a 409 Conflict

1

u/createthiscom Mar 05 '21

Ah, modern art.

1

u/letsdebugit Mar 05 '21

Reaching for the stars!

1

u/[deleted] Mar 09 '21

Reminds me of Led Zeppelin's Staiway to Heaven !

1

u/urnotbeanz Mar 20 '21

I see nothing wrong here :P

1

u/[deleted] Mar 29 '21

It's like Toizeraman's poly-A tail!

1

u/LongLiveCHIEF Jul 15 '21

I really hope this is the kind of code they trained co-pilot with.

1

u/Jumpy-Economist Mar 22 '22

How do you avoid a huge chain like this? I've often had larger programs where the bottom can look like this

1

u/[deleted] Apr 20 '22

Yandev moment.

1

u/[deleted] Sep 13 '22

glider gun moment

1

u/[deleted] Nov 12 '22

Should've used Fibonacci indentation

0

u/[deleted] Feb 28 '21

[deleted]

3

u/[deleted] Feb 28 '21

No guard keyword in js sadly

9

u/manghoti Feb 28 '21

I'm not familiar with the guard keyword. But guard constructs work ok in JavaScript, just invert your ifs and then early escape.

2

u/[deleted] Feb 28 '21

Aye. Check out the guard keyword in Swift. I think it's pretty neat.

0

u/[deleted] Feb 28 '21

[deleted]

3

u/[deleted] Feb 28 '21

Gotcha. I'd never heard the term guard clause even though it's something I regularly do in my code. In swift there is an explicit guard keyword that allows for optional binding and forces you to exit the function if your guard condition fails.