5 ms·
And we're still using '*' for multiplication in our programming languages instead of '×' because using anything other than ASCII for programming is just too har
by rootbear 14y ago
And we're still using '*' for multiplication in our programming languages instead of '×' because using anything other than ASCII for programming is just too hard, or too weird, or whatever.
- scott_s 14y agoTo be fair, I prefer dots over crosses for multiplication of scalars in when I write it myself. I tend to assume a cross means cross product instead of scalar multiplication. (But, oddly, I do not assume that a dot means dot product.)
- sp332 14y agoWe already tried going full-APL but it only proved that it wasn't a good idea. I mean this is impressive https://www.youtube.com/watch?v=a9xAKttWgP4 https://www.youtube.com/watch?v=a9xAKttWgP4 but I still think the notation is too obscure.
- tel 14y agoFull APL isn't just unicode, though, it's also a total commitment to single-character operators as the primary language construct. Take a look at some Agda or Unicode-enabled Haskell code to see it really improving readability... though hampering type-ability.
- recuter 14y agoAs opposed to the many different and less terse idioms you have to do with regular languages? :) Everything is alien before it becomes familiar, I think a condensed guide to get people up to speed on the symbols is all that's necessary. APL doesn't feel like a weird throwback, it feels like it is from the future.
- vorg 14y ago> We already tried going full-APL but it only proved that it wasn't a good idea. When you say full-APL do you mean in one leap? Then I agree it's not a good idea, but how about going to APL in stages? First introduce just some operators (e.g. × ∧ ∨ ∈ ≥ ≤ ≠ → ⇒ only), then introduce more gradually until all APL operators are in use? Then keep on introducing other symbols from Unicode not in APL.
- sp332 14y agoWell I used "we" continuing ruther's sense of "programmers in general". I didn't really do APL myself. I think it was Alan Kay who said: we needed to make APL to know what going too far looked like, that way we could stop wondering if we could do better by going further.
- rmccue 14y agoMore likely, it's because we don't have them on our keyboards. Programming languages are usually about reducing friction for programmers, but using the proper multiplication/division symbols would increase that for most people.
- simonh 14y agoMy best guess would be that we use * for multiplication because x being alphanumeric is a valid variable name. regarding keyboard presence, this is one of the things that irks me about Mac keyboards is the absence of the # character. I write little programs and scripts on my mac infrequently enough that I have to look up how to type it every blasted time. That, and how to take screenshots. The "Print Scrn" key on PCs spoils me.
- Uncompetative 14y agoX = Y x Z B = T ^ F v T P = Q n R u S C = U cross V D = U dot V Area = Width by Height i.e. just capitalising names means that you can define macros that operate as infix operators: L . R -> L dot R L dot R -> Dot[L, R]
- jewbacca 14y agoWhat language are you referring to? I'm not quite sure I understand your examples. -------- Related: In Haskell, any 2-argument function can be used (or defined) infix by surrounding it with backticks, eg: add 2 3 is equivalent to: 2 `add` 3 ---- And you can use this to cleanly write curried functions (often predicates) with their arguments flipped, eg: vowelCount = length . filter (`elem` "aeiou") ---- Note that functions named with punctuation characters are infix by default, and one can be used/defined prefix by surrounding it with brackets, eg: (<$>) = fmap toUpper <$> "aeiou" # => "AEIOU" ---- It's also convenient for resolving a subset of one of the harder problems in computer science: naming things. For a 2-argument function, use it infix and read it as a phrase in english. Which is clearer: ".jpg" `isSuffix` url or: ".jpg" `isSuffixOf` url You can also define functions' precedence and associativity (left/right) when used as an infix operator.