Publishing libraries in target languages

You might want to check out Ć (cito) first, it was designed for this use-case. Not as powerful as Haxe, but might be sufficient for the “carefully limited subset” you already had in mind …

Incidentally, it seems like we have similar desires to use Haxe (or something) to make language-agnostic libraries. I wrote this post recently (unaware of yours here). Absent special syntax to tell Haxe I want to export clean C entry points (and a single function for initializing the ‘runtime’), I’ve decided I’m not going to mess with trying to interface with hxcpp output, but instead am going to try the embedded HashLink approach. Based on what I’ve skimmed I think that’s going to be cleanest and the least effort.

But really the holy grail is something like what SWIG does for C++ - being able to export actual classes and instantiate them / call methods from other languages – essentially what COM tried to solve decades ago (and mostly failed, IMO). Ć/cito is even better than that, since there are no language boundaries to cross with the final output. But the language itself is unfortunately a bit primitive (probably of necessity given how many languages it’s idiomatically targeting).