4 ms·
This article does a great job at pointing out just how needlessly difficult computer science makes itself when it doesn't have to. Example: !(a || b) == (!
by riskable 8y ago
This article does a great job at pointing out just how needlessly difficult computer science makes itself when it doesn't have to. Example:
!(a || b) == (!a && !b)
`a` and `b`. They're meant to represent, well anything really but to the average person (or weirdos like me) it would be infinitely easier to understand if the author wrote it like this:
!(Bob || Sally) == (!Bob && !Sally)
I don't know why but whenever I encounter single-characters-as-math-variables in computer science I have to spend far more time unpacking such statements into things my brain can understand. It is so much easier if such statements are written as nouns that describe actual things.
I remember having a hard time working with C for loops until a friend of mine wrote one like this:
for (int number = 0; number < 10; number = number + 1)
Suddenly it all made sense! I am not alone in this! I have taught programming to kids and others who have struggled to learn programming and this seems to be how normal people think.
Note: We, as a geeky community are not normal. I just have a strange exception in that at least one little part of me thinks like a normal person and that is with "what we name things" :)
- chrisseaton 8y agoI can't understand any point to writing 'a' rather than writing 'Sally'. What practical difference does it make?
- Ensorceled 8y agoThat’s the entire point of their post, it doesn’t make a practical difference to you but does to other people.
- deleted 8y ago[deleted]
- chrisseaton 8y agoI know that, but I don't know what it is that makes a difference to them and I'm interested in understanding it.
- Izkata 8y agoI'm with them, and if I had to boil it down to one sentence: Zero mental overhead for representing the idea. I think visually for anything logic-based - shapes, lines, venn diagrams, etc - so using such abstract no-meaning variables gives me nothing to put into that mental image. So unless the logic concept is familiar enough, I have to invent something for the variable before I can place it in the construct, in order learn the construct. Once the logic construct is familiar to me, I have no issues with the abstract variables at that point.
- cecilpl2 8y agoIt makes it WAY easier to understand exactly why !(a || b) == !a && !b. Bob and Sally are things that people already understand and relate to. a and b are not, so there is an extra layer of indirection there when attempting to reason about them. !(Milk || Sugar) == (!Milk && !Sugar), duh.
- chrisseaton 8y agoSorry I still don't get it. > Bob and Sally are things that people already understand and relate to. People understand they're people's names. But that's not a relevant detail for the equation, so why add that to the problem? It complicates, rather than simplifies, my understanding of it. > !(Milk || Sugar) == (!Milk && !Sugar), duh. I don't get what the 'duh' is. You've added nothing to the equation! They're just different names!
- uryga 8y ago`with_milk` and `with_sugar` are booleans that people have (lots of) experience with. this seems to help us think about this stuff – we've seen how milk/sugar "work" many times, and we've already internalized some model of that situation – we already "get it" on an intuitive level. hence, reusing that model for general Boolean variables reduces the cognitive effort required[0]. for a similar example, see [1]. summary: a study presented people with a logical problem. they failed miserably if the question was about abstract math-y stuff, but got it right most of the time if the variables were like `X is underage` and `X can buy beer` (explained in the "Policing social rules" section) --- [0] as a bonus, we can quickly sanity-check if our reasoning is correct – if there's `no (milk or sugar)` in my coffee, there's obviously `(no milk) and (no sugar)` in it! [1] https://en.m.wikipedia.org/wiki/Wason_selection_task https://en.m.wikipedia.org/wiki/Wason_selection_task
- giornogiovanna 8y agoNo. a and b are things I better understand - they're just "two facts otherwise unspecified". Sally and Bob bring with them all this baggage about humans and names and stuff, so it's kind of stupid to use them as descriptors. Two things: firstly, everybody and their grandma knows about de Morgan's laws, so this is a bad example, and secondly, humans best learn abstract ideas through concrete examples, yes, but if you really need to explain something using examples like "Milk" and "Sugar", then that is best done in comments, not in the code, whose very purpose is to unambiguously specify the abstract idea. This brings up an interesting idea, though - are there any programming languages that "learn" what the user wants by example? What would that even look like?
- tpush 8y ago> It is so much easier if such statements are written as nouns that describe actual things. But there is nothing in 'Sally' or 'Bob' that is more descriptive than 'a' or 'b' in this case; in fact, using 'Sally' or 'Bob' implies that whatever you're talking about specifically involves people, however that is of course no the case. Using non-descriptive single letter names makes total sense in a context like this, since the only semantic associated with those particular elements is equivalence.
- all2 8y ago> But there is nothing in 'Sally' or 'Bob' that is more descriptive than 'a' or 'b' in this case; in fact, using 'Sally' or 'Bob' implies that whatever you're talking about specifically involves people, however that is of course no the case. I will trot out "it is standard pedagogical practice..." If someone doesn't have an abstract mental framework (that mathematics and logic require for understanding) to hang stuff like this on, then it is very helpful to restate things in terms that they are familiar with. Once they understand the specific, then its time to make it abstract: take what they now understand and generalize it - say from people, to predicates in general. You gotta start where they're at.
- ken 8y ago> Once they understand the specific, then its time to make it abstract: take what they now understand and generalize it - say from people, to predicates in general. What does "!Bob" mean, though? Are we negating the person, or their name? Neither one makes sense to me. Maybe I'm too far gone down the computer science rabbit hole, but this is far more confusing to me than "!a".
- all2 8y ago> Are we negating the person, or their name? Neither one makes sense to me. This is a fair statement. I think a treatment of predicates would be necessary before getting to using names as predicates. "When we say 'Bob', we mean 'Bob has enough money for a bus fare'." Then, if we want to say "Bob doesn't have enough money for a bus fare" we can express it with !Bob (which means, in this case 'not Bob'). I agree that using names can be confusing. I think meaning needs to be addressed first.
- deleted 8y ago[deleted]
- gracenotes 8y agoI think you're seeing the influence of math on programming conventions. If I think of something like (!a && !b), I can immediately start doing boolean algebra in my head. I can manipulate it like an algebraic expression and get the job done 10x faster than if I had to work through the "real" meaning. Anyone's productivity in programming can be enhanced by taking a mathematical outlook, although I suppose the beauty of programming is that you don't have to. To throw in a Dijkstra, "The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise." What do you do when certain semantic levels require some mathematical background - do you choose a less precise abstraction or do you just require that background? I'm not sure what the answer should be for this kind of blog post, but at least intro-to-programming materials should be as accessible as possible.
- FridgeSeal 8y agoBecause mathematics is more about the abstract patterns and structures, rather than the meaning of individual variables (as it is for programming). More bluntly, it doesn’t matter what a and b are here, only the overall meaning of demorgans laws. Arguably, giving them names that are any more than minimal signifiers actually detracts from what’s important I.e. the relationship of the law is important, not the variables Bob and Sally. Personally, having the variables called bob and sally actually makes it harder, because the whole expression immediately becomes far more verbose.