Earlier quoted context omitted.
There may be occasions when a single letter makes sense, but this should be the exception, not the rule. If you've got a ton of "anything" variables in your code, then that means there's probably a better, more understandable design for your system which expresses what the variables represent with more precision.
The variables named 'anything' can represent anything, that's the point. Are you saying we should avoid writing code that's too general? I understand that not all languages are powerful enough to allow defining functions that can operate on any type. But this doesn't mean that languages with this expressive power should refrain from using it; it means that users of less powerful languages need to learn something new…
Programming as a Way of Thinking
51–60 of 133 posts
Re: Programming as a Way of Thinking
#52This article starts to get at an idea that I've had for a while now -- that mathematicians are doing it wrong. In the software business we learned a long time ago to name our variables properly, name our functions logically, and to control complexity by breaking ideas into modules and then hiding the details inside. If you can't name something, then you don't know what it is, and that tells you that you should rethin…
I took discrete math last semester and part of the course focused on binary relations and their properties (reflexive, symmetric, transitive...etc). I saw students memorize the mathematical definitions for all properties and yet be unable to actually apply them to a particular relation. I suspect many people ended up ignoring the definitions and coped by developing their own or using intuition. This seems like a sign…
Re: Programming as a Way of Thinking
#53This article starts to get at an idea that I've had for a while now -- that mathematicians are doing it wrong. In the software business we learned a long time ago to name our variables properly, name our functions logically, and to control complexity by breaking ideas into modules and then hiding the details inside. If you can't name something, then you don't know what it is, and that tells you that you should rethin…
Re: Programming as a Way of Thinking
#54This article starts to get at an idea that I've had for a while now -- that mathematicians are doing it wrong. In the software business we learned a long time ago to name our variables properly, name our functions logically, and to control complexity by breaking ideas into modules and then hiding the details inside. If you can't name something, then you don't know what it is, and that tells you that you should rethin…
Interestingly, 500 years ago, math was to your taste. There were not much symbols in it, but lots and lots of English (or, more often, French, German, or Latin) sentences that took paragraphs upon paragraphs of text to describe what today a couple of equations do...
I find a good paragraph explaining what the equation means and implies is far more useful than the equation alone.
This is all the typical "what" vs "why". If you just want to describe the what then the formula alone might be enough (and just presuming everyone know what the variables mean), but if you actually want to convey a some meaning that formula needs to be explained.
Re: Programming as a Way of Thinking
#55This article starts to get at an idea that I've had for a while now -- that mathematicians are doing it wrong. In the software business we learned a long time ago to name our variables properly, name our functions logically, and to control complexity by breaking ideas into modules and then hiding the details inside. If you can't name something, then you don't know what it is, and that tells you that you should rethin…
Is the problem that you want formulas to make sense on their own without the surrounding text? That's not how math is meant to be read. Formulas are reserved for only a few thoughts that are best expressed in that concise notation. The bulk of most mathematical writings is text.
Re: Programming as a Way of Thinking
#56This article starts to get at an idea that I've had for a while now -- that mathematicians are doing it wrong. In the software business we learned a long time ago to name our variables properly, name our functions logically, and to control complexity by breaking ideas into modules and then hiding the details inside. If you can't name something, then you don't know what it is, and that tells you that you should rethin…
When it comes to proofs, you can only keep so much information in your head at once. In most cases, if you have a ton of variables floating around, you are probably trying to do too much at once and would be better served by breaking out a lemma or two from the main proof.
I will note the worst code I've ever read was written by a control theorist that used only single letter variables. I later found out the variable names were the same as a paper, but the paper was not provided in the program comments.
> Pretty much every industry has it's own vocabulary.
So does math. Open up any textbook and you'll see definitions everywhere. When it is useful to name something, mathematicians normally do.
Re: Programming as a Way of Thinking
#57Earlier quoted context omitted.
I don't like mathematical notation's ambiguity and opaqueness much either, but it is fairly important for the notation to be terse. It's more important than in software because so many proofs are about this being equivalent to that, and symbols give you a lot of room to work with, which you would not have with words. And I mean, the vocabulary already exists, papers just need to explain which symbol represents what.…
But that's not our experience in software. We do write "learningRate" over and over again, because we've learned that that makes the code much more understandable that just writing "e". In fact, we've learned that excessive terseness in software is an anti-pattern.
Re: Programming as a Way of Thinking
#58Earlier quoted context omitted.
I took discrete math last semester and part of the course focused on binary relations and their properties (reflexive, symmetric, transitive...etc). I saw students memorize the mathematical definitions for all properties and yet be unable to actually apply them to a particular relation. I suspect many people ended up ignoring the definitions and coped by developing their own or using intuition. This seems like a sign…
IMO this is sort of an ironic example because it's a case where the names actually convey meaning well. It's a case where I've specifically noted to myself "I'll always remember these definitions because the names are so nice".
Re: Programming as a Way of Thinking
#59This article starts to get at an idea that I've had for a while now -- that mathematicians are doing it wrong. In the software business we learned a long time ago to name our variables properly, name our functions logically, and to control complexity by breaking ideas into modules and then hiding the details inside. If you can't name something, then you don't know what it is, and that tells you that you should rethin…
This article starts to get at an idea that I've had for a while now -- that mathematicians are doing it wrong. And you're making a typical programmer mistake in thinking that. Programming is geared towards having people who are experts in programming, but not in a specific subject area, be able to develop and maintain code. Therefore practices like descriptive variable names help provide context to people who cannot…
As a topic goes from specialists to generalists reusing a tiny set of terms becomes a horrible waste of time. Worse, math becomes less precise when different areas reuse terms like infinity, set, numer, area, etc to mean vastly different things let alone identical notation for different ideas.
Re: Programming as a Way of Thinking
#60Earlier quoted context omitted.
> ... a paper that uses entirely unnecessary equations, and doesn't bother to define symbols. This practice wastes everyone's time. I agree with you there, notation should be defined, otherwise it doesn't help explain anything. However, consider that for people who are already used to the notation those "unnecessary" equations are actually more compact and precise than reading the accompanying text. What seems diffic…
> However, consider that for people who are already used to the notation those "unnecessary" equations are actually more compact and precise than reading the accompanying text. What seems difficult to you may be easy for someone else, and vice versa. A struggle for me over the years has been that there does not really seem to be any way of learning the notation, separate from the standard university education process…