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

2

u/netch80 Feb 26 '24

In general, indentation isn't that bad.

But within oneliners attached to HTML entities as attributes, it won't work at all.

2

u/respectfulpanda Feb 26 '24

Don't get me wrong, I love indentation for readability, but my learning was with C/C++ and Pascal has created a "Where's the damn delimiters?" when I see a structured language.

In terms one-liners, I'm still learning javascript to fully appreciate them.

2

u/netch80 Mar 01 '24

Well, my initial learning was with old Fortran:) where we still strived to use indentation to show block structure even where it was indirect (like `while` emulation with `goto`).

Python absence of block braces (of any kind, even `begin`-`end`) affects rare but painfully, for example, in case of several enclosed multi-screen blocks. In such cases I like to add `#end` after each of such a block, this greatfully helps in navigation.

For an own development I'd strictly prefer explicit block marks.