|
|
|
|
|
by rtpg
1284 days ago
|
|
JS suffers way too much from a lack of a good comprehensive standard library and builtins. It doesn't even have list comprehensions! I get thinking Python and JS are "kind of the same", but there are so many details that Python gets right and JS kinda falls apart on. Python's pervasive dunder methods means that you can look at objects in a REPL and get a good representation (try looking at any non-trivial Javascript object and it's a major pain). You can define equality. Operations _don't_ stringify by default (so dictionaries work like you think they should). And Python has blocking methods, which means that you can write code in a straightforward way. There are a lot of things playing in JS's favor but especially as packaging stories get better it's hard to discount Python's ease of use relative to Javascript IMO. And all of this is kind of ignoring the fact that most people are _actually_ talking about Typescript when they talk about JS nowadays, because writing "raw" JS is so error prone that it would be very difficult to actually get serious work done in it without an extra lint phase (I say this as a huge TS proponent) |
|
JS actually did used to have list comprehension but it was deprecated because nobody used it. There's no need imo. .map, .filter, .reduce, and other array methods achieve the same thing with a nicer syntax imo
Also JS has undoubtedly one of the nicest anonymous function syntax with arrow functions. Something I constantly find myself missing when I'm in a python file.
> And Python has blocking methods
What does this mean? Isn't JS blocking by default? Both languages have async support that you don't have to use...
> it's hard to discount Python's ease of use relative to Javascript
Hmm I guess we just have different experiences with this. I can open up a quick text file anywhere on my computer, save it as a .ts file, import whatever library I want, use TS if I want it, etc and then just run it in the CLI with `deno run test_run.ts`
Feels pretty easy to me. And then you have _anything_ related to UI. Maybe it's just me but I never quite felt comfortable with GUI libraries in Python. With JS I can just make an HTML file and open it up in any browser and I have access to the most cross-platform UI API in the world: the WWW
> "raw" JS is so error prone that it would be very difficult to actually get serious work done in it
If you're trying to get "serious" work done you probably shouldn't be using either of these languages. Or if you are, you'd definitely have some linter set up for either one. Also, Python's typehints are nice, but it can't compare to TS. And if you don't wanna go all in on TS, you could always stick with JSDoc comments which get you 90% of the way there for small projects and have really great support in any modern IDE.