6 ms·
Preach. We need more Python slander. It annoys me to no end when people trash JavaScript as if it was some exception in bad language design. Most languages have
by alabhyajindal 1y ago
Preach. We need more Python slander. It annoys me to no end when people trash JavaScript as if it was some exception in bad language design. Most languages have something bad that can be picked up and trashed on - some more than others.
- heavenlyblue 1y agoGiven that it starts with a thing called "id" which is an implementation detail and probably should not be used for equality, it seems like this is a geniuinely well designed language :)
- mirashii 1y agoid is not an implementation detail, it's a core built-in function of the language. The value that it returns is an implementation detail, but the properties of the value it returns are not and perfectly valid to rely on.
- 0xDEAFBEAD 1y agoThe "properties of the value it returns" are, by design, implementation-dependent. You're only supposed to use the id function if you need to know something about what's going on under the hood. The id function is working exactly as intended: it's exposing aspects of the implementation, if for some reason you need to know that stuff. It would not be a positive change to sacrifice Python performance in order to make the output of id() more intuitive. I've spent many hundreds of hours coding Python and I don't believe I ever used that function or saw someone else use it.
- zahlman 1y ago`id()` is documented and mandated to exist, and the result provides guarantees that make it suitable for identity (not equality) checks[1] (although of course you should normally use the `is` operator). Pitfalls involving it are generally really pitfalls with understanding object lifetimes[2]. [1]: https://docs.python.org/3/library/functions.html#id https://docs.python.org/3/library/functions.html#id [2]: see e.g. https://stackoverflow.com/questions/52096582 https://stackoverflow.com/questions/52096582
- bnchrch 1y agoThank you! For years Ive been saying the sheer volume and fury by which Javascript is criticized is much more applicable to Python. Both aren't perfect languages, and both are far from "the best" but it is maddening that Python get often picked as a darling when its implementation, ecosystem and tooling are fundamentally at odds with correctness and productivity.
- verbify 1y agoI think people pick on js more because it's the only option for scripting frontend for the web, while if you don't like python there's probably another language that can be used instead.
- dreamcompiler 1y agoUnless you're doing AI, in which case you're royally screwed.
- socalgal2 1y agoI'd say people pick on JS because they don't learn it. They jump in, use it like python or C++, get frustrated it's not the same as what they're used to, vow to use it as little as possible. This was especially true before es5/es6 with var function scope and no class syntax.
- moffkalast 1y agoYeah python deserves a good bashing as well, it's about as bad as JS in this regard. I mean for bool("false") resolves to True ffs.
- bnchrch 1y agoDon't forget its transitive dependencies creating non-deterministic builds
- 3eb7988a1663 1y agoThat is entirely consistent with how truthiness works in Python. The function does not claim to parse strings, that is how you get YAML Norway. Do you think there should be different results for bool("no"), bool("false"), bool("heckno!"), bool("heckyes!")? Edit: should have included internationalization: bool("nein!")
- moffkalast 1y agoHonestly once you really think about it just about nothing about these decisions ever makes any real sense which is why JS is made fun of constantly. It's nonsense functions running on nonsense data. "if some_non_bool_value:" should not be valid syntax and truthy and falsy is a concept that would get you locked up in an asylum if you decided to explain it to a doctor.
- crazygringo 1y ago> The function does not claim to parse strings But it's entirely reasonable to think it would. I honestly don't understand why it wouldn't, because: >>> int("35") 35 >>> float("3.5") 3.5 >>> bool("False") True If casting from a string to a type works with ints and floats, why not with bools? What possible justification is there? And of course it doesn't need to work for "no" or "heckno!", that's silly. But it sure seems like it ought to work on whatever the official string representation is. And not produce: >>> bool(str(False)) True I'd honestly much prefer bool() threw an exception on receiving a string, rather than act the way it does now.
- 1y ago
- motorest 1y ago> We need more Python slander. It annoys me to no end when people trash JavaScript as if it was some exception in bad language design. Python's file system support across platforms is notoriously problematic or even outright broken. Wasn't this enough reason to put it lower in the quality bar than JavaScript?
- akdor1154 1y agoJavaScript doesn’t even have file system support.. each runtime has its own tacked on implementation in the relevant “standard” library. Now which is notoriously problematic?
- fragmede 1y agowat https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- bb88 1y agoI came here to say that. That was an eye opening intro to Javascript for me.
- throwaway314155 1y agoJavaScript is far more jarring than Python depending on your background. They do both have issues of course, but that's the reason JavaScript gets "picked on" more.
- bb88 1y agoHow does this attract more people to hackernews who come from the python world? If anything, it just shows how toxic people can be on this site.
- hamstergene 1y agoThere could be generational gap here: for many people the first JS was ES5 or later, which is after the language was taken seriously and fixed. The difference between Python2 and ES1-ES3 was much bigger than between modern Python and modern JavaScript, so some protest against old bad fame is understandable. But, if you have any suspicion that JavaScript has been treated unfairly: it hasn't. It is literally being replaced by TypeScript as we speak. The fact you have to invite people to come up with more Python slander is itself a testimony, JavaScript has never needed an invitation. Having lot more issues than others is what being exception means, and JavaScript is one.