Live data from Hacker News

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

github.com

11–17 of 17 posts

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

#11
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.

Haxe is not just an experiment. It is a mature language and ecosystem used in production. You will find it powering many games for example.

I used it a long long time ago on one of my first freelance gigs (with a PHP target). It was already quite solid and saved me the need to use a PHP framework.

I also remember using it as a typed javascript pre-compiler, at a time where FB Flow and MS Typescript were still fighting over developer mindshare. I would probably still use it if TS didn't take over the ecosystem entirely.

https://haxe.org/use-cases/who-uses-haxe.html

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

#12
post #5

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

To what extent does Haxe still align with modern Javascript? Is modern javascript even considered to be the basis of actionscript anymore?

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

#13
I'll raise you a polyglot script that doesn't require eval: :)

  1 // len("""
  console.log('javascript');
  /* """)
  print('python');
  # */
Example:

  # python3 /tmp/test.py
  python
  # node /tmp/test.js
  javascript
I _believe_ the only source limitations are the the JS cannot contain `"""` and Python cannot contain `*/`.

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

#14
post #11
post #6

Earlier quoted context omitted.

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.

Haxe is not just an experiment. It is a mature language and ecosystem used in production. You will find it powering many games for example. I used it a long long time ago on one of my first freelance gigs (with a PHP target). It was already quite solid and saved me the need to use a PHP framework. I also remember using it as a typed javascript pre-compiler, at a time where FB Flow and MS Typescript were still fightin…

"This" = Polycompiler (the OP project), not Haxe. Polycompiler appears to be intended as a toy/experiment, so it doesn't really make sense to compare it to Haxe.

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

#15
post #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 on…

Not my project but there's always Dead Cells and the stories behind its developed.

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

#16
post #9
post #7

Earlier quoted context omitted.

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".

BTW I'd love to hear your feedback if you have tried the above examples!

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

#17

I'll raise you a polyglot script that doesn't require eval: :) 1 // len(""" console.log('javascript'); /* """) print('python'); # */ Example: # python3 /tmp/test.py python # node /tmp/test.js javascript I _believe_ the only source limitations are the the JS cannot contain `"""` and Python cannot contain `*/`.

use r"" (raw-string literals), to avoid breaking on invalid Python escape sequences in the javascript part.
Post reply on HN