I’ve been battling for some time to find the best balance between being pragmatic and my desire to use Haxe when targeting nodejs and the browser. Haxe is my language of choice, but there’s still some hoops to jump if you want to leverage existing ES/JS libraries and frameworks.
I then decided to embrace TypeScript, which to be honest, is actually a very neat language. Yes, it still shares a lot of the JS quirks, but these too are being fixed as part of the ECMAScript evolution.
However, Haxe does have the edge in many cases: pattern matching, everything is an expression, macros, to name a few. Also, there are awesome libs like the suite of tink libs (like tink_web, which is super nice to build APIs with).
My idea was to then embrace TS for what it is good for and Haxe for what it is awesome at, and allowing the programmer to adjust the TS----HX knob as he/she sees fit. This reduces the barrier to entry, by basing the initial app structure and build system off pure TS/JS code/tools. Haxe is a guest here, if you allow, but a guest with the potential to become a host later, if needed to be (possibly).
Nothing here is really groundbreaking or new. A key component is the excellent GitHub - kevinresol/hxgenjs: Extensible JS generator for Haxe by @kevinresol , which has been around for a while already. I just tried to streamline the process and provide a reference implementation that can be further improved.
Here’s the [WIP] experiment: GitHub - haxe-boilerplate/pwa-ts-haxe-sample: A sample PWA app with some Haxe<>TS bridging experiments, for learning purposes. Might not work well. Not suitable for production use.. Please check the README as it has some important info on how to run it. Also, there are some minor issues that I’m facing, although they are not blockers. They are listed at the end of the README file.
I’d love to know your thoughts about this approach, which is by no means a perfect one and there might be aspects I missed/could be improved upon. It does seem to have potential though and provide for a very nice bridge between both languages in the same environment. If you have any additional ideas or constructive criticism, please let me know