Live data from Hacker News

Why I'll never abbreviate a variable as long as I live

beehollander.wordpress.com

101–110 of 111 posts

Re: Why I'll never abbreviate a variable as long as I live

#101

When hiring we ask for sample code from developers written specifically for the job application. We place a really high premium on readability. Occasionally we'll get code from devs that is very concise - not just abbreviated variable names, but complex long statements using ternary etc. I'll usually ask them to resubmit code and really focus on readability and it turns out fine. But I think there might be a misconce…

Whenever we interview a candidate, the one thing we give high premium on is structure, the rest come next. bad variable names, long complex code...can easily be adjusted . If the candidate doesn't have a good understanding of how to structure a code (what goes where, for what purpose, separation on concern...), it'll take much more effort to teach that candidate than to teach the bad variable namer. Properly structur…

> Whenever we interview a candidate, the one thing we give high premium on is structure

Yeah, because amorphous programmers are often unpleasant to work with.

Sorry, I knew what you meant, but the image of a jellyfish in a chair was to good to pass up.

Re: Why I'll never abbreviate a variable as long as I live

#102

I say this tongue in cheek: With current IDEs having such great autocompletion, has anyone experimented with coding far outside of the ASCII character set? Programming language restrictions aside, I recognize the obvious troubles this would cause. And yet I do a lot of work on simulations where math formulas are converted to code, which means lots of compounded Greek names like "omegaSquared" or "epsilonMinus". Namin…

I see some new emojis on the horizon!

Re: Why I'll never abbreviate a variable as long as I live

#103

Pwd stands for: ________? Correct, you guessed it! Once an abbreviation or acronym becomes widely used it makes sense to use it as a variable name for as long as you live.

I worked at a place where they would frequently use 'no' as the abbreviation for 'number'. I never could bring myself to do that.

Re: Why I'll never abbreviate a variable as long as I live

#104

When hiring we ask for sample code from developers written specifically for the job application. We place a really high premium on readability. Occasionally we'll get code from devs that is very concise - not just abbreviated variable names, but complex long statements using ternary etc. I'll usually ask them to resubmit code and really focus on readability and it turns out fine. But I think there might be a misconce…

The older I get, the less I value "cleverness" in programmers. I used to delight in writing code golf one-liners. But now I realize it detracts from solving the hard problems, and it makes simple problems harder.

Re: Why I'll never abbreviate a variable as long as I live

#105

I was recently implementing a geometry algorithm which I looked up on quora. It was described using typical vector notation, using r,s . t,u. Since I referenced the algorithm in the comments, I decided to use these same variable names in my code. I think this is the right choice, but my code reviewer didn't. But he didn't click on the quora link. Why is okay for mathemeticians to abbreviate things but programmers? Is…

> "Is it because they deal in more abstract entities where the name is irrelevant?" Partially, but also because math equations don't really have strong maintainability needs. Another mathematician isn't going to walk in 6 months later, get confused, and blow up the universe. Though I'd argue that in fact math equations should be better named. They're rather abstractly named as a matter of convention, but they would b…

>they would be more easily understandable in many cases if variables were more carefully named

A mathematician already knows the notation, so a a long mathematical expression with descriptive names will not make it more easy to understand (if you know the notation). I would argue that it can even make things worse and add cognitive load.

Re: Why I'll never abbreviate a variable as long as I live

#106

Earlier quoted context omitted.

I was joking. The example sort of looks like something that would fall out of minify -- although 'a' - 'z' would have to be used/visible in a scope before 'aa' would be generated as a name.

I should have clarified. The coder style of naming might seem to be run through minifier, but the coder actually wrote 'a', 'aa', 'aaa'... My guess is that the coder saw a minified code a took it as a standard or something.

And that was the joke: that the original code "out-minified" minify - that running the original gibberish through minify would NOT make it any smaller :-)

Re: Why I'll never abbreviate a variable as long as I live

#107

The problem was not that the variable was abbreviated. The problem was that the abbreviated variable was so similar to another abbreviated variable that was used for a similar purpose.

sure but if the variable was not abbreviated the chance of collision would have been less.

My point was that the abbreviation is not a problem per se. If there was not another variable with a similar name, it would not have mattered at all.

This is an issue of names being similar. No matter how long a variable name is, if another variable name in the same namespace is superficially similar, this kind of thing can happen.

On the other hand, if there are no other variables with similar names, then you can abbreviate all you want and your chance of collisions will not increase.

Re: Why I'll never abbreviate a variable as long as I live

#109

"Never abbreviate a variable" is a very strong statement, surely inspiring religious wars. And maybe there are edge cases: i as a loop counter, id for an integer primary key, whatever. But this example is something else entirely; "ttpfe" is honestly the worst variable name I have every seen.

Ah, good ol' TransactionTemplatePayloadFactoryExtension.

I posit that, if you abbreviate a variable name like that one, you now have two problems.

Re: Why I'll never abbreviate a variable as long as I live

#110
post #92

Earlier quoted context omitted.

I see no connection here to what I wrote, which has nothing to do with functional vs. imperative programming. I'm talking about names and readability in code. Imperativeness is a separate matter. One can easily have it without longDescriptiveNames, and although I don't have Knuth handy, I imagine he did.

At first read the idea you propose is very attractive but I think you do need to address why APL didn't take off. Perhaps they chose a poor vocabulary, are there better ways to represent algorithms?

I'm sorry I didn't reply to this during the conversation, but am traveling this week. IMO the short answer is that questions like "why didn't APL take off" presuppose an orderliness to history that doesn't really exist. Plenty of historical factors (e.g. market dynamics) can intervene to prevent an idea from taking off. Presumably if an idea is really superior it will be rediscovered many times in multiple forms, and one of them will eventually spark.
Post reply on HN