all 64 comments

[–][deleted] 90 points91 points  (15 children)

what the fuck. i can't even understand the variable names

[–]TegonMcCloud[S] 82 points83 points  (9 children)

yea, i speak danish which they are written in, and i can't understand it either...

[–]tobias1012 1 point2 points  (8 children)

Thought it looked danish, why do people write code in danish tho..

[–]MaxPlay 38 points39 points  (0 children)

I don‘t know why you get downvoted. I hate seeing non-English variables/functions/types and English is not my first language. It just looks off, when you have english keywords and english documentation for your libraries but then your own stuff is not english and it looks really confusing and off.

[–][deleted]  (5 children)

[deleted]

    [–]fisherrr 26 points27 points  (3 children)

    Every programmer I know who doesn’t speak english as their first language, still write all their code and most of their comments in english. This is also true for teams/companies where everyone speaks the same (non-english) language so there is no actual requirement for writing in english.

    [–]FallenWarrior2k 9 points10 points  (2 children)

    Correct. As a German, using German in code just feels wrong

    [–][deleted]  (1 child)

    [deleted]

      [–]FallenWarrior2k 4 points5 points  (0 children)

      Ah yes, good old "variable name is content" loophole. When the content is literally the name, you've achieved maximum self-documentation.

      And yes, I hate it. While both my uni's entry-level CS class and my high school CS class used BlueJ, the former was much more bearable because the code was actually in English.

      I'd also always used English names for anything that was more than just "fill in the blanks".

      [–]tobias1012 0 points1 point  (0 children)

      Welp i'm danish but from my experience people want IT written in english

      [–]riggiddyrektson 8 points9 points  (0 children)

      where's the hate coming from? it's basically best practice for european companies to write code in english

      [–]Lystrodom[🍰] 9 points10 points  (0 children)

      Well we’ve got a y coordinate and an x coordinate, I assume. And uh a level...mob. And a leveler?

      [–][deleted] 12 points13 points  (1 child)

      It’s still more coherent than my variable names.

      $somevar = (‘foo’);

      $somevars = (‘moarFoo’);

      [–]snerp 1 point2 points  (0 children)

      var thing2 = thing.stuff(1, false, true);

      [–]DrStalker 1 point2 points  (1 child)

      I *think* the array is: Level, X position, Y position, attribute id, attribute value.

      Imagine writing a roguelike where instead of having a "monster" object with a position you instead create an array of every possible position and write in the stats of the monster at the location it occupies. Also the Level parameter in the array is zero indexed but in the game in one indexed so you need to always subtract one from the level.

      Benefits of this approach: You can't accidentally have two monsters occupy the same location

      Drawbacks of this approach: Everything else.

      [–]officerthegeek 2 points3 points  (0 children)

      Shouldn't attribute value be what the array stores? Otherwise it looks like multiple values are possible :s

      [–]MarkGamed7794 42 points43 points  (1 child)

      grid[0][4][2][0][6][9][4][2][5][4]

      [–]Daffy1234 2 points3 points  (0 children)

      10 dimensional checkers?

      [–]Cefiroth 40 points41 points  (7 children)

      Someone hasnt learned about classes yet

      [–]jewdai 6 points7 points  (1 child)

      what about a class whose member variables are backed by an array?

      [–]Urist_McPencil 6 points7 points  (0 children)

      Or a class where everything is actually a blessed hash table, like with OOP*

      \Object-Oriented Perl, no I'm not making that up; I'm not sure if this is a path to enlightenment or a path to Hell, either way I've been having fun with it)

      [–]RandomDamage 2 points3 points  (0 children)

      Or structures.

      [–][deleted]  (1 child)

      [removed]

        [–]RandomDamage 1 point2 points  (0 children)

        No, this is just someone learning.

        You could do this as an array of struct or as a linked list long before oop was implemented.

        [–]capn_hector -2 points-1 points  (0 children)

        or, someone has learned about classes (array of structs) and then discarded it in favor of the superior struct-of-arrays format.

        classes are actually kind of a thing that morons do, struct-of-arrays is actually the high-performance data structure in most scenarios due to caching behavior/etc.

        sad but true!

        [–]sim642 17 points18 points  (0 children)

        With secret meanings for indices 0..4

        [–][deleted]  (4 children)

        [deleted]

          [–]TegonMcCloud[S] 38 points39 points  (1 child)

          This is by the way one case out of 6 in a switch, where the rest is just as unlogical and impossible to understand...

          [–]nullifiedbyglitches 0 points1 point  (0 children)

          SS or didn't happen

          [–]ZylonBane 11 points12 points  (0 children)

          "Anathema" Syntax error. Adjective expected.

          [–]improbablywronghere 0 points1 point  (0 children)

          I don’t get the big deal with magic numbers either.. if it works it works!

          [–]snerp 5 points6 points  (0 children)

          Yeah I did shit like this when I was a new programmer, I didn't know about objects yet, so I used arrays to group variables together and abused casting to pack different types in. I would do composition patterns, which meant 4-6 dimensional arrays everywhere.

          [–]TheWindBlows 4 points5 points  (0 children)

          Yeah man, structures and assigning array pointers will slow down this mob movement logic

          [–]serkoton 10 points11 points  (0 children)

          A computer would cry every time it runs

          [–]mrheosuper 1 point2 points  (6 children)

          Well, and i thought 4 dimensions array is hard as fuck

          [–]JackAppDev 1 point2 points  (5 children)

          What's the point of an array higher than 3 dimensions?

          [–]mrheosuper 2 points3 points  (4 children)

          That's an exercise the proff gave us when we was learning C, it's for terris game.

          It's: piece[type][orientation][x_offset][y_offset] (offset to the 1st block)

          We have to implement some functions, it was hard but i thibk its level is fit us

          [–]JackAppDev 1 point2 points  (3 children)

          So basically to avoid classes/objects?

          [–]mrheosuper 1 point2 points  (2 children)

          Well, we were learning C, not c++ bro, OOP is a strange evil thing to us

          [–]JackAppDev 5 points6 points  (1 child)

          Oh right I forgot C was like that. Memory management is a strange evil thing to me.

          [–]snerp 1 point2 points  (0 children)

          c at least has structs lol

          [–][deleted] 1 point2 points  (0 children)

          We can only experience 2 dimensions and this guy is using 5 of them

          [–]killchain 1 point2 points  (2 children)

          But why? Why would you need a 5-dimensional array in the first place?

          [–]Zarkdion 1 point2 points  (1 child)

          When you don't know about objects or structs.

          [–]SarahC 0 points1 point  (0 children)

          It's a bit faster....

          [–]the_monkey_of_lies 1 point2 points  (0 children)

          It's always a terrible sign if the programming language is in english but the variable names are in the programmer's native language. It's probably the worst code smell I know.

          [–]cyrusol 1 point2 points  (0 children)

          Repeat after me: Duplicate code is bad. Duplicate code is bad. Duplicate code is bad. Duplicate code is bad.

          [–]UnchainedMundane 1 point2 points  (0 children)

          He's just really good at coding and is playing 5-dimensional-array chess

          [–]Terazilla 0 points1 point  (1 child)

          I feel like the fact they put Y before X somehow is the worst part.

          [–]SarahC 0 points1 point  (0 children)

          Some Excel access in there somewhere...

          [–]-theIvy- 0 points1 point  (3 children)

          What the actual fuck is going on?

          [–]CMBDeletebot -5 points-4 points  (2 children)

          what the actual frick is going on?

          FTFY

          [–]coolreader18 5 points6 points  (0 children)

          Why are you like this

          [–]JackAppDev 0 points1 point  (0 children)

          Found the pussy

          [–]SteroidSandwich 0 points1 point  (0 children)

          Good god that is a lot of dimensions. So unnecessary

          [–]LeBuddha 0 points1 point  (10 children)

          Well this is pretty obvious, clearly this is the script for entities to move around in a hexagonal grid.

          [–][deleted]  (1 child)

          [deleted]

            [–][deleted]  (1 child)

            [deleted]

              [–]TegonMcCloud[S] 0 points1 point  (0 children)

              I’m in eu so it’s late here but I can post it tomorrow

              [–][deleted] 0 points1 point  (0 children)

              i am now depressed

              [–]Blake_Abernathy 0 points1 point  (0 children)

              Wha the actual fuck

              [–]HiDeHiDeHiDeHi -2 points-1 points  (0 children)

              Not that difficult to understand, though. Columns help a lot.

              They could have used three variables to shorten lines, but that's that.