Live data from Hacker News

Polycompiler: Merge Python and JavaScript code into one file that runs in both

github.com

1–10 of 17 posts

Re: Polycompiler: Merge Python and JavaScript code into one file that runs in both

#3

Ok, now write your code in a metalanguage(i believe fut might work), and now we can write once and run on two different engines.

Maybe we can convince Marc Feeley to write a backend for Gambit that targets this.

Re: Polycompiler: Merge Python and JavaScript code into one file that runs in both

#6
post #5

You could also write your app in Haxe instead and cross compile to Javascript, Python, C++, Java, Lua,...

This seems to be intended as an interesting experiment (in the same genre as things like quines). There are obviously more production-ready ways to compile code for multiple runtimes.

Re: Polycompiler: Merge Python and JavaScript code into one file that runs in both

#7
post #3

Ok, now write your code in a metalanguage(i believe fut might work), and now we can write once and run on two different engines.

Maybe we can convince Marc Feeley to write a backend for Gambit that targets this.

Hey, I'm writing this from Pr Feeley's lab :)

I understand your comment was tongue-in-cheek, but we certainly have an interest in cross-language interoperability! You can check out our work here:

- https://try.gambitscheme.org is Gambit compiled to JavaScript with the universal backend. Evaluate \alert("hello!") at the REPL to see the JSScheme Syntactic FFI in action.

- https://codeboot.org is our own Python interpreter running in the browser. It has a PythonJS FFI. Evaluate \alert("hello!") at the REPL to test it out. You can even import JS libraries using the standard Python syntax by replacing the identifier with a string: import "https://mycdn.com/mylibrary.js".

- https://github.com/gambit/python is a Gambit module that integrates Gambit with CPython, using the same syntactic FFI. You can import PyPI modules from Gambit.

References to conferences/papers describing these features can be found on my GH profile (https://github.com/belmarca). AMA if you wish!

Re: Polycompiler: Merge Python and JavaScript code into one file that runs in both

#8
post #6
post #5

You could also write your app in Haxe instead and cross compile to Javascript, Python, C++, Java, Lua,...

This seems to be intended as an interesting experiment (in the same genre as things like quines). There are obviously more production-ready ways to compile code for multiple runtimes.

See even https://en.wikipedia.org/wiki/Polyglot_(computing) .

Re: Polycompiler: Merge Python and JavaScript code into one file that runs in both

#9
post #7
post #3

Earlier quoted context omitted.

Maybe we can convince Marc Feeley to write a backend for Gambit that targets this.

Hey, I'm writing this from Pr Feeley's lab :) I understand your comment was tongue-in-cheek, but we certainly have an interest in cross-language interoperability! You can check out our work here: - https://try.gambitscheme.org is Gambit compiled to JavaScript with the universal backend. Evaluate \alert("hello!") at the REPL to see the JS Scheme Syntactic FFI in action. - https://codeboot.org is our own Python interpr…

It was more "ha ha only serious" than purely tongue-in-cheek. I'm familiar with Gambit's multi-backend targeting and have experimented with its JS backend. I consider it one of the quickest, and most comprehensive, ways to get "Scheme in the browser".

Re: Polycompiler: Merge Python and JavaScript code into one file that runs in both

#10
post #5

You could also write your app in Haxe instead and cross compile to Javascript, Python, C++, Java, Lua,...

It's so good to see Haxe mentioned!

I ported an entire AS3/Flash game to Haxe that my friends had written during our college years, as a kind of "thank you" present for ten years of friendship (adding mobile, cross-platform, gamepad controller, netplay and other things).

While the tooling was spotty, I found the experience wonderful! Haxe felt like a decent language with laudable goals and a nice community.

I hope one day I find another reason to work with Haxe.

Does anyone have any project that is using Haxe in production? Would love to hear about such stories!!

Post reply on HN