7 ms·
Is the example they show intentionally hyperbolic? Most of the notation is used incorrectly. * "returns" being |--> is awkward and out-of-line with the meaning
by reikonomusha 10y ago
Is the example they show intentionally hyperbolic? Most of the notation is used incorrectly.
* "returns" being |--> is awkward and out-of-line with the meaning of that symbol. |--> is usually read as a transitive verb "maps to".
* Using the calligraphic F for "def" is extremely weird and unhelpful.
* Having None be the empty set symbol, which is not set(), is strange.
* Blackboard bold F for False is weird, usually that means a finite field.
* Blackboard bold S for string?
* The dissonance between what the blackboard bold characters mean is jarring. Sometimes it's a type, somethings it's a particular object.
* Whatever the notation is for list and dict types (fraktur) is extremely non-standard and overly frilly.
The Greek/AND/OR/comparisons/not-equal/etc stuff is pretty OK. It's actually truly in-line with their meaning in math.
I am only saying this because the author points out at the end in a serious fashion that it's a useful thing to do for readability.
Don't be fooled. Just because you can make your editor look kinda-sorta like math, doesn't mean it actually is math.
- hornetblack 10y agoIn Haskell's unicode package `undefined` is the bottom symbol (⊥, UP TACK). Which is probably closer to None than the Empty set. (However because UP TACK is a mathematical symbol, so Haskell parses it as an Operator and so it must be wrapped in brackets: `(⊥)`)
- nerdponx 10y agoYuck, is that a formal logic symbol? It just looks like "orthogonal" to me.
- OscarCunningham 10y agoIt's used as the symbol for "false" presumably because "T" stands for "true".
- deleted 10y ago[deleted]
- contravariant 10y agoIn a proper font its size is the same as a capital letter, and matches the symbol '⊤' for true.
- spott 10y agoIt doesn't have to be exactly mathematically correct to improve readability. Most of your points are basically "it doesn't look right to me", which is fine, you probably shouldn't use this, but that doesn't mean it isn't useful to other people. >Don't be fooled. Just because you can make your editor look kinda-sorta like math, doesn't mean it actually is math. So what? Doesn't make it wrong... this is just window dressing, which can be very helpful sometimes.
- jdormit 10y ago> Most of your points are basically "it doesn't look right to me" The objection was "the mathematical symbols are not being used correctly", not "it doesn't look right to me". Which makes a big difference if the point of putting math symbols into your code is to make it read like an equation , as the author is attempting to do.
- bnegreve 10y agoMany concepts inspired from math and used in programming do not correspond anyway. In programming 'functions' can have side effects, 'variables' can be mutated, 'integers' have upper / lower bounds etc. Although I agree that some notations are probably unhelpful, I still find nice that it can be done.
- fenollp 10y agoThat list comprehension though. Could be useful to math-fluent newcomers.
- contravariant 10y agoWhat list comprehension? I don't see any. Besides, python list comprehension isn't that far from the mathematical version. Compare: { x^2 : x in Z, x^2 > 10 } with [ x^2 for x in Z if x^2 > 10 ] The main problem is that you can't have a list of all positive integers, so you're kind of forced to make it a generator instead. And the standard set notation clashes a bit with the notation of dictionaries, but on the whole it's not that bad.
- qrian 10y agoIt's there at the first defined function. $$any(code \notin api\_codes \forall code \in codes)$$
- dangom 10y agoAccording to the Wikipedia "In mathematics, the word null (from German: null meaning "zero", which is from Latin: nullus meaning "none")[1] means of or related to having zero members in a set or a value of zero. Sometimes the symbol ∅ is used to distinguish "null" from 0." I guess symbols only exist in a context, anyway, right? They aren't immutable beings with a true meaning. Prettifying an Emacs buffer does not change the text written to a file, so the user can also have a context for himself independent of whether he is collaborating with someone else or not.
- lou1306 10y agoI would have used the "up tack" [^1] (or \bot for LaTeX users) to signify "null". Empty set could lead to ambiguities imho. [^1]: https://en.wikipedia.org/wiki/Up_tack https://en.wikipedia.org/wiki/Up_tack
- dangom 10y agoI agree with you. Specially because ∅ looks a lot like crossed 0, depending on your font. My point is that symbols only have meaning for those who see them. With Emacs pretty-mode, symbols are substituted visually and not ever saved to file.
- dzamo_norton 10y agoThe use of \mathbb{R} for floats acts to obscure things for me I'm afraid. It loads up dusty old stuff in my brain about the reals that is not true of floats from the slow tape archive storage in my skull, and _doesn't_ load up stuff in my brain about floats like, say, where the first integer gap occurs[1]. A side note is that \mathbb{Q} would be a closer match to float. [1] http://stackoverflow.com/questions/3793838/which-is-the-first-integer-that-an-ieee-754-float-is-incapable-of-representing-e http://stackoverflow.com/questions/3793838/which-is-the-firs...
- deleted 10y ago[deleted]
- qrian 10y agoI think we should view them as what we are trying to represent, not what they really are. Besides, with the same logic int32 or int64 isn't really an integer in a sense that it can't represent 2^64.
- OJFord 10y agoIt's still 'an integer'^, it's just that the set {i | i \in int64} is a proper subset of \mathbb{Z}; so using the latter to denote the former is inappropriate. ^i.e. for all i \in int64, i \in \mathbb{Z}.
- jordigh 10y agoOne thing that bugs me about this symbolic fetishism is that it really is cargo culting to an almost literal degree. First of all, mathematicians don't really care that much about notation and notation isn't very fixed. There are some broad conventions, but fashions change all the time within a relatively short time span (relative to the history of mathematics). It wasn't that long ago that "_|" instead of "!" was used for the factorial, and you can find 20th century texts that use that notation. Second of all, most mathematicians really really do not care about notation that much. Notation isn't what makes mathematics, because it's dictated by fashions, whims, and very often, even by jokes. It's completely incidental, to the point that we did mathematics for thousands of years with very little expressions that we would recognise today as "notation". If you're writing computer code, I say it makes more sense to follow the fashions of code than to try to squeeze them into the fashions of mathematics. Too often I see programmers trying to emulate the style but not the substance of mathematical writing, in an attempt to invoke the favour of the ghosts of Euler and Gauss (who, by the way, would not recognise much of the notation that we use today).
- adrianN 10y agoI think good notation is pretty important in mathematics. See for example the difference it makes in calculus. Good notation can make complicated things tractable.
- jordigh 10y agoSure, I'm not saying it's not important at all. It's very helpful to be able to have some shorthand instead of using Latin abbreviations for everything like they did in the fifteenth century. It's just that people that are relative outsiders to the mathematical community give it way more importance than mathematicians do. This is particularly true of computer people, I think, because compilers and interpreters are very rigid about the syntax that they accept. Computer people pass these expectations into mathematics and assume that mathematical writing has some strict, rigid syntax that if not religiously followed nothing makes sense. Terry Tao has something to say about these "compiler errors": https://plus.google.com/u/0/+TerenceTao27/posts/TGjjJPUdJjk https://plus.google.com/u/0/+TerenceTao27/posts/TGjjJPUdJjk
- goldfather8 10y agoHi, author here. Most of your points are addressable by two observations: 1. Context and readibility are user dependent. 2. Choices were made for semantic parsing first and correctness second. The returns symbol was chosen as right arrow since I can set yield to left arrow. I agree the def symbol can be jarring. But I have found it beneficial for nested functions and class methods - it takes up less space. I do note that some choices were 'aggressive', this being perhaps the most aggressive. The times one writes set() vs None influenced the choice. The semantics are close enough. The blackboards were again chosen for parsing semantics, not correctness. Unicode symbols stand out and take less space. I do agree on the dissonance and have since standardized use of blackboard/script/etc.. The mypy changes have benefited me immensely, it's so verbose otherwise. Readability is to the eye of the beholder, where this approach excels since customization is dead-simple and the changes are entirely visual. If one values an exact correspondence to mathematics, then just configure the symbols in that way. The post is indeed hyperbolic to illustrate the choices availible. I do admit that being liberal with the notation makes cross-language configuration challenging. For other languages I only use the basic, correct symbols. Thanks for the feedback.