Live data from Hacker News

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

beehollander.wordpress.com

51–60 of 111 posts

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

#51

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…

> Why is okay for mathemeticians to abbreviate things but programmers?

I think you want to add a "not" before "programmers in the end of your sentence.

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

#52

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.

This comment really deeply gets to the heart of the issue.

Programmer X thinks "I'll abbreviate because MAN IT IS SO OBVIOUS what the abbreviation is, what sort of idiot would think anything else?".

You have nothing to lose by typing:

let password = ''

as opposed to

let pwd = ''

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

#54

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?

That sounds right. Also, there are standards for variable names that everyone is familiar with in math, so those letters actually have meaning. As most of my code is not purely for implementing pure math algorithms, I haven't almost ever written code where a variable couldn't have been named with a word describing it or its use. It makes understanding and maintaining the code a lot easier when it is self-documenting.

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

#55

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…

...So if a Triangle is composed of points "Steve, Alice, and Bob,"...

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

#56
Great writeup, full of sharp details.

In the 90's I worked on a FoxPro application, also for DoD. My boss, a retired Navy Captain, used very terse variable names, partly because he was a hunt-and-peck typist, and partly because earlier languages allowed only two-character names.

But FoxPro allowed variable names of any length. However, it only recognized the first ten characters. To my boss's chagrin, I often used names longer than ten characters, risking collisions with other long names. That never happened.

But ten years after leaving, I was hired to port the product to Visual FoxPro, which does recognize the whole name. Some of the early commits were "Fixed inconsistently-used long variable name..."

Of course, in those days we weren't using linters, or tests, or source control, or reproducible builds... and yet still had a business. No wonder Alan Kay calls computing "not quite a field."

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

#57

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…

I theorize it's because math as we know it was written down on paper and blackboards. Those mediums don't have auto-complete, like any good code editor does.

I wish math notation would be replaced by s-expressions - easy to type and only like 3 concepts to learn for fluency.

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

#59

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…

I suppose it's because a proof is contained within itself while a computer program may interact (in this case with another component within the same application) in non-obvious ways. Clarity in variable names helps to prevent this behavior, although it doesn't completely eliminate the risk.

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

#60
post #56

Great writeup, full of sharp details. In the 90's I worked on a FoxPro application, also for DoD. My boss, a retired Navy Captain, used very terse variable names, partly because he was a hunt-and-peck typist, and partly because earlier languages allowed only two-character names. But FoxPro allowed variable names of any length. However, it only recognized the first ten characters. To my boss's chagrin, I often used na…

Hearing that absolutely terrifies me like?? Silently allowing names to collide in that way just sounds ridiculous to me.
Post reply on HN