Is it possible to compile multiple languages together in order to get the best of the different languages.
相关问题
- Angular: ngc or tsc?
- How do shader compilers work?
- Where is the implementation of included C++/C head
- C++ Builder - Difference between Lib and Res
- Why does constructing std::string(0) not emit a co
相关文章
- How to force Delphi compiler to display all hints
- Xcode - How to change application/project name : w
- What other neat tricks does the SpecialNameAttribu
- Are there any reasons not to use “this” (“Self”, “
- What is the purpose of “-Wa,option” in GCC? [close
- php module does not compile. Does not recognize “s
- Why does the C++ compiler give errors after lines
- Can a compiler inline a virtual function if I use
It's definitely possible to link them together (if suitably programmed) after compiling them separately, if the compilers and linkers are all compatible. For example:
this compiles a Fortran file, then a C file, then links them together in a single executable named
together
(assuming they call each other properly;-) using the GCC suite of tools.Microsoft's .NET is a popular way to use multiple languages together -- C#, F#, IronPython, IronRuby, and so on. Visual Studio will handle the compilations into compatible codes and the joining together in assemblies, but you can also do it "by hand" if you wish.
If by "compiling together" you mean having multiple different languages within the same file, that's also possible but rarer -- for example some C compilers have extensions to let you express "inline" assembly language within the same file.
.Net platform is multi-lingual. Parrot is great for mixing Perl, Python, Ruby. What are you trying to do?
Take a look at Swig. It wrapes your
C/C++
code so that you can call it from virtually any other language.It is really hard to cleanly handle Algol-68 thunks in C. Do-able, but I don't think I'd want to do it every day,
Another good example of combining language is the Java platform. You can intermix Groovy, Jython, JRuby, Scala, Clojure, and other languages with Java. The different languages require different compilers, but you can generally call from one language to another. Groovy and Scala are particularly well suited for inter-operation.
Oh, and the Java Native Interface (JNI) lets you call C, C++, assembly and other languages from Java.
(The .NET platform shares these same attributes, as other posters have noted.)
Yes, it's possible, but a lot depends on the specific languages. For example, calling C functions or C++ classes from Python is done routinely.