4 ms·
When I learnt programming, i was confused by x=x+1; After I understood what it really meant, I wondered why they didn’t use some other symbol to capture this s
by thetruthseeker1 8y ago
When I learnt programming, i was confused by x=x+1;
After I understood what it really meant, I wondered why they didn’t use some other symbol to capture this semantic. Say something like x <- x+1 ; Which implies assignment rather than equality - That way this would be unambiguous and I feel is more clear. I now guess the choice of using ‘=‘ was probably an attempt at making a (compromised) choice given the limited symbols that were available back when High level languages were first written?
- gcmac 8y agoGo write a couple hundred lines of R (please don't actually do this R is atrocious imo) and then you'll understand why '=' is used instead of '<-' - because it's a pain in the ass, even with hotkeys
- abhishekjha 8y agoR has = as well which has been working equivalently for me so far. Any caveats?
- haZard_OS 8y agoHey, hey, hey! R IDEs give plenty of options which utterly mitigate such alleged difficulties: https://stackoverflow.com/questions/1741820/what-are-the-differences-between-and-in-r https://stackoverflow.com/questions/1741820/what-are-the-dif...
- egwynn 8y agoSome languages made slightly better design choices, just not the ones that became super popular! https://en.wikipedia.org/wiki/Assignment_(computer_science)#Notation https://en.wikipedia.org/wiki/Assignment_(computer_science)#...
- kirillseva 8y agothis is exactly how R syntax works
- jcranberry 8y agoSimilar notation is already used for mappings in general albeit from left to right with the bar arrow, and obscures one of the necessary characteristics of recursive functions, which is a mapping to the natural numbers. Edit: Misunderstood, thought you were talking about math, not programming languages.
- Zarel 8y agoHeh, I just read an explanation of this the other day: https://www.hillelwayne.com/post/equals-as-assignment/ https://www.hillelwayne.com/post/equals-as-assignment/ The summary is that C used it because assignment was a lot more common than equality checking, and back then, typing fewer characters was a big deal.