3 ms·
That's a bad choice of name from one or more old languages that misused established mathematical terminology (e.g. C misuses void, constant and variable). An i
by willtim 6y ago
That's a bad choice of name from one or more old languages that misused established mathematical terminology (e.g. C misuses void, constant and variable). An immutable variable (or in maths, just "variable') has a value that is unknown at build time but is constant at runtime. A constant has a known value at build time.
What nearly every language calls a variable today, is probably better described as a "reference" or "assignable", but sadly that ship has sailed and we'll forever be inconsistent with the math terminology for that one. Immutable variable is therefore a useful synonym for "proper variable".
- evacchi 6y agoI like "(name) binding"
- agumonkey 6y agoIt's variable in the mathematical sense, not the memory machine sense. f(x) <= x is a variable, but once you picked a value for x you have no means to 'modify' it. Mathematicians seem to frown upon that for consistency reasons and instead will define a new variable name for a derived information from x current value. ps: I'm not sure how true it is, but there was a picture of Ada Lovelace writings saying that Babbage computing machine caused troubles because you couldn't keep track of the value of a gear/variable which made design on paper very error prone
- mikewarot 6y agoBad choice or no, the language is appropriate... Constants should remain constant at runtime. Variables should be allowed to vary. I don't see why people think immutable strings is a good idea, for example. How do you ever build a text editor, if the strings can't be edited?
- willtim 6y agoThe language and notation is inconsistent with hundreds of years of use in maths and confusing for kids learning both maths and programming (at least it confused me). Regarding your skeptism of immutable data structures, it's best to think of immutable data and data structures as copy-on-write instead of update-in-place. This is a technique that is currently very underused, for example most programming languages do not come with "persistent" copy-on-write collections. Here is an example text editor built using immutable data structures in C++: https://github.com/arximboldi/ewig https://github.com/arximboldi/ewig Advantages are excellent support for concurrency (background save works while you edit) and trivial support for undo/redo.
- mikewarot 6y agoI tried diving into the source code, and immediately ran into something new :: everywhere and starting googling.... Namespaces?!? - Looks like a solution in search of a problem. The whole point of object oriented programming was to prevent reaching inside of objects from the outside, thus making then implementation independent from use... Namespaces seem to break that. Like leaving the cover off a machine so that you can push on one of the relay contacts by hand. C, C#, C++ feel to me like Greek all sorts of keywords that make no sense, and random !@#$%^&*():"<>?[] everywhere Somewhere at the top of all that code, there has to at least be one actual pointer variable where you keep track of the last revision, isn't there?