10 ms·
What it is about code written in languages that prefix variables with $ that results in unmaintainable code? I'd personally vote for i and j Mea Culpa: I've
by fleitz 17y ago
What it is about code written in languages that prefix variables with $ that results in unmaintainable code?
I'd personally vote for i and j
Mea Culpa: I've written my fair share of horrid code in PHP and Perl.
- sketerpot 17y agoWhen you use i and j as loop indices, everybody knows what you're talking about. It's idiomatic. How is that bad variable naming if its the clearest thing for everyone?
- nailer 17y ago> How is that bad variable naming if its the clearest thing for everyone? The clearest thing for me would be: channel.open() Which indicates to me that a channel is being opened. Rather than i.open() Which means nothing to me unless I find and read some other line.
- alextgordon 17y agoNobody's suggesting that i and j be used for anything other than loop counters: integers. In fact they come from FORTRAN, where a variable starting with a letter [i-n] was an integer, whereas variables starting with other letters were floats. Personally, I much prefer the certainty of the current situation to the relative uncertainty of a free-for-all. That and for (counter = 0; counter < N; counter++) seems very longwinded.
- RodgerTheGreat 17y agoMaybe this is just a personal thing, but it always struck me as odd that the recommended variable names for loop counters are the two letters that look most similar to a semicolon. I tend to use x and y.
- nailer 17y ago> Nobody's suggesting that i and j be used for anything other than loop counters: integers You're right, I missed the 'indices' part of your original comment. Unfortunately I've worked at a couple of places where they're used in every for loop.