MultiPardigmn programming/Multilanguage?

I was thinking that a language could be written so that it could incorporate other languages flawlessly or near flawlessly…

I’m new to programming though so I would not know how to go about writting the code for it but I thought I would post it here because I could think of no better place…

I imagine it would look something like:

class javaOpenGL{
public javaOpenGL(){
LangCast(openGL);
}

    LangCast(Lang l){
     //the code that would then process the alien lang.
    }

}

I hope that this gives you people my (blurry) vision of a multilang.

PS I’m not sure this is where I should post it but it did say suggestions not what kind of suggestions.

Sorry - not that simple. There are litterally a million issues!
Microsoft has done a lot of work in this field with regards to .NET. Their solution is to take every language and turn it into the same language - the Intermediate Language (IL) - similar to java byte code. However it’s not perfect, and they had to cut some features in some languages to make it work.

As long as you have a known object model, and an API to access it from each of your languages, it’s “possible”. However, you’ll run into horrible problems with delimiting the different code blocks, you need to pay global attention to issues such as garbage collection etc, not to mention the fact that your syntax-colouring editor will likely roll over and die.

Note that in HTML, for example, you can have blocks that can contain code written in different languages - but you could argue that it works because these languages are all very similar.

I thought that at the basic level all programming languages spawn from the same instruction set.
so what would be hard about it?
at most you would need a compiler/interpiter that understood the different languages and then use a idenifier to let the compiler know what language your using in a particular block of code…

or did I just say something incredibly n00b?

…as if any piece of software in existance understood languages. Hell, few human’s have a decent understanding of their own language :stuck_out_tongue: The Babelfish translater still does horribly childish work in translating. It’ll be quite a ways before we have software that can successfully translate languages.

Well, KickAss, you’d be right that all languages, at some point in their life (during execution) are running in machine code.

However, it also has a lot to do with how different languages have different data representations and formats in memory. For example, Java’s primitive type ‘int’ is a 32-bit number in memory. In other languages/platforms an ‘int’ might be 16-bit - and how do two pieces of code written in opposing languages interoperate on this data?

What you’d essentially be left with, if you could do this, would be a hybrid language where the meaning of various types and reserved words would have a single meaning. Otherwise, your code would be extremely unreadable by anyone who didn’t know the same languages as you.

The only example that I can think of off the top of my head, where this is actually done, is where you can write blocks of Assembly code right in with your C code - but that at least is only learning two languages.

Maybe someday we’ll all program in some voice-activated user interface, where we can simply describe a data structure and have the computer code it for us, and we’ll forget about such issues as this.

[quote]or did I just say something incredibly n00b?
[/quote]
Indeed. It’s a right of initiation to redevelop the same bad ideas all over again. It’s a sign that you’ve learned enough to be dangerous, but not yet enough to know that such an idea has been considered millions of times and always has the same drawbacks. Don’t worry, it’s a good thing. :slight_smile:

Now to answer your question, mixing syntaxes can be a real PITA for the compiler, so it just isn’t done. However, it is possible to mix things at a code bundle level (e.g. Java Class, DLLs, compiled obj file, assembly, etc.). The only real problem is in linking these files together. Each language/OS tends to have its own idea of how links should be handled. Some are dynamic, some are static. Some use the stack one way, some use it another. Some call an interrupt, some perform a memory jump. Etc, etc, etc.

The solution is to generate “glue” code that maps one linking method to another. Usually this glue is so automatic, you don’t even see it. Sometimes, though, it requires the developer to do something (as with JNI). A perfect example of the former is the ObjectiveC <-> Java bridge that exists on Macs. You can call Java code directly from ObjC, and ObjC code directly from Java. The only problem is that it’s buggier than hell. It seems that features like delegates don’t exist in Java, so there has to be a shaky reflection gizmo to make them work. And named parameters don’t exist in Java, so another shaky gizmo must be maintained to map the methods.

At the core of the issue, however, is that one needs to ask themselves WHY they want to use multiple languages? Newbies often think along the lines of “well this bit of code is so easy in BASIC, and this bit is so easy in C”. But this is just inexperience showing through. After they learn a little more, they suddenly realize that languages are not a barrier. Instead, they merely needed to expand their thinking and understand the basics underlying all languages. After that, you can do anything in any language. :slight_smile:

Does that answer your question?