1. 15

For background, Haxe is a statically typed language with a fair amount in common with ActionScript. This addition means there is now a decent statically typed compile-to-python option. http://en.wikipedia.org/wiki/Haxe

  1.  

  2. 2

    Thanks for the background. Just a general question about this tool, what would be the use-case for someone to target both C++ and Python? Is this meant for producing (for instance) portable libraries or full applications?

    1. 3

      A few possible use cases:

      • I believe it was actually started by one of the maintainers of the Haxe / SublimeText plugin. The plugin had to be written in Python, but he wanted to be able to write it in Haxe (to invite more collaboration), and so he decided to try implement a python target, and a few other people pitched in to help. So that is one use-case: you need to write code for a Python environment, but are most comfortable with Haxe.

      • You have a Haxe code base, but you need to write some tools (build tools etc) and Python has better library support. For example the Flambe is written in Haxe, but uses a Python-based tool to monitor assets and perform live-reloading. This tool could be rewritten in Haxe now.

      • You have an existing library (like this 2D physics library) written in Haxe, and you want to use it in Python. This would generate the python code, then you just need to figure out how to wrangle it in to a format so you can bundle it is a library.

      • If you had an existing Python web-app, but wanted to use something like Haxe for the client side JS, you could now use Haxe/Python on the server to glue the two together, allowing sharing of code between client and server, and having a more water-tight integration.

      At the end of the day, I think this was written as a “because I can” target - it was not difficult to start it for the original project (a sublime text plugin), and a few people helped out. It gives me some hope that whatever the next-big-platform is, if I still prefer the Haxe language it’s not too hard to just write another target :)

    2. 1

      Haxe is the LLVM of transpilers.

      1. [Comment removed by author]

        1. 3

          To get an idea of how to write “externs” so Haxe code can interact with either the python standard library or various other libraries, take a look at this example:

          https://github.com/HaxeFoundation/haxe/blob/development/std/python/lib/os/Path.hx

          As for use-cases, see my other comment. I don’t think this is meant for people writing full-blown Python apps to suddenly write them in Haxe. But if there are Haxe developers who need to tie in to a Python library or interact with a Python ecosystem, now they can do it without leaving their preferred language.

          I can’t imagine many Python devs switching to such an “ugly” language any time soon (too many curly brackets!), but for those of us who like Haxe or are invested in it, this opens up more flexibility and more options, so I look forward to playing with it.

          1. 1

            You could stub out requests for just the method you call with dummy haxe code and then edit the generated source.