Reply
 
Thread Tools Display Modes
  #1  
Old 07-20-2019, 05:40 AM
Sage Rat's Avatar
Sage Rat is offline
Member
 
Join Date: Mar 2004
Location: Howdy
Posts: 21,666

Mathematics should learn from programming standards


I have no idea if this is true, but I suspect that math is written the way that it is due to history.

Historically, a lot of math was done by etching or scratching into clay, wax, or other mediums. Even after this period, with the introduction of paper and pens, those materials were still somewhat expensive, difficult to use, and unforgiving of error.

If you are writing text, one surmises, this isn't so bad. We're built for language and, with practice, can come to write fluently in a single go, without too horrible of a result.

With math, a lot of the work is work. You have to develop an idea, go down lots of rabbit holes, cross a lot of stuff off, etc. You don't just sit down and plonk out your new paper every day like a columnist can do with his articles.

There's a value, in historic times, for brevity of written material and far moreso - potentially - for mathematics.

That, I suspect, has tempered the culture of the field and stayed as a relic of that past.

In programming, if you named your variables 'a', 'b', and 'm', everyone would take you out into the parking lot and shoot you out of a cannon to get you as far away from them as possible. These sorts of names simply make it harder to follow and understand the material. (I have had to work with code like that. It sucked.)

Trying to read a math paper, you'll come across a formula and have to spend 5 minutes scouring the text to try and find where they introduce the variable, what it signifies, what type it is, what restrictions there are on it, and how it has been initialized. Occasionally, that all seems to be absent all together.

To be fair, there are certainly areas of pure mathematics where one might say that a named variable would have the danger of implying a certain understanding or way of thinking that misleads the reader away from a more "pure" view of the mathematics, I don't know. But I suspect that for most professional math, that's an argument that isn't particularly valid. And I further suspect (but admit to having no knowledge) that many math papers are founded on work done in Python or R, probably following standard programmatic convention and using full, meaningful variable names. And yet - if that's true - the resulting paper will probably end up with the single letter names again. If so, then clearly that's silly that there's the discrepancy.

Teaching kids is almost certainly strongly hampered by this tradition.

F = MV is just nonsense. The letters are clearly chosen to represent concrete realities of our world. It is not pure mathematics. This isn't to say that all nor even most kids would remember force = mass X velocity, but it probably would be slightly more who did than today and there would probably be less of an overall sense of impenetrability and obfuscatory intent on the part of the people who work in that field. People might be just a little more open to going that direction.

Perl and regexes are things that, with experience, you can come to understand natively without having to think about it too much. There is some minor gain in power because of the brevity.

But you'll notice how much real work gets done using something else and how much people grumble at having to use those languages, simply because they are purposefully obtuse and ambiguous to anyone who isn't a grizzled expert. And there really isn't that much gain for the cost. Regexes are fine as a tiny subpart of a larger application but they have that whole application around them that's actually readable and usually the regex isn't something that you need to care about the specifics of, just the general purpose it's filling.

With a math paper, like an application with some regexes embedded in it, we're reading plain English as our principle meat and potatoes of the matter with a few pieces of arcane nonsense placed occasionally.

English is not a particularly technical medium. If you have to use plain English to explain the bulk of your math, that's strange. In a program, only very little needs to be English for a person to follow along. That mathematicians have to resort to English rather than something more on the level of Java or Python is possibly somewhat telling that there may be a high level mathematical language gap.

In a program, the extra arcane bit is generally inconsequential. It's not core logic. But with a math paper, the arcane formulas using mystery variables are the most important thing to be able to understand and yet, as said, they're dependent on a bunch of setup written in plain English and, frequently, that's largely insufficient to explain what we're talking about. I'll be told that Ξ is the day (of the month? Of the year? Of some test period??) but then, never see that letter in any formula. After investigation, one might determine that the author has used the following in the formulas:

ξk-1p3

The emoji may or may not be a part of the formula.

I say to thee:

https://perl.plover.com/obfuscated/tpj.pl

Last edited by Sage Rat; 07-20-2019 at 05:41 AM.
  #2  
Old 07-20-2019, 06:27 AM
PrimalEnvy is offline
Guest
 
Join Date: Aug 2016
Location: Newfoundland
Posts: 129
Quote:
Originally Posted by Sage Rat View Post
F = MV is just nonsense.
Of course it's nonsense. It's actually F=ma. Or sometimes F=d/dt(mv).

I can somewhat see why using single-letter variables can be confusing. I don't think there's much issue when dealing with short formulae. In a long formula, it might just not be practical to use longer variable names. The actual constants usually do get more specific names.

It does get confusing when the same letter is used for representing different concepts, especially in physics. Is P pressure, power, momentum?

Beyond that, I don't really know what you're suggesting as a solution.
  #3  
Old 07-20-2019, 10:15 AM
Exapno Mapcase is offline
Charter Member
 
Join Date: Mar 2002
Location: NY but not NYC
Posts: 31,444
The answer to "why don't we change something with hundreds of years of tradition and a huge body of already existing work to make it newer and more convenient?" is always that it has hundreds of years of tradition and a huge body of already existing work.
  #4  
Old 07-20-2019, 10:35 AM
Thudlow Boink's Avatar
Thudlow Boink is offline
Charter Member
 
Join Date: May 2000
Location: Lincoln, IL
Posts: 27,170
The TL;DR is something like: Computer programmers are encouraged to use descriptive variable names, and people who write mathematical equations and formulas should be encouraged to do the same, instead of using single letters and symbols that don't indicate what they stand for. Is that about it?

My response: In some cases, you may be right.

In some cases, the abstraction is the point. Either the variables could stand for anything, or we don't want the distraction of worrying about what they stand for while we're doing the actual math on them.

In some cases, mathematical work—the work involved in actually solving an equation—involves many lines of handwritten work, which would be much harder to write and to work with if the x's and epsilons were words or phrases.

