简体   繁体   中英

JavaScript code resulting from Haxe compilation

I'm a senior ActionScript dev and would like to start converting some of my class libraries to JavaScript, especially those that make use of bitmap manipulation and would target the canvas element in HTML.

My question is how clean is the resulting JavaScript code from a Haxe/HaxeNME compilation? Is it easy to debug?

Or would I be better off forgetting Haxe and coding in JavaScript from scratch?

Well, it's rather readable, but it's not the best idea to debug it, especially if you use a lot of inlining and such.

Currently Haxe is getting support for JavaScript source mapping , which means that you can debug your Haxe code in the browser. This is still at a rather early stage, but should be fully supported within the next couple of months.

It should also be noted that static typing reduces the number of bugs introduced in the first place.

As for whether or not you should use vanilla JavaScript instead is a matter of preference. If you come from an AS3 background, Haxe is most likely a better choice for you.

I would say that back2dos' assessment is no longer accurate in 2019 - Haxe supports JavaScript source mapping quite well , which means that debugging with IDEs like Visual Studio Code that support them works out of the box. If inlining becomes an annoyance during debugging, you can always disable it with --no-inline .

For instance, to debug NodeJS applications you can use VSCode's built-in Node debugger and a launch configuration that looks something like this:

{
    "name": "Node",
    "type": "node",
    "request": "launch",
    "program": "${workspaceFolder}/out/main.js",
    "sourceMaps": true,
    "outFiles": [
        "${workspaceFolder}/out/*.js"
    ]
}

You can even remotely debug in browsers, for instance with the Chrome and Firefox debuggers. If you are using OpenFL, the Lime extension will handle all the configuration for you .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM