4 ms·
We don't tolerate poorly named variable and method names in software development - why is it tolerated in mathematical notation?
by aantix 3y ago
We don't tolerate poorly named variable and method names in software development - why is it tolerated in mathematical notation?
- Kuinox 3y agoHistorically paper was costly, and there is no autocomplete on paper too.
- simion314 3y agoYou should try it with long names and without and let's see what is easy to understand. e^pii = -1 or theNatural....Constant... = theCircleConstant... theSqureRootOfMinusOne = minusOn or maybe you replace One with theNeutralElementForMultiplication but maybe someone is too lazy and you need to give a good clear name for what multiplication is, Sorry, but I could not help it, I seen this kind of comments multiple time, some people want to jump to the middle or end of a book/course and skip the hard work.
- qumpis 3y agoThis is other side of extreme. And these constants are widely accepted notation.
- simion314 3y ago>This is other side of extreme. And these constants are widely accepted notation. Some dude will say that "i" is also used as the vector for the horizontal axis, i is sometimes used in induction as iterator too, so clearly it should be refactored to sqrtOfMinusOne. Also + and * are overloaded in math, so maybe they should be replaced with a clear name like "realNumberAdition"
- Freebytes 3y agoWhat you demonstrated as the "bad example" is closer to what mathematicians have been doing recently, but they would use natLog, ratCir, and im as variable names instead inside of a function called gnl() and offer no comments as to what any of it means. From what I have seen, they should likely be putting their code into ChatGPT and asking it to clean it up because it does a better job of writing functions with properly named variables.
- taneq 3y agoAaaargh! Prefixing identifiers with "the" or "my", especially combined with a type name (eg. "int myFirstInt = 3;") is a giant neon warning sign indicating that whoever named them is (a) fresh out of a beginners' course no matter how much calendar time has passed, and (b) they never properly grasped what an identifier is actually for. (I know these are examples and not what you personally would actually name them, but ugh what a visceral reaction. :P )
- simion314 3y agoSure, it was an example I would do something like const E = 2... const PI = 3.14 but the argument was that what if a random say train driver looks at my code, he will not know what E could be.
- thewataccount 3y agoA lot of the times equations are meant to be general and can apply to a vast number of scenerios. For example x̄ (x-bar) is used in statistics to represent the sample mean of a distribution. It doesn't matter what your distribution is, you'd likely call it x̄. Whenever you see an equation mentioning "n", this will very often be the number of items in a set/list/array, not matter what that set is counting. Usually these equations are very general, and they don't care what "n" actually is, and this way it's easy to see where you should plug that number into. If you look at the equation for x̄ (averaging) then you'll see "n" in there, and you already know what it's for, and it's incredibly concise. If you're familiar with them they actually are named relatively well, and generally they're references that you then implement, they aren't meant to be the implementation themselves.
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- crest 3y agoA lot of times mathematical notation use domain specific naming conventions for they variables and each the tradition is a leftover from a time when you had to write the whole line (by hand) for every step you wrote down and only a few name variables. Take a look code at the other extreme can you imagine writing down verbose Java code line by line using quill and ink? I don't even want to read such a low entropy highly redundant "notation" on a 34" 8k screen. The only way to navigate it is through load bearing IDEs.
- niemandhier 3y agoYes! When writing down the equations you use a form that docks to the right points in the mental model space of your audience. In the end the symbols on the paper are just a way to guide the reader to his own understanding of the underlying mathematical truth. I bet most of us do not even think about that. Rho is a density, n is a natural number, epsilon is small, delta a perturbation …
- _dain_ 3y ago>Take a look code at the other extreme can you imagine writing down verbose Java code line by line using quill and ink? Not Java, but I have done productive brainstorming sessions where I handwrite Python or R onto paper, to figure out some kind of tricky problem or algorithm. Syntactically correct and indented too. It's not hard to handwrite code at all. Plus my "comments" can have arrows and diagrams and doodles and anything I like.
- magicalhippo 3y ago> can you imagine writing down verbose Java code line by line using quill and ink? Not quill and ink, but I took several programming exams at uni, where we had to write the answers, including pages worth of Java code with pen on three-layer carbonless copy paper... This was just 15 years ago.
- dheera 3y agoIt has always been tolerated in math. The more unpronouncable the Greek letter, the better. If you want to sound really badass, you start using Hebrew letters as well. The pinnacle of badassness is multiple capital Pi and capital Sigma with some set notation below instead of indexes laid out clearly like a for loop. Or "Einstein notation" where you stop writing the summation symbol because a small group of people think it is implied, which helps gatekeep others from the field of research because they can't make sense of your equations anymore. At that point, people give up on reviewing your paper and just publish the damn thing because you're from Google, Stanford, or wherever. If mathematicians worked like software engineers they'd label things like "density[x, y]" instead of "\rho_{xy}" or at least stop using PDFs and use HTML with a tooltip over each variable name like we have in pretty much every modern editor, but we all know they hate readability.
- jonahx 3y agoObviously, you're not a golfer... This topic is complex. For a more thoughtful take, start with: https://www.jsoftware.com/papers/tot.htm https://www.jsoftware.com/papers/tot.htm
- 6gvONxR4sf7o 3y agoYou often do math on the whiteboard or on paper, and it involves repeated references to the same things, which might take forever to write out at each step. Additionally, since it's a 2d notation, the "shape" of the formulas is informative, which is an aspect you lose with bigger names.
- kebsup 3y agoMy favourite is when CS professors rewrite algorithms in latex and use single letter variables only. So much student time could be saved if they just wrote it in python.