Question

I was thinking whether it is possible to bridge asp.net, php and java to form a single page.

Actually i dont need any such thing as of now. It was just an idea that stiked to my mind as some features of some languages are good and some features or some other languages are good, so i was thinking what if i combine all these features into one

I mean, I m creating a page that has code from all the 3 languages asp.net php and java.

<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 that complier recognize different segments of code and send them to run on their compilers to execute. And output can be recognized and used by other languages in XML

i m not saying that all the languages to interact with each other. Although they can interact with each other through XML. But I only mean to say that the file is compiled as a single entity having different- different programming languages code which are send to their respective compiler to get executed and finally returning back to the parent compiler

I am thinking of a compiler that can be developed whcih recognize different languages code and send them to their compiler as done by .net framework eg MSIL

Was it helpful?

Solution

Is it possible?

To quote reverend Lovejoy from The Simpsons "short answer no with an if. Long answer yes, with a but."

No, it is not currently possible if you use currently available technology.

Yes, but it requires you to roll your own server which would act as a shim, splitting out the different sections of code and sending them to the requisite language parsers + compilers, and then bring those separate sections back together to display the page.

Edit: @Shantanu: My pleasure. The implementation is completely left up to you as I have not investigated anything like this at all.

Ultimately I feel this is not the most productive thing to do as you will probably run into a large number of issues.

The biggest being: Code from one language will have no concept of what is being done in the other languages.

i.e. If you have a variable defined with values in your ASP, the Java or PHP versions would be unaware of it without huge effort, not to mention they would be completely unable to access the memory from each other's processes.

However, if you do want to go down this route, I suggest you look into a parser generator like ANTLR. It will help you write a parser which could look for your special tags (note, this could be done with regex or a hand spun parser if needs be).

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

I will say that if you want to have the 3 languages interact, you will be creating a HUGE project. It may be easier to use the .Net framework and write the PHP and JAVA (which probably already exist) languages for it, allowing you to forgo creating a whole server stack.

OTHER TIPS

It's not, no. The scripts being server side, the entire file would be passed to each of the servers (asp.net/php/java) in turn and I believe the other code would cause a parse error.

It'd also be horrendously inefficient.

While not quite what I think you have in mind, it's simple to generate pages that contain multiple client-side languages. Simply define different type attributes for the script tags, e.g.:

<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 HTML on the server side from different languages - well, of course it's possible but I'm not aware of any frameworks that will make this easy. The thing is, just about every page-generating server-side library expects to form a complete HTML page based on the contents of an HTTP response.

The easiest way to go about this might be to designate one language as your "primary", have that one actually generate the web page - and then get it to make external calls that ultimately supply the parts of the page generated by other languages (along with the logic to stitch them all together). These calls could be direct process invocation, RMI with wrappers, web service calls (to local or remote hosts), etc.

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

ESI

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

Essentially the page is built up in a series of tiles. Oracle implements this in its webcache products but it'd be simlpe enough to write a parser yourself.

C.

I think a new compiler has to be designed to recognize different source code on the basis of some tags

say

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

like this When this compiler see this code

It should send the corresponding code to its compiler.

eg

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

something like that

I've mixed languages using ajax. It may make sense in your case, but you haven't provided enough detail.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top