r/shittyprogramming • • Apr 23 '19

Space efficient & lines up nicely

Post image
521 Upvotes

58 comments sorted by

View all comments

Show parent comment

4

u/[deleted] Apr 23 '19

I just love how when you read from top to bottom you get the "stuff" first and then the context, that feels pretty natural to me.

18

u/Cathercy Apr 23 '19

You think it does, but if you were actually working in a language that did this, you wouldn't like it.

You would just be reading arbitrary code wondering what its purpose is until you get to the bottom. Then go "ohhh, that's what this function is for". In reality, you would just end up scrolling to the bottom of the function before you began reading the content of the function, because you need that context to even want to read the rest of the function.

4

u/[deleted] Apr 23 '19

Good point, probably the reason ive never seen this before.

3

u/[deleted] Apr 23 '19

Yeah, and in the inverse, the most important stuff comes at the bottom because it depends on everything else in the file, it makes it easier to follow that natural progression of "how do we get here"

3

u/[deleted] Apr 23 '19

Exactly.

5

u/[deleted] Apr 23 '19

Here's a fun one, single statement ifs:

do_thing()
    if (x);

Borderline Ruby

0

u/[deleted] Apr 23 '19

[deleted] — view deleted comment

3

u/[deleted] Apr 23 '19

Maybe I do need to try ruby sometime.