Imagine what the quadratic formula would look like if, instead of a, b, and c, it were written in terms of secondDegreeeTermCoefficient, firstDegreeTermCoefficient, and constantTerm.

Even worse, imagine what the derivation of the quadratic formula would look like if you had to complete the square on

secondDegreeTermCoefficient * variable^2 + firstDegreeTermCoefficient * varianble + constantTerm = 0
  #5  
Old 07-20-2019, 12:04 PM
leahcim is offline
Member
 
Join Date: Dec 2010
Location: Boulder, CO
Posts: 3,662
In programming languages, "terseness", and "eliminating boilerplate" are also considered good properties to have.

Consider C++:

Code:
std::vector<BarType> ret(foo.size());
std::transform(foo.begin(), foo.end(), ret.begin(), 
    [](const FooType& foo_element) { 
        return GetBar(foo_element);
    });
vs same in Scala:

Code:
val ret = foo.map(GetBar)
The latter is more readable in no small part simply because it cuts out the information that isn't relevant at that moment. Math's terseness is the same principle.
  #6  
Old 07-20-2019, 12:12 PM
Mijin's Avatar
Mijin is offline
Guest
 
Join Date: Feb 2006
Location: Shanghai
Posts: 9,026
Quote:
Originally Posted by Sage Rat View Post
With math, a lot of the work is work. You have to develop an idea, go down lots of rabbit holes, cross a lot of stuff off, etc. You don't just sit down and plonk out your new paper every day like a columnist can do with his articles.
I think this is the real problem, not single-letter names.
If there was a convention that every equation has a clear table next to it explaining all the variables, there wouldn't be a problem.

I think with academic papers, there's something of a cultural factor IMO that everyone wants to be taken seriously and a paper needs to take some time to "solve".
(just my impression as a non-mathematician but who occasionally has to digest math / physics / comp sci papers)

Last edited by Mijin; 07-20-2019 at 12:13 PM.
  #7  
Old 07-20-2019, 12:14 PM
Mijin's Avatar
Mijin is offline
Guest
 
Join Date: Feb 2006
Location: Shanghai
Posts: 9,026
One thing to think about: nowadays, most mathematicians also need to write code. When they do so, do they use meaningful variable names?
  #8  
Old 07-20-2019, 01:38 PM
Daylate is offline
Guest
 
Join Date: Dec 1999
Posts: 1,632
Quote:
The answer to "why don't we change something with hundreds of years of tradition and a huge body of already existing work to make it newer and more convenient?" is always that it has hundreds of years of tradition and a huge body of already existing work.
That didn't bother the chess authorities at all. A few years ago they were perfectly happy to replace "descriptive notation", in use for hundreds of years and with thousands of books written using it), with an abortion called "algebraic notation", seemingly because they wanted change for change's sake.

And I could see no improvement in either clarity or convenience.
  #9  
Old 07-20-2019, 03:27 PM
DPRK is offline
Guest
 
Join Date: May 2016
Posts: 3,479
Quote:
Originally Posted by Mijin View Post
One thing to think about: nowadays, most mathematicians also need to write code. When they do so, do they use meaningful variable names?
Most mathematicians nowadays do not "need to write code" (why would they?), though many can and do. It's not like a computer program where there may be dozens of variables (one hopes), and the goal is to be clear while avoiding excessive subscripts and superscripts. A mathematical article may have mind-blowing identifications like, "Let p be a prime number...", "Let X be a scheme... Pic(X) the Picard group of X...", "Let G be a group and H a normal subgroup", etc. And you want some sort of notation: for instance, you don't want to write out "square root of x" in full each time it appears, or "equal" instead of "=" all the time.

For an excellent sample of mathematical notation before and after it has been cleaned up, see the notes on "Mathematical Writing" by Knuth et al. There should be a free web version floating around somewhere, as well as videos of the classes.
  #10  
Old 07-20-2019, 04:04 PM
Lance Turbo is offline
Guest
 
Join Date: Aug 1999
Location: Asheville, NC
Posts: 4,058
I'm willing to be convinced. Show me a bit of published mathematics and then show me how much clearer it is written the way you think it should be.

It doesn't even have to be published. Rewrite this post with descriptive variable names. If it is notably clearer then I'll jump on your bandwagon.
  #11  
Old 07-20-2019, 06:30 PM
Exapno Mapcase is offline
Charter Member
 
Join Date: Mar 2002
Location: NY but not NYC
Posts: 31,444
Isn't the simplest way to tell if a mathematical formulation is wrong is to note that it's written in words instead of math?
  #12  
Old 07-20-2019, 06:36 PM
DPRK is offline
Guest
 
Join Date: May 2016
Posts: 3,479
Well, it can't all be Principia Mathematica.
  #13  
Old 07-20-2019, 07:07 PM
HMS Irruncible is offline
Guest
 
Join Date: Nov 2004
Posts: 8,280
I would venture to say that in most math papers where you're complaining that you don't know what the variables are, this is probably the least of your challenges. The biggest challenge would be understanding the concept and context. Once you get that far, then comprehending the variables becomes a non-issue.

There are certain computing trends that prioritize English readability over programmatic terseness. IMO this has been a disease to the programming community in recent years (Ruby/Rails, looking at you). My response to the OP is the same.

1. Are you sure... absolutely certain that you picked the best idiom for your fancy English-readable code?
2. Have you thought through how much behind-the-scenes context needs to be established to make your idioms work? Are you prepared to maintain that?
3. What are non-English speakers supposed to do? Go pound sand? How about people who speak English, but a slightly different version than you?
4. Of the thousands of programming languages in existence, which one would you believe solves your problem the best?

This seems a solution in search of a problem to me.
  #14  
Old 07-20-2019, 07:12 PM
Chronos's Avatar
Chronos is offline
Charter Member
Moderator
 
