3 ms·
A lot of Python design decisions have felt weird and off to me but they’ve long justified it by saying that it’s those little ugly design choices that make the
by Revanche1367 1mo ago
A lot of Python design decisions have felt weird and off to me but they’ve long justified it by saying that it’s those little ugly design choices that make the language so usable and effective in practice compared to more well-designed languages that hardly anybody uses. I’m not enough of an expert to clearly say if that’s really true, but imo, there’s a repeated pattern of slightly weirdly designed languages becoming super popular: Python, Javascript, perhaps C as well. Or, maybe we only notice the weirdness because these languages are used so much and get nitpicked to no end.
- frollogaston 1mo agoJS is a lot less weird than Python. And Python is what I started with and continue to use half the time. The article missed the most common one, __name__ == "__main__" like wtf
- Revanche1367 1mo agoI’m not a regular JS user and haven’t touched the language in a long time, but I remember a (popular?) website for teaching modern JavaScript mentioned that some aspect of the function/macro that returns the type of an object was just plain wrong in a specific and important case. This was years ago however, so maybe the problem isn’t there anymore. Anyhow, I added JS to the list mainly because it is known as a badly designed language and Brendan Eich seems to agree.
- frollogaston 1mo agoThere are certainly weird things about it, but they're all things you can ignore especially in modern times, whereas in Python you're constantly dealing with it head-on.
- Revanche1367 1mo agoTotally agreed there, Python is my main language nowadays because of work but the inconsistencies and lack of some very easy to add syntactic sugar to cover up some of the ugliness (like your example above) in a backward compatible way is constantly irksome and keeps me from really loving my most used tool.
- lukan 1mo agoAh yes, nowdays it is even easier, but "Javascript, the good parts" came out 18 years ago already. https://www.oreilly.com/library/view/javascript-the-good/9780596517748/ https://www.oreilly.com/library/view/javascript-the-good/978... Helped me get a more pragmatic approach to use that chaotic mess of a language and environment. Just use what works, ignore the rest (but I also ignored some specific advice from the book and used what worked for me).
- Daishiman 1mo agoI'm not sure what world you live in but I remember quite well when prototypical inheritance was The Way in JS to do object-oriented programming. Then they copied the C#/Java syntax for classes. Then they aded a bunch of reactivity with Observable with a ton of quirks. Every single new, large feature in JS has been full of quirks. The same cannot be said for Python; the exceptions are few and far between and more often than not they're not actually exceptions but rather something bound to core language fundamentals which once understood don't present a challenge because there is an actual underlying consistency.
- Izkata 1mo agoYou've probably just gotten used to it so you don't notice it anymore: https://github.com/satwikkansal/wtfpython https://github.com/satwikkansal/wtfpython (Note some of these are outdated, but some of those only mention that towards the end of the section rather than the beginning)
- Daishiman 1mo agoIf you read it you'll realize that, very much like I said, the Python WTFs have to do with mechanisms that not obvious but are consistent. This is far better than Javascript, where the underlying mechanisms may be superficially obvious in some subset of cases, but are not consistent and generate many special cases.
- frollogaston 1mo agoThe Python wtfs are definitely more consistent than the JS wtfs.
- frollogaston 1mo ago11 years ago sure. Then the classes they added were syntactical sugar. Observable was never part of JS, it's from the rxjs lib that I avoided cause yeah it's spaghetti. In about the same timeline, Py went from threading to async-await, which created classic blocking vs nonblocking mismatches. The whole 2 to 3 breaking migration was also still a big deal in 2015.
- xigoi 1mo agoJavaScript still has many quirks you can’t just ignore, such as sort() using string comparison by default.
- frollogaston 1mo agoThat one does suck. I'd get it if < > did the same thing, but it doesn't.
- hackyhacky 1mo ago> JS is a lot less weird than Python. I challenge you to find Python behaviors as weird and off-putting as anything here: https://wtfjs.com/ https://wtfjs.com/
- frollogaston 1mo agoA lot of those are stuff I'd never do like `Test.prototype = null;`. Some are legit footguns, but they rarely get in your way. Python has weird file imports (no relative ones either), broken package management, historical differences between asyncio and blocking that still cause issues, threading/GIL caveats that trip up even experienced users, indentation for scope (esp weird given it was designed for REPL), weirdly no anonymous functions, 2 vs 3 (mostly gone by now), the __init__ and __init__.py stuff, namedtuple vs dict vs object, `global`, and a whole mess with type-linting if you're going there. You have to deal with all those things every time. Here's one little Python footgun that everyone hits and is also annoying after: def func(array=[]): # default value is empty array, right? array.append("asdf") print(array) >>> func() ['asdf'] >>> func() ['asdf', 'asdf']
- Daishiman 1mo agoWhat you put as an example isn't a footgun if you know how the language evaluation rules work. Once you understand that the "footgun" explains a dozen behaviors, which may be a weird behavior but it is consistent.
- Izkata 1mo agoWhich isn't really much of a refutation because you can say the exact same thing about what's on wtfjs.
- DangitBobby 1mo agoThere's really no comparison. I use both languages extensively and JavaScript is by far the quirkier language.
- 1mo ago
- zmgsabst 1mo ago> __name__ == "__main__" What makes this weirder than other languages detecting if they’re an import or an invoked file?
- scoofy 1mo agoIt’s only weird syntactically. Python tends to lean towards intuitive, natural language by default. I would have assumed they’d have created a syntactically straightforward alternative, like: __this_file__ == “__launch_file__” or similar. I understand python values “only one way” of doing things, but it would be helpful for readability.
- wodenokoto 1mo agoNo, the “readable” shortcut would have been if __main__: There are no magic strings to remember and the IDE can help you look up variables.
- scoofy 1mo agoAgain, this is a CS/Math major kind of thinking. The term __main__ means nothing syntactically. If we care about language acquisition -- thus language adoption -- it is always better to make "very common terms" in the language understandable to someone who is completely illiterate to your formal language. I honestly think one of the main reasons why python is so successful is as simple as: print "Hello world!" ...and later: print("Hello world!") It might not seem like much, but when you're asking someone to pick up a language outside of a classroom setting, it's just much more intuitive than: echo "Hello world!"; or: console.log("Hello world!"); or god forbid: public class GFG{ public static void main(String[] args) { System.out.println("Hello world!"); } } These little things matter in the long run, even if they don't seem like they matter when you're already fluent.
- frollogaston 1mo agoIdk what's better, console.log or print, cause way back as a beginner I was confused what it means to print something. Like with ink? They're both ok, unlike the C++ or Java ways. But Python breaking hello world in version 3 was crazy.
- impulsivepuppet 1mo agothis isn't uniquely pythonic and JS isn't a great counterexample. https://nodejs.org/api/esm.html#importmetamain https://nodejs.org/api/esm.html#importmetamain node also has __dirname and __filename from the good old days.
- frollogaston 1mo agoThe JS one is at least a builtin instead of a magic string
- zahlman 1mo ago> The article missed the most common one, __name__ == "__main__" like wtf It makes perfect sense, but also is not an example of what TFA is about. In fact the entire point of having that `if` check is that `__name__` is not a constant.
- stephenlf 1mo agoYes. These are funny little quirks, but nobody will ever get tripped up by them.
- kmacdough 1mo agoIt's not the ugly design choices that make it popular. It's just that it was the first that did a decent job of being easy to read/write. Even if you write an objectively better language, you can't replace the ecosystem of libraries, education material and human support that comes with popularity. Popularity begets popularity, and since ease of use is the selling point, it's probably never going to practical to replace it as a general purpose go-to for beginners. And where people begin, they tend to stay. So instead we slowpy march on, bearing the burdens of original sin.