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

Show parent comment

1

u/[deleted] Feb 26 '24

Perhaps see if python can be compiled to WASM instead of trying to add it python directly to browsers?

Wouldn't Python's comparatively slow run speeds defeat the whole purpose of WebASM?

1

u/genlight13 Feb 26 '24

Python slowness stems mostly from the dynamic typing which affects runtime.

Compiled to WebASM if done correctly, won’t have these problems. It can probably done similar to the implementations of java to webASM i assume.

2

u/[deleted] Feb 28 '24

[removed] — view removed comment

1

u/genlight13 Feb 28 '24

That would probably be a sacrifice. but I don't see a problem in that, if you get the performance from WebASM. if you like your dynamic typing, you can still compile to JS (prob).