Search code examples
programming-languages

Writing a program in 2 languages?


Can a program be written in more than one programming language? The stuff I read on The Daily WTF seems to imply that big companies/organizations employ several different languages when building a large application. How does that work? I know from working with Django that dynamic web pages are often put together with a bunch of different languages (Python for the controllers, HTML + Django's templating language for the view, and SQL for the models), but what about programs, ie stuff that would turn into an .exe when compiled?


Solution

  • It's quite common to build large applications using different langauges and technologies. Mixing languages comes in different ways.

    First, compilers from different languages can produce compatible output that can be linked together. That can be .obj files from C, C++, Pascal and other languages compiling to native code. Or that can be .NET assemblies - you can effortlessly use an assembly written in any .NET family language from any other .NET family language assembly.

    Then, there're various interoperability technologies. You could have some code wrapped as a COM object and consumed from an application in a different language. Or you could put code in different langauges into different programs and make them communicate via some interprocess communication technology like RPC. In the latter case they will not care at all how the other process works - they only send and receive messages - much like you don't care that your browser and the web server you read pages from are most likely written in different languages.