> Is this supposed to be a joke? … there is no way they increase bugs.
No, it's not supposed to be a joke.
Steve McConnell 1993 observed density is proportional to source program length, so this should be obvious to every programmer: If a small program (as measured in source code bytes) is more likely to be a correct program, then this follows.
A major issue with discussing programming is the sheer number of people who believe they know how to program, when any non-programmer could see quite obviously that they don't: A professional bridge-builder doesn't often fail to build a bridge, but a professional CMS programmer seems to unable to get much past hello world without a bug or two; Less code will therefore produce less bugs.
You are completely misrepresenting what McConnell says.
There is a summary of his advice here[1], but just to highlight
Describe everything the routine does
And we mean literally everything. If that makes the name ridiculously long, the name isn't the problem. Your routine is.
And
Make names as long as necessary
According to McConnell, the optimum name length for a variable is 9 to 15 characters; routines tend to be more complex and therefore deserve longer names. Make your names as long as they need to be in order to make them understandable.
I've read McConnell, and your claims are so completely the opposite of what he recommends that I'm still unconvinced you aren't trolling.
I don't agree with everything McConnell says, but if you have it handy, note at page 173:
"A study from Basili and Perricone found that routine size was inversely correlated with errors: as the size of routines increased (up to 200 lines of code), the number of errors per line decreased (Basili and Perricone 1984).
And the conclusion (on page 174): …None of the studies that reported decreased cost, decreased error rates, or both with larger routines distinguished among sizes larger than 200 lines, and you're bound to run into an upper limit of understandability as you pass 200 lines of code
With that in mind, consider that KDB's SQL92 interface is 35 lines (the parser is 14 lines). It may be an extreme example of what McConnell is observing, and yet was himself unable to learn from.
> I'm still unconvinced you aren't trolling.
Look at it this way: Here is software that is faster than what you can write (or maybe you want to write your own taxi problem implementation), and if you don't try hard, you will miss out in finding out how to do something that you can't do.
That downvote button is so easy, that internet person is just a troll, I've been programming for ages, so of course I know what I'm talking about, but if you look through my comment history, you might find it easier to convince yourself at least that I believe that program length matters and permit yourself a discussion about it. You might learn something.
I find it difficult to agree that using non-representative names for variables or functions improves understadability.
Notably, using something like x to represent a meaningful value means the brain has to hold the mapping between the two, which will decrease the number of useful pieces of information kept in short term memory[1].
The brain doesn't keep track of the number of characters in a variable name.
So icsa[1] said something interesting on this point:
The issue, for me, is not readability but context. Even a word or two (e.g. cuts, begins, dims) helps greatly to establish the context of the code. Like having a map before hiking.
A comment can clearly provide that context without making the variable names long.
long names are distracting. try using short names for variables where code requires scrolling and very short name for variables in short blocks of code (where you see the context without scrolling). something like 'idxLS' instead of 'indexOfLastSlash'. Or x+=totalsMst[i] instead of accumulatorOfTotalValues+=totalValuesFromMasterList[i] if this is the only line in a loop.
as your opponent has mentioned, context is the key. you operate with objects in your brain, and the faster the transition from code element to the brain object, the better you understand the code. long names make this lookup unnecessarily difficult.
- you need to write same variable name on each step of derivation of a formula
- paper and blackboards don't have autocomplete
- juxtaposition is used for multiplication, thus SwapBlue can be Swap times Blue or a single variable called SwapBlue, spacing for multiplication is not a good solution when writing to board/paper
And despite lambda calculus being written entirely using single letter variable names, Scheme programmers all use proper word-size variable names in their programs.
Mathematics notation is so notoriously awful that mathematicians often can't even read equations from other disciplines without significant extra context.
is easy to spot when they're side-by-side, but not so much when they're two pages away from each other. Python's tabs and spaces can confuse the indention in cases so that code that "looks" aligned actually isn't.
If you haven't run into a problem caused by a typo, you haven't been programming long enough.
> This is indeed a problem with languages without mandatory variable declaration.
Typos affect everyone. It is not a function of the language that causes you to mistype. It is that the program is long and you cannot see the whole thing that causes you to miss it.
> Is it the case of K, Q or whatever its name is?
{foo}[] generates an error because foo is unbound. What's the difference between {foox} and {fooy}? They both might be variables, and yet it is only by reading the program that you can tell which one is correct.
> Typos affect everyone. It is not a function of the language that causes you to mistype. It is that the program is long and you cannot see the whole thing that causes you to miss it.
In any language with mandatory variable declaration the code wouldn't even compile. And any decent IDE would even flag this while writing the code.
> In any language with mandatory variable declaration the code wouldn't even compile.
Nonsense. memmove and memcpy are both defined, and if you choose the wrong one your program compiles and runs, but it simply produces the wrong result.
> And any decent IDE would even flag this while writing the code.
There is no IDE that will flag this. Advanced whole-program static analysis has a hard time with this problem and I'm not aware of any general solutions.
There is: it makes the program bigger. Program source code length is significant, and if you have more lines, you have more opportunities for bugs.