I want to write a translator from java to js, just like the translator from typescript to js. What knowledge should I know?

similar projects:

jweet A transpiler from Java to TypeScript/JavaScript

java2typescript Java To TypeScript Transpiler

I myself, not on behalf of you, ah, I hope to write web programs in the future. I don"t need two editors to come back and cut. I don"t have to write js for a while and write java for a while. And then call it through http. And handwritten url. The same method is written in the foreground and in the background.

so, I think that in the future, I can write the same language in the same compiler, js and java. I prefer to write java, foreground and background interaction. It looks as simple as controller calling the service method. (can you seal another layer on top of http? or use the rpc reference ( DWR , dubbo )

)

ts is a syntax that cannot be directly recognized by browsers and can only be recognized by ordinary js grammar browsers through a translator.
by the same token, since there is a ts-to-js translator ts, as long as there is a java-to-js translator, it is possible to write js in java, that is, to convert one grammar into another.
after you write ts, use tsc to transfer ts to js.
to write java, use the javajs translation command to convert java to js.
doesn"t feel very difficult or troublesome.
it is said that babel, the translator from es6 to es5, was written by a high school student. Everyone can write it if they want. Why can"t others do it to me? It"s not a difficult thing.

apart from the projects I share, are there any other projects that are better than these two projects, or have implemented the functions I mentioned?

and what should I know if I want to write it myself? Is there a ready-made translator library? As long as you enter the differences between different languages and grammars, you can transfer one language to another, or what simple github source code you can refer to

.

to write java, use the javajs translation command to convert java to js.
doesn't feel very difficult or troublesome.

if you really write it, you are a god. Just name two things I don't think it's easy to do.
the first point is that the number of all javascript is a 3-byte float type, but there are int,float,double and other types in java. What if the java bit operation is converted to a javascript bit operation? Can it be solved? Yes, it's troublesome.
the second point is that the classes in java refer to each other. What do you do with circular dependency in javascript? Can it be solved? Yes, it's troublesome.


CheerpJ to learn about


ts to js is just an interpretation from superset to regular syntax. Their implementation is based on ECMA standards, that is, they only need to make explanations at the implementation level, but it is very difficult for java= > js to cross languages, not only in terms of usage, but even from the underlying principles of language design. Otherwise, the pit will get deeper and deeper


the cost of turning stone into gold is much higher than that of directly mining gold
. Similarly, the front and back end can write background (nodejs), or java in the same language. Why do you want to convert java into js?
? this is a thankless thing. There are too many differences between the two languages. If you can turn, you can turn. After all, machines can do things that people can do. But it doesn't make much sense


the escape of optical language can only solve a small part of the problem. What is more important is the runtime and ecosystem of the language.
if java programmers want a language that covers the front and back end, I recommend that kotlin,kotlin-js is mature, similar to your idea.


then why don't you write with the same IDE.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30263-3409f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30263-3409f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?