I'm planning to write a single API that is syntactically valid in most major programming languages (to the greatest extent possible, so that only minimal amounts of code will need to be re-written when moving from one language to another). I think the simplest way to do this would be to write a group of functions that consisted entirely of function calls and variable assignments, since the syntax for function calls is almost exactly the same in all major programming languages.Of course, I'd need to write wrapper functions for if-statements and while-loops, since the syntax of each of these is different in each programming language.Here's a proof-of-concept for one polyglot function that should work in most programming languages://JavaScript syntaxfunction proofOfConcept(){    printSomething(This is just a proof of concept.); //the function printSomething will    //                      need to be implemented separately in each programming language.}//Java syntaxpublic static void proofOfConcept(){    printSomething(This is just a proof of concept.); //the function printSomething will    //                      need to be implemented separately in each programming language.}//Python syntaxdef proofOfConcept():    printSomething(This is just a proof of concept.); //the function printSomething will    //                      need to be implemented separately in each programming language.//C syntaxvoid proofOfConcept(){    printSomething(This is just a proof of concept.); //the function printSomething will    //                      need to be implemented separately in each programming language.}Would this be a useful design strategy, or is there a better way to do this? I think this would be a useful strategy for developing libraries in multiple programming languages, althogh it would require a small number of language-specific functions to be written for each target language.
Writing an API that is syntactically valid in multiple programming languages
language agnostic
The Katahdin programming language was designed to solve this problem. Its documentation includes this example, which combines Fortran and Python functions in one file:import fortran.kat;import python.kat;fortran {    SUBROUTINE RANDOM(SEED, RANDX)        INTEGER SEED        REAL RANDX        SEED = 2045*SEED + 1        SEED = SEED - (SEED/1048576)*1048576        RANDX = REAL(SEED + 1)/1048577.0        RETURN    END}python {    seed = 128    randx = 0    for n in range(5):        RANDOM(seed, randx)        print randx}