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.