Join Date: Jan 2000
Location: The Land of Cleves
Posts: 84,413
Often, in math, descriptive variable names are impossible, because the variables aren't describing anything in particular. Maybe there are a thousand different real-world situations that equation could be describing. Maybe nobody's ever found any real-world situation that would be described by that equation. Maybe there are exactly two known real-world situations described by that math. The only time that descriptive names would really make sense would be when there's exactly one real-world situation described by a particular bit of math, and that's quite rare.
  #15  
Old 07-20-2019, 07:54 PM
Chingon is offline
Guest
 
Join Date: Dec 2006
Location: the hypersphere
Posts: 565
Hard to take a suggestion seriously from someone who makes such glaring errors.
  #16  
Old 07-20-2019, 08:51 PM
DPRK is offline
Guest
 
Join Date: May 2016
Posts: 3,479
In mathematics texts the length of a book (like, for example, a textbook) there is sometimes an index of notation in the back next to the subject index, so if you are trying to remember what X+ represented, versus X++ , four chapters before, it's quick enough to find out.
  #17  
Old 07-20-2019, 09:11 PM
glowacks is offline
Guest
 
Join Date: Aug 2008
Posts: 2,191
Computer programs need descriptive variable names because computer programs have a much higher likelihood to be need to be read by people who don't already understand what it is they do. If you don't understand a math paper because you don't understand what the variable names mean, it's highly unlikely that you've studied the subject enough to understand the concepts; only if people use intentionally obtuse variable names, or conventions differ between academic groups, does it become a problem that the target audience is unable to read and comprehend a paper because of bad variable names.

Why do computer programs need to be understood by people who don't already understand them? Because they are actually used in the production of things, and may be embedded in mission-critical applications for much longer than the original programmers will be with the company. Mathematics papers are just academic papers. I'm fairly sure that if one looks at a CS academic paper, they use basically the same sort of variable naming as in Mathematics. It's only on production programming that the descriptive variable names get used.

The topic of variable names reminds me of watching some lectures on quantum mechanics where an equation central to the theory had an "m" as the mass of the particle in question, and later in the development of angular momentum they use "m" to stand for the magnitude of one component of angular momentum and then go on to say how "only this part of the equation depends on m" when the other part of the equation clearly has an m in it as well. However, no one even bats an eye at this, because everyone knows the first m appears in one specific place and isn't used elsewhere, and anyone studying it for long enough would never be confused because it wouldn't make any sense for those two m's to stand for the same thing. Similar things go on with the base of the natural logarithms and the charge of the electron both being written "e"; everyone knows which "e" is which because of the role it plays in the equation. You have no reason to ever put a complex (as in, not a member of the real numbers) variable in the exponent of the charge of the electrion. It should be at most a 2 or some higher integer or an expression that clearly resolves to an integer. If the exponent is complex, it's obvious that the e is the standard base for exponentials. Similar, any e where there is nothing in the exponent is clearly not the base of natural logarithms; while occasionally in math it might come out of an integral or something, that's not going to be the case in physics. Only people totally clueless about the subject would think they would be standing for the same thing.
  #18  
Old 07-20-2019, 09:31 PM
DPRK is offline
Guest
 
Join Date: May 2016
Posts: 3,479
That's all fair enough, but I don't think we can really condone as good style notation in which identical symbols, or ones not easily distinguishable, stand for different things. Surely that is avoidable.
  #19  
Old 07-20-2019, 09:39 PM
leahcim is offline
Member
 
Join Date: Dec 2010
Location: Boulder, CO
Posts: 3,662
In addition to all of the other reasons, computer programs need multi-character variable names, because source code generally uses only a small number of characters -- in ancient times because only ASCII text files were supported, but even with modern compilers that can use unicode source files, those files tend to be typed on keyboards upon which typing ASCII characters is much easier than any other type.

Mathematics has a long tradition of using characters from multiple alphabets and multiple typefaces to encode the same kind of meaning that longer variable names are used for in programming.
  #20  
Old 07-20-2019, 10:39 PM
Sage Rat's Avatar
Sage Rat is offline
Member
 
Join Date: Mar 2004
Location: Howdy
Posts: 21,666
Quote:
Originally Posted by glowacks View Post
Computer programs need descriptive variable names because computer programs have a much higher likelihood to be need to be read by people who don't already understand what it is they do. If you don't understand a math paper because you don't understand what the variable names mean, it's highly unlikely that you've studied the subject enough to understand the concepts;
1) There is an entire class of people who, by definition, don't know the concepts: Students.
2) Mathematician creates paper. Engineer implements formula. Engineer sad. As said, there is a thing as non-pure mathematics. I don't know for sure, but I suspect that the grand majority of math is done professionally for purposes of real world application. I've personally implemented the RSA algorithm, both the encoding portion and they key generation portion (including prime tests). Similarly, I have implemented a bunch of 3D math (quaternion multiplication, etc.) and some regression analysis. All of those required reading and trying to establish basic things like "what the hell is the meaning of this stupid variable"? Turning a formula into code should be, in essence, a 1:1 conversion. If you're going to use to use the gamma function, being able to load your "paper" into an IDE and having it take me into a library for complex numbers when I right click the Γ would be horribly useful, in terms of identifying what I am looking at. If I just see the Γ, I have no idea if it's a thing that this person has declared or is a mathematical standard. If the latter, is it a Greek character or Hebrew or what? The time spent tracking down the formula makes a person lose track and forget what the original topic was or how this fit in at all. If a math paper could be written in something like an IDE this would be immensely useful for the practical usage of the output of mathematicians. And, I do suspect, it would be useful for mathematicians as well since, as said, plain English is not a particularly good medium.
3) Mathematics is almost certainly growing at a compounding rate. Consequently, it's breaking into subfields and those subfields are certainly going to be as obtuse to those outside of it as math is to the general public. And yet, the product of every field is liable to be useful to every other field. Programs build on libraries and must explicitly include those libraries, otherwise they are carte blanche. As said above, with the gamma function, it would be in a library. For a mathematician, looking at some math in another field, he's going to have the same issues as an engineer. He may think that this paper has relevance to what he's doing, but that doesn't mean that he wants to learn the entirety of a new field of mathematics. For his purposes, he wants to know what he needs to know, minimally, and if he could simply look at which items from which are imports are used, he can investigate that limited subsection of the field before proceeding to try and read the paper.

