Write a react clone in Python (complete with "pyx" files), and then use one of the python to js transpilers to compile to js on the frontend. On the backend, you'd use "react" just as another simple template language, whereas on the frontend, you'd also have the reconcilation algorithm.
You will never get a perfect Python on JS, only a mockery of it. It would be more confusing than anything. Beside, transpilers add tons of complexity, and this complexity increase more when the language is very different from JS.
You have things like IronPython or MicroPython, which are different from cPython but good enough.
When I say transpiler, I don't mean just mapping one syntax to another. I mean either really compiling to JS, or having a python bytecode interpreter in JS. It is possible to compile very different languages to JS, for example Nim.
I think it should be possible to support 100% of the core language - even metaclasses, why should that feature be more difficult? Of course you would not map Python classes to JS classes! You would map Python classes to something else, like opaque JS objects.
It is not realistic to support 100% of the library, but that is not neccessary - on the frontend, you wouldn't need to use most libraries, and you don't need C FFI. Most of the time, you'll be only pushing JSON or python objects into templates.
More yes, they have catched up on syntax. But they are far, far away in term of features. Even if we completly discard the huge and fantastic python stdlib (but really, no hashing or uuid in web language ?), Python has still:
- operator overriding
- look up interception API
- metaclasses
- embdedded design patterns: iterator, singleton, context manager, etc.
- multiple inheritance
- standardised imports, with hooks
- controlled gc
- dict comprehension
- generator expressions
- type hints
- string formatting language and operations
- much more comfortable lists
- rich built ins (all, any, enumerate, zip...)
- no weird implicit type casting and comparison rules
- stack traces and very explicit error messages
- support of a lot of charsets out of the box
- multiple notations for text and numbers
- types for bytes
- support for imaginary numbers
And so much more.
Because Python is such an easy language to use, it's easy to think it's just a simple scripting language.
It's not.
It is very, very powerful.
But it has such a smooth learning curve and you can be productive in it so quickly a lot of people never need to see it.
You can compare Ruby to Python. Or Go.
But JS ? It's not even on the same planet. The only reason this abomination has this success is because it has an accidental monopoly on the most awesome and popular platform of the human race: the web.
- operator overriding
- look up interception API
- metaclasses
- embdedded design patterns: iterator, singleton, context manager, etc.
- multiple inheritance
- standardised imports, with hooks
- controlled gc
One of the best things about JS is that is has none of these features. Smaller languages are better, and blindly adding features is not the way to improve a language.
Unfortunately, nothing in JS can ever really go away, so it's starting to leave the "small language" sweet spot.
JS is better than Ruby by being smaller and infinitely better specified. Go is a nicer language due to being designed from scratch recently by people with excellent taste.
In your opinion. There are entire platforms, with literally millions of programmers, which say otherwise - like .NET or C++ for example.
My opinion? There's no point in calling a language better without qualifying a context or use-case. There are so many languages, with so many different (takes on) features, that it's frequently impossible to even meaningfully compare them. Much less to say which is better.
In other words, I can agree with your statement, that "smaller languages are better", for example in fitting your tastes or in ease of implementation. I won't agree that smaller languages are "better" universally, however, because it's trivial to show the contrary. It's enough to point to all the "transpilers", template- or macro-systems that are being written all the time, nearly always for small languages. If smaller is universally better, then how come so many people want more features and are willing to invest their time to write a transpiler?
Personally, I like small, elegant languages - but I also like the big, pragmatic languages, the weird and experimental languages, the special-purpose and exotic languages and so on. Each has its uses and may be a good tool in the hands of a professional.
The most popular projects in js are transpilers and small tooling to do basic operations (leftpad, lodash, etc). Apparently the entire js community is disatisfied with what js comes with.
Write a react clone in Python (complete with "pyx" files), and then use one of the python to js transpilers to compile to js on the frontend. On the backend, you'd use "react" just as another simple template language, whereas on the frontend, you'd also have the reconcilation algorithm.