FAQ 
Calendar 


#1




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: ξ_{k1}^{p3} 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; 07202019 at 05:41 AM. 
#2




Of course it's nonsense. It's actually F=ma. Or sometimes F=d/dt(mv).
I can somewhat see why using singleletter 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




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




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




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); }); Code:
val ret = foo.map(GetBar) 
#6




Quote:
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 nonmathematician but who occasionally has to digest math / physics / comp sci papers) Last edited by Mijin; 07202019 at 12:13 PM. 
#7




One thing to think about: nowadays, most mathematicians also need to write code. When they do so, do they use meaningful variable names?

#8




Quote:
And I could see no improvement in either clarity or convenience. 
#9




Quote:
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




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




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




Well, it can't all be Principia Mathematica.

#13




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 nonissue.
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 Englishreadable code? 2. Have you thought through how much behindthescenes context needs to be established to make your idioms work? Are you prepared to maintain that? 3. What are nonEnglish 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




Often, in math, descriptive variable names are impossible, because the variables aren't describing anything in particular. Maybe there are a thousand different realworld situations that equation could be describing. Maybe nobody's ever found any realworld situation that would be described by that equation. Maybe there are exactly two known realworld situations described by that math. The only time that descriptive names would really make sense would be when there's exactly one realworld situation described by a particular bit of math, and that's quite rare.



#15




Hard to take a suggestion seriously from someone who makes such glaring errors.

#16




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




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 missioncritical 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




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




In addition to all of the other reasons, computer programs need multicharacter 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




Quote:
2) Mathematician creates paper. Engineer implements formula. Engineer sad. As said, there is a thing as nonpure 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




Quote:
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




Quote:
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:
Objectivelyspeaking 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




Correction: Matlab (no 'h')

#24




Sorry, but symbols have been found to be quite convenient and useful.



#25




Quote:
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




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 [HCO_{3}^{}] 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; 07212019 at 09:40 AM. 
#27




Quote:
__________________
Evidence gathered through the use of science is easily dismissed through the use of idiocy.  Czarcasm. 
#28




Quote:
Meaningful variable name are only important in these cases:
Basically... write good code, and this problem isn't a problem anymore. 
#29




Quote:
but again, as I write above, the solution there is to make your code more mathlike (use tight, singlepurpose 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




Quote:
 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 worldwide, 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




Quote:
Here's the Wikipedia article for the Gamma function. What would your hypothetical wishedfor IDE have given you when you "click the Γ"? Something like this whole article, or a specific part of it, or something else? Quote:

#32




Quote:
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




Quote:
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 oftcited examples like commenting x++ with // increment x However plenty of times I've had to basically reverseengineer 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 nonnested loop variables) Last edited by Mijin; 07212019 at 11:57 AM. 
#34




Quote:
Quote:
Quote:
Quote:
Quote:



#35




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 selfdescribing 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:
Likewise, here are some good reasons to be very descriptive in variable names:
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; 07212019 at 01:01 PM. 
#36




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. Quote:
Quote:
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




Quote:
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




Quote:
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; 07212019 at 07:44 PM. 
#39




Quote:
Quote:
Quote:
Quote:
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




Quote:
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:
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 singlecharacter names. 
#41




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 wellchosen) 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 wellwritten 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




Quote:
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; 07222019 at 01:32 AM. 
#43




Quote:
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




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




Quote:
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




#47




Quote:
"d/dt" is the derivative operator. 
#48




Quote:
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




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




I never learned COBOL but found I can read a COBOL program. Thanks, Grace!

Reply 
Thread Tools  
Display Modes  

