A compiler that recognizes different languages ​​and sends them to the appropriate compilers. Possible?

I was thinking if using asp.net, php and java is possible to create a single page.

Actually, I don’t need such a thing right now. It was just an idea that I had in my head, because some features of some languages ​​are good, and some functions or some other languages ​​are good, so I thought that if I combine all these functions into one

I mean, I am creating a page with code from all three asp.net php and java languages.

<asp code></asp code> <php code></php code> <java code></java code> 

or

 <html> <asp code> <php code></php code> <java code></java code> </asp code> </html> 

or something like this, complier will recognize different code segments and send them to run on their compilers for execution. And the output can be recognized and used by other languages ​​in XML

im doesn't say that all languages ​​interact with each other. Although they can interact with each other through XML. But I only mean that the file is compiled as a single object, having different code from different programming languages, which are sent to the corresponding compiler for execution and, finally, returned to the parent compiler

I am thinking of a compiler that can be developed if it recognizes the code of different languages ​​and sends them to its compiler, as is done using the .net framework, for example MSIL

+4
source share
6 answers

Is it possible?

To quote Rev. Lovejoy from The Simpsons, the “short answer is no” with “if.” The long answer is yes, but “but.”

No , it’s currently not possible to use the technology currently used.

Yes , but it requires that you roll your own server, which will act as a spacer, separating the various sections of code and sending them to the required parsers + compilers, and then combine these separate sections to display the page.

Edit: @Shantanu: My pleasure. The implementation is entirely up to you, as I have not investigated anything like this.

Ultimately, I think this is not the most productive thing, since you are likely to encounter a lot of problems.

Biggest creature: Code from one language will not have a clue about what is being done in other languages.

i.e. If you have a variable defined with values ​​in your ASP, the Java or PHP versions will not be aware of this without enormous effort, not to mention the fact that they will not be able to access memory from each other completely.

However, if you want to go down this route, I suggest you look into a parser generator, such as ANTLR . This will help you write a parser that can search for your special tags (note: this can be done using regular expression or parsing with manual rotation, if necessary).

After you split the code, you will want to send it to the compilers for each language from which you can get text output. Once you have this text, it should be all html + javascript, which can then be combined together to display the page.

I will say that if you want 3 languages ​​to interact, you will create a HUGE project. It may be easier to use the .Net infrastructure and write the PHP and JAVA languages ​​for it (which probably already exist), which allows you to abandon the creation of the entire server package.

+5
source

No no. Server-side scripts, the entire file will be transmitted to each of the servers (asp.net/php/java) in turn, and I believe that other code will cause a parsing error.

It would also be terribly inefficient.

+1
source

I have mixed languages ​​using ajax. This may make sense in your case, but you haven’t provided enough details.

0
source

Although not quite what, in my opinion, you mean, just create pages containing several client languages. Just define various type attributes for script tags, for example:

 <html> <script type="text/javascript">...</script> <script type="text/vbscript">...</script> <script type="text/someothersupportedscript">...</script> <body> ... </body> </html> 

If, on the other hand, you want to generate server-side HTML from different languages ​​- well, of course, it is possible, but I don’t know any frameworks that will make this easy. The fact is that almost every server-side library that creates pages expects to generate a full HTML page based on the contents of the HTTP response.

The easiest way to do this may be to designate one language as your “primary” one, have one that actually generates the web page, and then make it make external calls that ultimately provide parts of the page generated by other languages ​​( along with logic to sew them all together). These calls can be a direct process call, RMI with shells, web service calls (local or remote hosts), etc.

However - I'm really not sure why you want to do this. :-)

0
source

ESI

http://www.akamai.com/html/support/esi.html

Essentially, the page is created as a series. Oracle implements this in its web cache products, but just writing a parser is enough.

FROM.

0
source

I think the new compiler should be designed to recognize different source code based on some tags

say

<aspX> - means asp.net
<php> - means php
<C#X> - C # code

like this when this compiler sees this code

It should send the appropriate code to its compiler.

eg,

 <aspX> <asp: Textbox....../> <C#X> xyz=abc(); </C#X> </asp> 

something like that

0
source

All Articles