There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

ashishlotake ,
@ashishlotake@mastodon.social avatar
fubo ,

Fortran, really.

In Fortran, variables beginning with the letters i through n have integer type by default, whereas all other letters imply a real-number (floating-point) variable. You can change this by declaring a type, but using i for a real is non-obvious.

(Hence the old joke, “God is real — unless declared integer.”)

relative_iterator ,
@relative_iterator@sh.itjust.works avatar

Interesting. I assumed i for iterator.

fubo ,

i, j, k are commonly used as subscripts in linear algebra, too.

Eufalconimorph ,

i^2 = j^2 = k^2 = ijk =-1

eager_eagle , (edited )
@eager_eagle@lemmy.world avatar

idk, this arbitrary i-n range behaving differently than other variables sounds like a terrible source of weird bugs to me. I don’t think variable names should ever change a program’s behavior.

edit:

Many old Fortran 77 programs uses these implicit rules, but you should not! The probability of errors in your program grows dramatically if you do not consistently declare your variables.

source

Successful_Try543 ,

This comes from early years, when FORTRAN was introduced and the programmers needed to save space in the punch cards. Today, to avoid this possible source of bugs, you usually state “implicit none” in the preamble.

GregoryTheGreat ,

So I’ve been an engineer doing code ports to newer versions of Fortran. I never knew why that was at the top of every file. Thank you.

juliebean ,

in programming, and in mathematics, it’s always been weird to me that frequently paired variables are basically the most easily confused for one another pairs, especially when written quickly or sloppily.

  • i and j
  • x and y
  • m and n
eager_eagle ,
@eager_eagle@lemmy.world avatar

exactly, this is so annoying. I don’t know by first-hand experience, but I also think p and q are confusing for dyslexic people.

rolaulten ,

Interesting footnote about p and q. You see them turn up on formal logic proofs (for philosophy)

juliebean ,

i knew i was forgetting some other common pairings, thank you. p/q and u/v always bugged me too.

VisualBuilder4 ,

u and v were so difficult for me to differentiate in handwriting. My handwriting is not that pretty and the difference between a round bottom and a sharp bottom is not that big when stressed in an exam.

Successful_Try543 ,

Like in math: given are the vector fields u, nu and v and the normal vector n …

reverendsteveii ,

I think your problem is with the alphabet, friend

collegefurtrader ,

M as in mancy

Sam ,

I always like to joke in coding interviews that I really like to make variable names as long as I can so they are very precisely named. Then when I get to a double nested loop I hit them with iterator and jiterator instead of I and j

eager_eagle ,
@eager_eagle@lemmy.world avatar

Unless they’re indices, do yourself a favor and use meaningful names instead.

I avoid index iterations the most I can tbh. And for nested loops,i and k is more readable.

tkarika ,

This is the way.

fidodo ,

Even for indexes I do index or something more specific for what it’s indexing. Any simple iteration I just do map or each so the only time I ever need to actually index things is for more complex scenarios in which case it’s worth it to have better names. Also with modem IDEs, auto complete is really good so you don’t need to write a full variable name more than once.

reverendsteveii ,

When I was a baby coder back in the 90s we were taught that these names were meant to save space in the symbol table because at one time space was so limited that naming your variable n rather than numElementsInArray would have an impact

GodIsNull ,

i for index or iteration. Using j, k, l… in loops signals (imho) that there is most likely an outer loop and the one using j, k, l are nested. x and y of course are carthesian coordinates . n is used as amount of substance in SI-unit-system, m is mass, maybe thats why it is used as amount of items in a set (Menge).

Programming computers have started to solve mathematical problems and math already used these symbols for centuries(?), so why you should change them? They are well established even in simple school mathematics. And at the end of the day a computer is nothing more than a calculator.

db2 ,

x = “Am I a joke to you?”;

A10 ,
@A10@kerala.party avatar

I haven’t used I and J after college

Knusper ,

I’ve hardly ever looped over indices after college. For-each loops solve 99% of real-world problems in a better way.

CommunityLinkFixer Bot ,

Hi there! Your text contains links to other Lemmy communities, here are correct links for Lemmy users: !programmerhumor

youRFate ,

Usually variables like that can be avoided with itterators nowadays. If they can’t I like to use idx, if they are nested I name them after what they index, like idx_rows, idx_cols.

kent_eh ,

I prefer to use K in for loops, but that’s just me.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • [email protected]
  • lifeLocal
  • goranko
  • All magazines