4 ms·
I think at some point you turn around and become relatively unbothered again. Or you have to if you're forced to work in languages lacking things you like from
by Jach 6y ago
I think at some point you turn around and become relatively unbothered again. Or you have to if you're forced to work in languages lacking things you like from other languages and don't want to feel frustrated all the time. (Doing Java and JS for years I was able to reduce the frustration to only some of the time.)
Until Python 3.4, there were no enums blessed in the reference implementation, but that was fine for me. Is https://docs.python.org/3/library/enum.html https://docs.python.org/3/library/enum.html really that much better than the examples in https://web.archive.org/web/20120207145701/https://norvig.com/python-iaq.html https://web.archive.org/web/20120207145701/https://norvig.co... ? More powerful, sure. But if we just wanted simple C++ enums and not structured Java-like enums it's hard to argue against the conciseness of RED,GREEN,BLUE = range(3) and moving on with what matters.
I guess two advantages of having something blessed by the language are 1) you don't need to think anymore or argue about whose workarounds (if any) are better, like the sibling's comment using PHP interfaces with consts inside, and 2) if the language isn't flexible enough to add the thing yourself, if the thing needs privileged status by the compiler or whatever, then you need the blessing for the best experience. My favorite language (Lisp) has no enums, but it's flexible enough to add them (and people have done so) in a way pretty indistinguishable from if they were there from the start, or of course you can use moral equivalents to the Python 2 examples without fuss. (Rather than just variables though there are also keywords or just plain symbols, which you can have type checked with deftype, and dispatch on with object methods if you like structured enums.)
- an_opabinia 6y agoBut people do want to reinvent Java in all their programming languages.