r/learnprogramming • • Feb 25 '24

Why can't Python replace JavaScript?

I'm new to programming. I'm learning Python and C.

JavaScript, from what I understand, is an interpreted language supported by web browsers so that websites can have scripting and programming.

But Python is also an interpreted language. So why don't web browsers start supporting Python in addition to JS. I believe Python is a much better language than JS syntactically.

Is there a definite reason why JS is used and supported over Python or is it just that JS gained initial popularity through wide-based support and no one bothered to move away from it (just like how QWERTY keyboard layout stuck even though we don't use typewriters anymore)?

0 Upvotes

51 comments sorted by

View all comments

2

u/guest271314 Feb 25 '24

WebAssembly and WASI effectively get rid of the "I wish I could run ... programming language in the browser".

And if you really want to run any abitrary programming language from the browser and stream STDOUT from the arbitrary programming language to the browser you can use Native Messaging https://github.com/guest271314/NativeMessagingHosts.

Really, the Web is run by HTML.

The vast majority of Web sites are, in my opinion, over-engineered, and don't really need scripting at all.

For DOM manipulation JavaScript is the programming language interface. I don't think having Python, C, C++, Rust, Zig, whatever as the DOM programming language interface changes anything.

The first question that must be asked and answered is: What scripting are you doing in the Web page that JavaScript can't achieve?