Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 276
Enrico Tuvera Jr Avatar asked Dec 10 '22 18:12

Enrico Tuvera Jr


2 Answers

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.

like image 108
sharptooth Avatar answered Dec 30 '22 01:12

sharptooth


If the compilers for the different languages can produce the same format of object files, the linker doesn't care what language they were compiled from.

Alternatively, you can compile a .dll from any language and it works the same.

like image 42
Anon. Avatar answered Dec 30 '22 01:12

Anon.