this post was submitted on 09 Jul 2023
35 points (94.9% liked)

Programmer Humor

32411 readers
351 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 18 comments
sorted by: hot top controversial new old
[–] [email protected] 6 points 1 year ago (1 children)

When I’m doing coding interviews I always like to start off and say I’m a big fan of very long variable names. “As descriptive as you can be” I say. Then I get to my first for loop. Instead of i I use “iterator” and then when I start a nested loop I use “jiterator” and it always gets a laugh.

[–] [email protected] 0 points 1 year ago (1 children)

I used to conduct coding interviews at my old job. If someone came in and had some humor like that, it would be big bonus points in my book. Being someone I would like to be on a team with is very important. Plus, I think it shows confidence and being comfortable in situations that make most people nervous.

[–] [email protected] 1 points 1 year ago (1 children)

I've been at two start ups and they had me interview people. Honestly this is what I looked for. I'd ask basic questions to prove you had an idea about coding, but I can teach someone to code, I can't teach someone to be someone I like working with.

[–] [email protected] 1 points 1 year ago

You can teach them to code if there is an underlying level of logic to build off. I’ve met a few people in life who I know for a fact will never code, no matter how smart they generally are.

[–] [email protected] 5 points 1 year ago* (last edited 1 year ago) (2 children)

i is for index. j is simply the next letter and we're too lazy to think up something meaningful

[–] [email protected] 1 points 1 year ago (1 children)
[–] [email protected] 1 points 1 year ago (1 children)
[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)
[–] [email protected] 1 points 1 year ago (1 children)

I always thought it stood for iterator

[–] [email protected] 1 points 1 year ago

I sometimes use it for "item", knowing full well its established meaning as index or iterator, because I'm a rebel.

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

It depends. x and y are either elements or coordinates, a and b usually elements though in e.g. Haskell reserved (by convention) for type variables.

The i j k l series is reserved for indices. n m etc. are the counts of something, as such you'll see i counting up to n. Both are due to mathematical sum notation and general mathematical convention. Random google result:

Let x~1~, x~2~, x~3~, …x~n~ denote a set of n numbers. x~1~ is the first number in the set. x~i~ represents the ith number in the set.

...if you're using a language in which you use i often chances are you should stop coding in C and get yourself a language with iterators. Manual loops are a bug magnet.

[–] [email protected] 1 points 1 year ago

don't mind i but personally always use index or x, y, z for games

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

I used starcraft references in mine till the project lead demanded I knock it off.

The protoss quotes were perfect.

[–] [email protected] 0 points 1 year ago (1 children)

People who name iterators with one letter have no soul.

[–] [email protected] 0 points 1 year ago (1 children)

And people who iterate over 3D space using firstDimensionIndex, secondDimensionIndex, and thirdDimensionIndex instead of x, y, z have no sense 😜

[–] [email protected] 1 points 1 year ago

x, y, and z are absolutely fine for spatial addressing.

[–] [email protected] -1 points 1 year ago (1 children)

A useful tip I picked up was to use ii instead of j for an inner loop. It's far more distinct than j.

If for some terrible reason you have even more inner loops you can easily continue the trend i, ii, iii, iiii, iiiii - or iv, v if you're feeling roman

[–] [email protected] 1 points 1 year ago

When you have multiple indices you're also bound to have multiple cardinals those indices count up to, say foo.length and bar.length, so foo_i and bar_i are perfectly legible and self-documenting. A bit Hungarian but Hungarian is good in small amounts. Unless you're dealing with width and height in which case it's x and y but it's not that width_i would be incomprehensible.

load more comments
view more: next ›