The assumption that everyone is an expert and that only experts would want to know things is not a good one. It's certainly not the right technique to bring others in nor to share with others.

Mathematics isn't purely a hobby. It is also and principally for real human use.
  #21  
Old 07-20-2019, 11:44 PM
Sage Rat's Avatar
Sage Rat is offline
Member
 
Join Date: Mar 2004
Location: Howdy
Posts: 21,666
Quote:
Originally Posted by Chronos View Post
Often, in math, descriptive variable names are impossible, because the variables aren't describing anything in particular. Maybe there are a thousand different real-world situations that equation could be describing. Maybe nobody's ever found any real-world situation that would be described by that equation. Maybe there are exactly two known real-world situations described by that math. The only time that descriptive names would really make sense would be when there's exactly one real-world situation described by a particular bit of math, and that's quite rare.
In terms of pure mathematics, I'm not sure that this is true - though obviously, that's not my area of knowledge.

To the extent that I can tell, pure mathematics always deals in diagrams. And while diagrams may well represent things that can't be displayed in 2D, they are nevertheless simply lines, points, nodes, etc.

Graham's number was the output of research on cuboids. A cuboid has edges and vertexes, etc.

There is no particular reason that you can't call your variable for the length of an edge in your hyper cuboid 'edgeLength'. It may be pure mathematics, but it is nevertheless the edge length of your hypercuboid.
  #22  
Old 07-21-2019, 12:39 AM
Mijin's Avatar
Mijin is offline
Guest
 
Join Date: Feb 2006
Location: Shanghai
Posts: 9,026
Quote:
Originally Posted by DPRK View Post
Most mathematicians nowadays do not "need to write code" (why would they?) [...]
Well I should have put "IME", but yeah IME most mathematicians write code (and obviously mathlab counts as code)

The main uses are probably: 1. Any time many calculations need to be performed 2. Visualization e.g. in geometry / topology 3. Share datasets with others 4. Run simulations (in applied mathematics)

Quote:
Originally Posted by Daylate View Post
That didn't bother the chess authorities at all. A few years ago they were perfectly happy to replace "descriptive notation", in use for hundreds of years and with thousands of books written using it), with an abortion called "algebraic notation", seemingly because they wanted change for change's sake.

And I could see no improvement in either clarity or convenience.
This is an example of how once a person gets used to one system, they often find it hard to see the benefits of switching to another system.
Objectively-speaking the algebraic system is quicker to both read out, and write down moves. (I also think there's less chance of confusing moves because every move only mentions one piece. Though that one's debateable as some may consider it easier to confuse, say, C4 and D4).
  #23  
Old 07-21-2019, 02:41 AM
Mijin's Avatar
Mijin is offline
Guest
 
Join Date: Feb 2006
Location: Shanghai
Posts: 9,026
Correction: Matlab (no 'h')
  #24  
Old 07-21-2019, 08:03 AM
Chingon is offline
Guest
 
Join Date: Dec 2006
Location: the hypersphere
Posts: 565
Sorry, but symbols have been found to be quite convenient and useful.
  #25  
Old 07-21-2019, 08:47 AM
MrDibble's Avatar
MrDibble is offline
Guest
 
Join Date: Mar 2001
Location: Cape Town, South Africa &
Posts: 25,875
Quote:
Originally Posted by Sage Rat View Post
Historically, a lot of math was done by etching or scratching into clay, wax, or other mediums. Even after this period, with the introduction of paper and pens, those materials were still somewhat expensive, difficult to use, and unforgiving of error.
Right from the get-go, you're building on some shaky foundations here:
1) wax tablets, in particular, are endlessly rewriteable.
2) You seem to ignore the chalk+slate tablet/chalkboard combo, again endlessly rewriteable.

