3 ms·
> Take a minute to internalize this; you might misunderstand it as something trivial. This is not about swapping two variables - it is literally about one objec
by karmakaze 4y ago
> Take a minute to internalize this; you might misunderstand it as something trivial. This is not about swapping two variables - it is literally about one object becoming another. I am not aware of any other language that has this feature. It is a feature of enormous power - and danger.
I do think implementing or understanding this is trivial. 'Become' can be implemented by 1. swapping all references to 'a' and 'b', or 2. swapping the data at memory locations of 'a' and 'b'. I can certainly see its interesting uses but don't see any value in describing it as a miracle or something that's hard to comprehend. Using the word 'become' to explain the language feature 'become' also isn't great.
I used ObjectStore at one company that does 'pointer swizzling' to lazy load deserialized objects, where segfault takes the place of `doesNotUnderstand`.
- pjmlp 4y agoI usually use it as an example when people say Python is too dynamic to have a JIT, when Smalltalk was one of the percusors of JIT for dynamic languages with features like become: (SELF then took it even further).
- taeric 4y agoIf I'm not mistaken, this is also an amusing retort to the idea that only statically typed languages can have common refactoring tools.
- pjmlp 4y agoSpecially since the first IDEs with such features were for Smalltalk and Lisp. Mesa (XDE) and then Mesa/Cedar, have several references Xerox papers, on how those enviroments served as inspiration for their IDE like features, like REPL, typo corrections, debugging, code reloading,...
- taeric 4y agoExactly. Too many folks take "static typing" as the only form of static analysis that can be done. Sometimes the only analysis that can be done on a codebase.
- Qem 4y agoIt's really unnerving when people repeat that "too dynamic" remark when there is widely known counterexamples. Fortunately it seems now people stopped denying the problem with the faster cpython project. IIRC, I think the roadmap for 3.12 or 3.13 already has some form of lightweight JIT.
- pjmlp 4y agoYes, apparently it took Microsoft's persuasion to make it happen, hiring Guido exactly for that purpose.