Sunday, June 23, 2019

Multi-language software programs

When two bilingual people talk to each other, they often tend to mix the two languages in their conversation. Have you heard of Hinglish?

As a software developer, it makes me wonder - is this doable or already done for programming languages?

There are ways to compile modules or files written in different languages in the same binary or application, e.g., JNI or Python module, so that one program in one language can invoke an "external" module of another language. There are ways to write program in one language and auto-generate equivalent programs in others, e.g., haxe. Or to connect between separate programs in separate languages via networking. (see more, and more, and much more)

However, syntax embedding is not very common, except in web-style or user interface drivven programs. An HTML web page often includes scripts in JavaScript and styles in CSS, and can potentially include code snippet from any other language, as long as the underlying browser or the embedded script can interpret or apply it.

The interesting question is - is it possible, or even beneficial, to have a program file that can freely intermix any language code on demand?

This is like including code snippets written a Python, C/C++, Java and JavaScript in the same program file. Different languages' code snippets will access the same data (data structures, variables, stack, etc). It will allow a multi-lingual developer to use whichever programming language is best for the given functionality. Even if the mechanism requires separate files within the same compiled or interpreted application, can they freely use the data, and add a new file in a new language without pre-provisioning of the supported languages?

What does it take to create such a developer tool?

No comments: