2 ms·
I wish I could wave a magic wand and replace all the Python in the world with JavaScript. The languages are practically equal in terms of features. They're bot
by pavlov 4y ago
I wish I could wave a magic wand and replace all the Python in the world with JavaScript.
The languages are practically equal in terms of features. They're both typeless with layered-on crutches available to make the runaway dynamism less painful. They both have weird footguns and ugly syntax and annoying design flaws, but these are different for each. So if you're forced to use both languages, it's an endless pain in the ass to remember which stupid runtime error can happen in JS but not Python and vice versa.
So JS can replace Python... But Python can't replace JS simply because it's unavoidable on the front-end. Since you must have JS code anyway, why use a language that's functionally very similar but different enough in syntax and API that you'll be writing bugs all the time? Just stick with JS and start drinking like me.
- eviks 4y agoIt's easy to avoid JS on the front-end : just wave your wand!
- pavlov 4y agoSince I have an all-powerful magic wand that rewrites history, I guess I could use it to make Python the default language in Netscape Navigator 2.0 and then everything written in JS since 1997 would be in Python instead... But I don't actually want to do that. The Python design philosophy isn't really compatible with loading embedded, sandboxed user programs over the network. A hypothetical Python-Netscape would have crashed and burned with security holes like ActiveX, IMHO.
- thechao 4y agoHere's how out-of-the-loop I am: I'd don't know the command line method for invoking the JS runtime on my computer! What it is? I regularly image my laptop, so I'd like to know what the system JS command line is. (I use Linux & macOS.)
- pavlov 4y agoThe CLI runtime that 99% of people use is Node.js, available via the same package manager where you'd get Python 3. Its dependency management story is not great, but in general better than the horrible mess on the Python side. On macOS there's a system runtime called JavaScriptCore.framework. It's actually a very good and useful engine. If you're writing native code, you could link to that. But of course it doesn't provide any of the Node.js API, just the JS standard library which is tiny. So the most typical use case would be to embed a JS API into your application.
- rjrodger 4y agoNot really safe to assume there's a decent one. Better to install directly from https://nodejs.org/ https://nodejs.org/
- dboreham 4y agoSomewhat agree. In fact for a recent project I began writing in JS for this reason but quickly ran into opinions from team mates with no JS exposure asking "Why wouldn't you use Python?", so I did. But, I think JS as a Python replacement is problematic because: 1. Some probably usable version of Python is already on your computer. Not true for JS. 2. Forced use of async in JS library code, even though Node.js doesn't require it.
- at_a_remove 4y agoAh, but with Javascript you are forced to deal with approximately ten thousand libraries from which you must choose for a given task. I hate that.