Pyton is VERY useful, but why hasn't taken over JavaScript?

This is a serious question.

I know nothing about Pyton, and I am working with JavaScript because I work on websites and well, JavaScript is used A LOT on websites…

But if people can build websites with Python, why hasn’t Python taken over JavaScript?

Is it because of things like REACT decided to be written with JavaScript instead of Python?

The only language that works in browsers is JavaScript. You can’t use Python or any other languages. There are some very minor exceptions (for example GSLS is a C-like language for writing shaders, and browsers understand it), but for all intents and purposes it’s JavaScript, full stop.


You can make websites with Python - SERVER side. Meaning Python deals with the backend. However the server only serves the websites to the browser. The browser then takes that and renders the whole thing, so you can see stuff.
And to have interactive websites with Python, you would need to stay in constant contact to the server so it can process information and serve new information if needed. Which is nice, but it means large websites would need large server-farms to handle the traffic on top of the bills that come with more traffic.

And as DanCouper said, browsers are equipped to execute JS. Which also means that even if Python is used in the backend, you’d still include JS files there to be served for the frontend. Just like you still need HTML and CSS, despite Python having libraries for visual design.

Keep in mind, a browser is a completly independant program. If an old browser cannot interpret a new CSS command, then you can’t do anything in the backend about it (except include a fallback). Similarly, as long as browsers are not equipped with a Python interpreter, they can’t run it.
So I’m prette sure even websites that allow to run Python code, actually send the code to the server to be executed and those return the result.


Just as an amendment to my other post, instead of saying “The only language that works in browsers”, I should have said “the only programming language that a browser can execute” (the small exceptions I mentioned still apply)

As an example:

If you have a computer @Elindo, you can run anything you like on it. So, for example, you can have a program written in Python that, when you fill in some template, generates some HTML.

Your operating system will have a load of network functionality built into it.

You can have another program written in Python that uses that network functionality to listen out for when another computer on the network sends a message to your computer.

That message may have been generated by someone using a program on their computer, a web browser in this example.

If the message from the other computer matches some pattern, you build some HTML using that templating program and send it back to the other computer. The web browser will be able to take that HTML and render a web page.

So the first of those things is a “template engine”, Jinja is an example of that. The second is, at core, a server, and when the network is the internet, a web server. So for example http.server in the Python stdlib,

You might have a program on your computer that glues together the above two things with a load of other functionality, a framework like Flask or Django.

The HTML you send may include a form with attributes indicating that when a user types something and hits submit, the contents of the form are sent back to your computer.

Let’s say the contents of the form are expected to be valid Python code (it’s just text). When you receive that text, you eval it with Python and send the result back.

Just to be clear, I’m describing something like Replit.

What you absolutely cannot do is execute Python code in that user’s browser. You can execute it on your computer. But at no point is there ever any Python code executing on the browser user’s computer. There is probably some JavaScript that you sent with the HTML, you want things like syntax highlighting and a way for a user to submit the text they’ve typed without refreshing the web page they’re looking at.

JavaScript is the only programming language that will execute in that web browser, and that’s why no other programming language is used, because no other language can be used.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.