Went to github to see the project maturity and
"OneLang is the love child of @koczkatamas and it was not a planned child. .... OneLang is six months old at the time of writing and it already speaks, but don't expect any comfortable conversation with it yet. It cannot grow without a loving family, and as a single dad I cannot take care of it alone. It needs more mommies and daddies who can help raise it up."
It seems like a really strange choice for the "source" language to be JS - a language without any real static typing capability (even with TS).
The most limited & basic kinds of static analysis are technically possible, but why not just start with an entirely static language and translate from that to dynamic languages? Would seem much simpler...
It's fun but breaks very quickly. One simple line such as "console.log(Math.random(10));" will fail.
Amusing anyhow.
Also: please make it python 3. It's been 13 years...
How to do one thing ok, and 10 things strangely.
@koczkatamas this is mindblowingly awesome! Keep it up and ignore the haters.
Question: Can it support plain JS -> other languages? Or does it have to be TypeScript? How could plain JS support be added?
From https://github.com/koczkatamas/onelang/wiki/FAQ it is clear that this tool falls far short of actual polyglottery.
For anyone interested in cross platform development, check out Haxe and its testing process. Writing a target that passes those tests is like finishing Dark Souls. The level of effort here is about on par with finishing the character selection screen.
Programming language translation has to be on the horizon. The cost of switching is currently too high.
I got into a project years ago with this ambition using an AST and allowing each language to provide their own translation for each syntax element or block of code.
It also had the unique benefit of being able to take larger blocks like a function and allowing the translator to provide a full function in some native programming language so that a login or Fibonacci function could have multiple translations in the same language allowing the translation to evolve and adapt to use the most efficient one as new translations were introduced.
Isn't it more an indication of how little substantial difference there is between most mainstream languages?
Hey I'm curious about your journey than the final result. I only skimmed through the code, so I don't understand everything, but it seems that the list of things it will identify is in the "yaml" files. Did you write out all of them or was there a pre-existing database somewhere?
I have wanted this for such a long time. How can I make python the main typing window instead of Typscript?
See also http://cdent.org/
Rather, I think it's a good tool that could help people who already knew a programming language to learn a new one.
How is this different to haxe? https://haxe.org/
it does not work on my first test:
My program is i=1 and the Java program it produces is:
class Program { public static void main(String[] args) throws Exception { i = 1; } }
which is wrong because "i" must be defined in java as in "int i;"
If anybody is looking for something stable for years, have a look at haxe [1]
[1] https://haxe.org
Opening the site on my 3GB RAM laptop froze it - could you please not pile web frameworks atop one another? Being able to translate between languages in all cases is intrinsically impossible because of the halting problem; that this works is a testament to how restrictive and bland the Von Neumann language paradigm is, seeing as these languages aren't terribly different and all have ridiculously long specs. The closest you could get to doing this for most languages would be to specify sets of composable, first-class macros in a purpose-written Lisp (almost certainly a Scheme derivative) and write FFIs to port in standard libraries around the core languages made from macros.
Why not write one piece of code that is simultaneously valid in ~12 languages?
https://github.com/stephane-chazelas/misc-scripts/blob/maste...
I know it takes advantage of some technicalities (end-of-input separators and such), but it's still a remarkably impressive piece of engineering. I put that up there with some really hairy quines (https://github.com/mame/quine-relay), except it can actually be useful!