Neither of those were particularly difficult to use, either. Or particularly expensive (hell, the Greeks and Romans used wax tablets for letters, bills of lading,even schoolkid's writing practice)
  #26  
Old 07-21-2019, 09:38 AM
Nava is offline
Member
 
Join Date: Nov 2004
Location: Hey! I'm located! WOOOOW!
Posts: 42,212
For many people, understanding a short symbol is easier than understanding a larger one; a lot of my Chemistry tutoring in the US was spent explaining that [HCO3-] can, and in fact for a very popular family of Chemistry problems* is, a variable. In English "a rose is a rose by any other name"; in Spanish llámalo x, "call it x", has that same meaning of "the essence of things does not change depending on what you call them", but it is also one of the most basic tools when doing algebra on stuff whose usual symbol is large and clunky. I am very grateful to my Physics and Chemistry HS teachers for the effort they put into making sure that their students knew to write our substitutions at the beginning of a problem, and to revert them explicitly at the end of the same.

That the OP has apparently encountered work by people who didn't know to apply those rules doesn't mean the solution is to have to drag large symbols all around the page when calling it x is just a lot more convenient. It's not about space, it's about ease.




* equilibrium problems, and specifically those based on the carbonate family. Teachers love their bicarbonate, man.

Last edited by Nava; 07-21-2019 at 09:40 AM.
  #27  
Old 07-21-2019, 09:49 AM
Nava is offline
Member
 
Join Date: Nov 2004
Location: Hey! I'm located! WOOOOW!
Posts: 42,212
Quote:
Originally Posted by Daylate View Post
That didn't bother the chess authorities at all. A few years ago they were perfectly happy to replace "descriptive notation", in use for hundreds of years and with thousands of books written using it), with an abortion called "algebraic notation", seemingly because they wanted change for change's sake.

And I could see no improvement in either clarity or convenience.
"A few years"? My Dad's chess books are written like that and they're dated in the 1950 through the 1970s. I suspect it may be a matter of one of several pre-existing notations becoming more widespread: you had been trained in a different one, but you might actually have been in a minority.
__________________
Evidence gathered through the use of science is easily dismissed through the use of idiocy. - Czarcasm.
  #28  
Old 07-21-2019, 09:55 AM
HMS Irruncible is offline
Guest
 
Join Date: Nov 2004
Posts: 8,280
Quote:
Originally Posted by DPRK View Post
That's all fair enough, but I don't think we can really condone as good style notation in which identical symbols, or ones not easily distinguishable, stand for different things. Surely that is avoidable.
This is not correct. Computer languages, at least the good ones, are lexically scoped so that you can reuse variable names. A well-designed function is short and has no side-effects, so it's safe (indeed preferable) to use short variables like a, i, n, or whatever.

Meaningful variable name are only important in these cases:
  1. Your language is not typed
  2. Your language is not lexically scoped (in this case, first try finding another job)
  3. You inherited a codebase where the methods/functions are too long, or it isn't even organized into distinct units.
  4. When calling a foreign function, it is helpful (though not required) to use a variable name that hints how it will be used in the called function.

Basically... write good code, and this problem isn't a problem anymore.
  #29  
Old 07-21-2019, 10:01 AM
HMS Irruncible is offline
Guest
 
Join Date: Nov 2004
Posts: 8,280
Quote:
Originally Posted by glowacks View Post
Computer programs need descriptive variable names because computer programs have a much higher likelihood to be need to be read by people who don't already understand what it is they do.
To phrase another way, much of the body of mathematics has no application at all, whereas a computer program likely mediates at least one application. So it can be helpful to differentiate context.

but again, as I write above, the solution there is to make your code more math-like (use tight, single-purpose functions with no side effect). Let your function signature explain itself, don't put this burden on variables or comments (which have been known to lie).
  #30  
Old 07-21-2019, 10:49 AM
glee is offline
Guest
 
Join Date: Aug 1999
Location: Obama country
Posts: 15,477
Quote:
Originally Posted by Daylate View Post
That didn't bother the chess authorities at all. A few years ago they were perfectly happy to replace "descriptive notation", in use for hundreds of years and with thousands of books written using it), with an abortion called "algebraic notation", seemingly because they wanted change for change's sake.

And I could see no improvement in either clarity or convenience.
The main reasons for the change from descriptive notation (e.g. 1. P-K4 N-KB3) to algebraic notation (e.g. 1. e4 Nf6) were:

- in descriptive, each square had two names , depending whether you were White or Black (algebraic had a single name)
- having only one system made it easier to sell books world-wide, syndicate chess columns and keep score in international events + correspondence games
- there were a lot of countries using algebraic already
- algebraic was slightly shorter (a small benefit!)

I used descriptive myself for decades, but switched to algebraic within a week...
__________________
Arnold Winkelried:
'glee, I take my hat off to you.... at first I thought you were kidding with your cite but I looked it up and it was indeed accurate. (Still in awe at the magnificent answer)'
  #31  
Old 07-21-2019, 11:22 AM
Thudlow Boink's Avatar
Thudlow Boink is offline
Charter Member
 
Join Date: May 2000
Location: Lincoln, IL
Posts: 27,170
Quote:
Originally Posted by Sage Rat View Post
Turning a formula into code should be, in essence, a 1:1 conversion. If you're going to use to use the gamma function, being able to load your "paper" into an IDE and having it take me into a library for complex numbers when I right click the Γ would be horribly useful, in terms of identifying what I am looking at.
I can't tell for sure, but you may be confusing "function" and "formula." In computer programming, a function is something that performs a specific, well-defined calculation for a specific purpose; but that's not how modern mathematicians use the term "function."

Here's the Wikipedia article for the Gamma function. What would your hypothetical wished-for IDE have given you when you "click the Γ"? Something like this whole article, or a specific part of it, or something else?
Quote:
If I just see the Γ, I have no idea if it's a thing that this person has declared or is a mathematical standard. If the latter, is it a Greek character or Hebrew or what? The time spent tracking down the formula makes a person lose track and forget what the original topic was or how this fit in at all.
A good writer of mathematics or anything else should know their audience, and should not use terminology or symbols that a significant portion of that audience would be unfamiliar with, without some sort of explanation or reference. That's true of any field.
  #32  
Old 07-21-2019, 11:28 AM
RaftPeople is offline
Guest
 
Join Date: Jan 2003
Location: 7-Eleven
Posts: 6,688
Quote:
Originally Posted by HMS Irruncible View Post
To phrase another way, much of the body of mathematics has no application at all, whereas a computer program likely mediates at least one application. So it can be helpful to differentiate context.

but again, as I write above, the solution there is to make your code more math-like (use tight, single-purpose functions with no side effect). Let your function signature explain itself, don't put this burden on variables or comments (which have been known to lie).
This is absolutely horrible advice. Fortunately, I've never encountered a large system where anyone was naive enough to actually do this.

If you've decomposed your functions to the extent that you don't need any meaningful variable names then you've decomposed way too far and reduced the readability of your code and thus cost your company money due to the time it takes for others to figure out how it works.

In addition, this just pushes the problem onto the function names. When you have an order of magnitude more names then the need for organization of the names increases significantly and the length of the names increases. It can be challenging to create function names that incorporate the full hierarchy of context.

You've also cost your company money due to the overhead of creating hundreds of thousands or millions of functions that didn't need to exist.


Regarding no comments:
Programming languages are not designed to describe anything about the problem being modeled. While it's true that good code organization and naming of functions and variables can reduce some of the need for comments, they simply can not eliminate the need for additional information for rapid understanding of the software.


Regarding comments lie:
"comments (which have been known to lie)"
So can function names, class names, table names, etc. Everything can lie, so your solution is to eliminate a valuable tool because some people make mistakes once in a while?

Should we eliminate function names for the same reason?
  #33  
Old 07-21-2019, 11:56 AM
Mijin's Avatar
Mijin is offline
Guest
 
Join Date: Feb 2006
Location: Shanghai
Posts: 9,026
Quote:
Originally Posted by RaftPeople View Post
Regarding no comments:
Programming languages are not designed to describe anything about the problem being modeled. While it's true that good code organization and naming of functions and variables can reduce some of the need for comments, they simply can not eliminate the need for additional information for rapid understanding of the software.

Regarding comments lie:
"comments (which have been known to lie)"
So can function names, class names, table names, etc. Everything can lie, so your solution is to eliminate a valuable tool because some people make mistakes once in a while?

Should we eliminate function names for the same reason?
+1 all of this.

In 20+ years as a software developer, I have never encountered code that had so many comments as to decrease readibility, nor have I encountered nonsense oft-cited examples like commenting x++ with // increment x
However plenty of times I've had to basically reverse-engineer code peppered with single character variables and sod all comments.

Or, to put it another way, if "True Scotsman" programmers always write clear enough methods or functions that meaningful variable names are not required, then I know of no True Scotsman programmers.

(The one exception though might be non-nested loop variables)

Last edited by Mijin; 07-21-2019 at 11:57 AM.
  #34  
Old 07-21-2019, 12:38 PM
HMS Irruncible is offline
Guest
 
Join Date: Nov 2004
Posts: 8,280
Quote:
Originally Posted by RaftPeople View Post
If you've decomposed your functions to the extent that you don't need any meaningful variable names then you've decomposed way too far and reduced the readability of your code and thus cost your company money due to the time it takes for others to figure out how it works.
This is 100% unsubstantiated opinion. Honestly it seems like you've never read or written good code. Good composition results in maximum readability. Readability should arise from the structure of the program, not your choice of verbiage.

Quote:
In addition, this just pushes the problem onto the function names. When you have an order of magnitude more names then the need for organization of the names increases significantly and the length of the names increases. It can be challenging to create function names that incorporate the full hierarchy of context.
Clearly you've never heard of namespaces, which are a basic feature of most commercially used programming languages, so we can pretty much discard the rest of your junior critique.

Quote:
You've also cost your company money due to the overhead of creating hundreds of thousands or millions of functions that didn't need to exist.
By what reasoning did you determine that thousands of variable names are cheaper than thousands of function names? (Setting aside that it isn't a 1 for 1 exchange).

Quote:
Regarding comments lie:
"comments (which have been known to lie)"
So can function names, class names, table names, etc. Everything can lie
This is not exactly true. When programmatic entities are incorrectly named, this will often be flagged/failed by the compiler, or a unit test, or an integration test, or a runtime. In other words there is some penalty for lying and some protection against it... for every entity except for comments.

Quote:
This is absolutely horrible advice. Fortunately, I've never encountered a large system where anyone was naive enough to actually do this.
Dude, dial the heat down a notch. Most of your post boils down to "that's now how I do it or how I like to do it, and things I don't like are probably expensive."
  #35  
Old 07-21-2019, 12:57 PM
HMS Irruncible is offline
Guest
 
Join Date: Nov 2004
Posts: 8,280
Quote:
Originally Posted by Mijin View Post
Or, to put it another way, if "True Scotsman" programmers always write clear enough methods or functions that meaningful variable names are not required, then I know of no True Scotsman programmers.
Your appeal-to-ignorance fallacy kind of cancels out your No True Scotsman there.

Anyway, my point is not "never write comments" or "never use good variable names". I did not suggest that. Rather I suggest that good program structure should be the first choice for self-describing code.

And if that isn't possible, here are some perfectly good reasons to write comments, and ways to write them so they don't lie:
  • Explaining the intent of the code. Why did I write this method?
  • Explaining a seemingly nonsense practice. This looks weird/risky. Why did I do that?
  • Signaling a known instability or site of change. This code may break after the year 2038!

Likewise, here are some good reasons to be very descriptive in variable names:
  • Your language uses global variables or lacks namespacing
  • You are calling a foreign function and you want to signal what you think you're passing to it.
  • You are defining the parameters of a method signature.
  • Your language doesn't have types, so your variables need a type hint.
  • Your method body is more than a half-screen long, and you don't have time to refactor it.

Considering above, I would ask we talk about _why_ we make certain choices, and the contexts where they make sense, instead of simply declaring that my preferences are good and cheap, but yours are bad and expensive.

For example, the survival skills you learned in PHP are partially irrelevant in Java and wholly irrelevant in Elixir (not that anything is wrong with PHP or Java, and clearly I'm an Elixir fanboy. Just pointing out that the survival practices are different because the languages are different).

Last edited by HMS Irruncible; 07-21-2019 at 01:01 PM.
  #36  
Old 07-21-2019, 06:18 PM
Voyager's Avatar
Voyager is offline
Charter Member
 
Join Date: Aug 2002
Location: Deep Space
Posts: 46,157
Quote:
Originally Posted by HMS Irruncible View Post
This is 100% unsubstantiated opinion. Honestly it seems like you've never read or written good code. Good composition results in maximum readability. Readability should arise from the structure of the program, not your choice of verbiage.
40 years ago I adapted the Jensen/Wirth Zurich Pascal compiler for my dissertation. The structure was very good, but for some reason they used one or two character variable names throughout. It took me two months to document everything. I blame Wirth because his data structures text did the same thing.

Clearly you've never heard of namespaces, which are a basic feature of most commercially used programming languages, so we can pretty much discard the rest of your junior critique.


Quote:
By what reasoning did you determine that thousands of variable names are cheaper than thousands of function names? (Setting aside that it isn't a 1 for 1 exchange).
Thousands of function names imply thousands of functions.

Quote:
This is not exactly true. When programmatic entities are incorrectly named, this will often be flagged/failed by the compiler, or a unit test, or an integration test, or a runtime. In other words there is some penalty for lying and some protection against it... for every entity except for comments.
That is misspelling, not lying.

As for comments, they are especially useful in giving the context of code, especially for code written to handle corner cases or weirdnesses forced upon you by your environment. Or do you trust in up to date external documentation?
  #37  
Old 07-21-2019, 06:29 PM
RTFirefly is offline
Charter Member
 
Join Date: Apr 1999
Location: Maryland
Posts: 39,244
Quote:
Originally Posted by Mijin View Post
If there was a convention that every equation has a clear table next to it explaining all the variables, there wouldn't be a problem.
When writing and proving theorems, mathematicians explain what every bit of notation means, aside from universally accepted notation for sets like the integers, rationals, reals, or complex numbers. As DPRK said:
Quote:
Originally Posted by DPRK View Post
A mathematical article may have mind-blowing identifications like, "Let p be a prime number...", "Let X be a scheme... Pic(X) the Picard group of X...", "Let G be a group and H a normal subgroup", etc.
Language like this may be Greek to the average reader, but as others have said, the hard part is the concepts, not the language. The intended audience of people who could make sense of the underlying ideas aren't going to be slowed down much by the notation.
  #38  
Old 07-21-2019, 07:42 PM
HMS Irruncible is offline
Guest
 
Join Date: Nov 2004
Posts: 8,280
Quote:
Originally Posted by Voyager View Post
As for comments, they are especially useful in giving the context of code, especially for code written to handle corner cases or weirdnesses forced upon you by your environment. Or do you trust in up to date external documentation?
What did I write to make you think that? I did not mention or imply anything about external documentation. Read my replies above where I explained when comments can be desirable.

Or actually...don't. I'm done with replies that put words in my mouth or don't read what I actually posted. However, thank you for being a prime example of one of the biggest problems with comments: people just don't read.

Last edited by HMS Irruncible; 07-21-2019 at 07:44 PM.
  #39  
Old 07-21-2019, 09:03 PM
RaftPeople is offline
Guest
 
Join Date: Jan 2003
Location: 7-Eleven
Posts: 6,688
Quote:
Originally Posted by HMS Irruncible View Post
This is 100% unsubstantiated opinion. Honestly it seems like you've never read or written good code. Good composition results in maximum readability. Readability should arise from the structure of the program, not your choice of verbiage.
There is research surrounding this topic, it's not just opinion.


Quote:
Clearly you've never heard of namespaces, which are a basic feature of most commercially used programming languages, so we can pretty much discard the rest of your junior critique.
40 years of experience in a wide variety of languages, OS's, and problem domains.



Quote:
This is not exactly true. When programmatic entities are incorrectly named, this will often be flagged/failed by the compiler, or a unit test, or an integration test, or a runtime. In other words there is some penalty for lying and some protection against it... for every entity except for comments.
The compiler has no idea of the intent of the function and whether the name supports that intent.


Quote:
Dude, dial the heat down a notch. Most of your post boils down to "that's now how I do it or how I like to do it, and things I don't like are probably expensive."
The heat is warranted due to how poor the advice was. It's based on objective evidence from 40 years of experience with large enterprise systems.

Once in awhile I get a lead or a programmer that read some blog somewhere with this type of advice and took it to heart and it takes time to correct their incorrect notions.

I recently fired a lead over this exact topic.
  #40  
Old 07-21-2019, 10:07 PM
Mijin's Avatar
Mijin is offline
Guest
 
Join Date: Feb 2006
Location: Shanghai
Posts: 9,026
Quote:
Originally Posted by HMS Irruncible View Post
Your appeal-to-ignorance fallacy kind of cancels out your No True Scotsman there.
It would have been an appeal to ignorance had I claimed that no such programmers exist.
Instead I am simply questioning the merit of your advice, given that in my 20 years experience it would be precisely the wrong advice for every programmer I have worked with.

Quote:
Anyway, my point is not "never write comments" or "never use good variable names". I did not suggest that. Rather I suggest that good program structure should be the first choice for self-describing code.
Then it would seem there's little to debate. No-one is going to argue against good program structure being of primary importance.

I guess the one remaining thing is that you are still implying that sometimes clear variable naming is beneficial, when my opinion is that it almost always is, and for many of the reasons you list.
Conversely I don't see any benefit of using single-character names.
  #41  
Old 07-21-2019, 10:41 PM
DPRK is offline
Guest
 
Join Date: May 2016
Posts: 3,479
How about Knuth's concept of Literate Programming? Beyond merely interspersing comments, a literate programme freely mixes computer language with documentation.

How popular is this paradigm? Knuth is a famous computer scientist, but he does not need to worry about things like large enterprise systems.

As for pure mathematics or applied mathematics, mathematics papers are closer to literate programming in the sense that mathematical writing relies on natural language as much as it uses (hopefully well-chosen) notation and jargon. But they are not computer programs, and there is a huge gap between the limited set of mathematical proofs that can be read and checked by a computer and what people typically write. A well-written mathematical article seems to rely on the creativity and style of the author beyond merely choosing apt names for the variables. Also note that many of them, though there are exceptions, are of moderate length [checking the daily "new submissions": 18 pages, 14 pages, 31, 15, 14, 26, 28, 29, 7, ...] compared to an enterprise computer program.
  #42  
Old 07-22-2019, 01:32 AM
RaftPeople is offline
Guest
 
Join Date: Jan 2003
Location: 7-Eleven
Posts: 6,688
Quote:
Originally Posted by DPRK View Post
How about Knuth's concept of Literate Programming? Beyond merely interspersing comments, a literate programme freely mixes computer language with documentation.

How popular is this paradigm? Knuth is a famous computer scientist, but he does not need to worry about things like large enterprise systems.
I've never heard of it, I'll check it out.

I will say that we are in the dark ages when it comes to solving the problem of modeling systems in a way that can be used to both communicate to users and maintainers about it's function, and that those same specs (or something derived from them) drive the execution. I think what could work is some sort of 3D model (abstract, hiding details unless drill in) that evolves over time according to input and that allows us to single out specific features and functions to see impact across a large system.

Last edited by RaftPeople; 07-22-2019 at 01:32 AM.
  #43  
Old 07-22-2019, 01:33 AM
Voyager's Avatar
Voyager is offline
Charter Member
 
Join Date: Aug 2002
Location: Deep Space
Posts: 46,157
Quote:
Originally Posted by HMS Irruncible View Post
What did I write to make you think that? I did not mention or imply anything about external documentation. Read my replies above where I explained when comments can be desirable.

Or actually...don't. I'm done with replies that put words in my mouth or don't read what I actually posted. However, thank you for being a prime example of one of the biggest problems with comments: people just don't read.
I don't see where you said anything positive about comments. Comments in functions, except very simple ones, have the same benefit as comments anywhere else.

If you are explaining why you are doing something, the choices are inside the code or in an external document. Or both, which is best.
Do you agree that compilers can't catch "lies" about functions? Testing might if they cause a logic error, but I'm not even sure what you mean by them.
  #44  
Old 07-22-2019, 07:38 AM
dropzone's Avatar
dropzone is offline
Member
 
Join Date: May 2000
Location: Cloud Cuckoo Land
Posts: 29,839
Quote:
Originally Posted by PrimalEnvy View Post
Of course it's nonsense. It's actually F=ma. Or sometimes F=d/dt(mv).
I'm confused. It's my normal state, but bear with me. If you are hit by object X moving at v, won't it hurt the same if a=0 or if it's accelerated to v when it hits? And I'm not sure what d is because you didn't define your terms.
  #45  
Old 07-22-2019, 09:28 AM
HMS Irruncible is offline
Guest
 
Join Date: Nov 2004
Posts: 8,280
Quote:
Originally Posted by Mijin View Post
I guess the one remaining thing is that you are still implying that sometimes clear variable naming is beneficial, when my opinion is that it almost always is, and for many of the reasons you list.
Conversely I don't see any benefit of using single-character names.
If you're working in a language with global variables, yes, they need to be named descriptively. Especially if it lacks namespaces to store them in. Or if you've inherited legacy code where the scope is pages and pages long, then yes, it's a necessary survival skill to to have self-describing variable names.

But if your program is broken down into lexically scoped functions no more than a half page long, then verbose naming of local intermediate products is just distracting. It also attracts "readability tweaks" (maybe I think I have a better name than yours). Better to make the point "this is X, it isn't important, it will only be in scope for a couple more lines anyway).

I take pains to explain my reasoning because we should be talking about general principles rather than universal practices. Again, much depends on your context and tooling.
  #46  
Old 07-22-2019, 09:35 AM
HMS Irruncible is offline
Guest
 
Join Date: Nov 2004
Posts: 8,280
Quote:
Originally Posted by Voyager View Post
I don't see where you said anything positive about comments.
Because you didn't read the comments..
  #47  
Old 07-22-2019, 09:50 AM
Andy L is online now
Member
 
Join Date: Oct 2000
Posts: 6,515
Quote:
Originally Posted by dropzone View Post
I'm confused. It's my normal state, but bear with me. If you are hit by object X moving at v, won't it hurt the same if a=0 or if it's accelerated to v when it hits? And I'm not sure what d is because you didn't define your terms.
You're hurt by the acceleration you cause in object X - a ball that hits you in the stomach hurts more if it decelerates quickly (by hitting unprotected flesh) than it does if it decelerates slowly (by (say) hitting a pillow strapped to your stomach).

"d/dt" is the derivative operator.
  #48  
Old 07-22-2019, 11:01 AM
RaftPeople is offline
Guest
 
Join Date: Jan 2003
Location: 7-Eleven
Posts: 6,688
Quote:
Originally Posted by HMS Irruncible View Post
If you're working in a language with global variables, yes, they need to be named descriptively. Especially if it lacks namespaces to store them in. Or if you've inherited legacy code where the scope is pages and pages long, then yes, it's a necessary survival skill to to have self-describing variable names.

But if your program is broken down into lexically scoped functions no more than a half page long, then verbose naming of local intermediate products is just distracting. It also attracts "readability tweaks" (maybe I think I have a better name than yours). Better to make the point "this is X, it isn't important, it will only be in scope for a couple more lines anyway).

I take pains to explain my reasoning because we should be talking about general principles rather than universal practices. Again, much depends on your context and tooling.
Again, researchers study this stuff. The results are unambiguous. for example, I saw a study where a "reverse text" function (about 10 lines) was studied by experienced programmers, one group had meaningful variable names and one group did not (e.g. a,b,c,etc.).

The group with meaningful names understood the code 2 to 3 times faster than the other group.

Good variable naming is even more important than comments.
  #49  
Old 07-22-2019, 11:34 AM
dropzone's Avatar
dropzone is offline
Member
 
Join Date: May 2000
Location: Cloud Cuckoo Land
Posts: 29,839
Quote:
Originally Posted by Andy L View Post
"d/dt" is the derivative operator.
I figured it was something like that because "d" meaning a change in something made somewhat more sense than it meaning distance, but the only calculus I know is what I made up, like dividing the area under a curve into a bunch of skinny trapezoids and throwing in a miniscule fudge factor. Easier done on a CAD system than a drawing board.
  #50  
Old 07-22-2019, 11:38 AM
dropzone's Avatar
dropzone is offline
Member
 
Join Date: May 2000
Location: Cloud Cuckoo Land
Posts: 29,839
Quote:
Originally Posted by RaftPeople View Post
Good variable naming is even more important than comments.
I never learned COBOL but found I can read a COBOL program. Thanks, Grace!
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:14 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.

Send questions for Cecil Adams to: cecil@straightdope.com

Send comments about this website to: webmaster@straightdope.com

Terms of Use / Privacy Policy

Advertise on the Straight Dope!
(Your direct line to thousands of the smartest, hippest people on the planet, plus a few total dipsticks.)

Copyright © 2018 STM Reader, LLC.

 
Copyright © 2017