3 ms·
Isn't this basically the Python data model? Especially so in Python 3, where strings are strings of unicode codepoints rather than bytes ("runes" like Go would
by nerdponx 7y ago
Isn't this basically the Python data model? Especially so in Python 3, where strings are strings of unicode codepoints rather than bytes ("runes" like Go would be even better but codepoints are halfway there).
Edit: In Python, equality, addition, even attribute setting can all be overridden by implementing certain "magic" methods on a class. Much of Python syntax is effectively syntactic sugar for calling these methods.
- grahamedgecombe 7y ago> "runes" like Go would be even better but codepoints are halfway there Go runes are codepoints. I think Swift is interesting, a "character" in Swift is actually a grapheme cluster.
- shellac 7y agoSwift probably inherits that from NeXT/OpenSTEP/Cocoa which was very unusual at the time in its degree of unicode support. For example it used something like unicode equivalence in string comparisons. (You'd see objective-c benchmarks suffer because of this)
- nerdponx 7y agoThanks, yes the Swift model is what I would be going for. I just wrote my first Go program this past weekend, evidently I misunderstood the tutorials/docs I read.
- lmm 7y agoPython or hundreds of other languages have "everything is an object". Java is rare in having a small handful of non-objects in a mostly-object-oriented language. Notice how big a problem the string/bytes split in Python 2 -> 3 migration was though - probably bigger than anything Java has had to do - which suggests this wouldn't necessarily have solved all problems as the author would like.