COMMUNITY

A Quoran wants to know about Haxe


(Thomas Fétiveau) #1

Hey there!

I just came accross this question on quora recently: https://www.quora.com/Is-Haxe-worth-learning-in-2019?nsrc=4

Maybe some of you would have some nice inputs to answer it :)…

Cheers,
Thomas


(Mike Robinson) #2

I think that the last comment made to that Quora says it all: fundamentally, Haxe is cross-compiler which can more-or-less seamlessly target a number of different platforms from just one source-code base. It is also a very strong language that can detect many, many errors at compile time.

As a simple example, I once inherited a god-awful mess that consisted of seven Flash programs, JavaScript that was supposed to talk to them all, and server-side code with which the JavaScript was supposed to communicate. Nothing worked, and it was all separately-written and separately-maintained. I was able to convince the client to let me “re-imagine” the whole thing in Haxe, which I did in about a month and a half.

Now, I had one code-base which generated everything. Furthermore, since Haxe now had a holistic view of every component, and because they all communicated using Haxe modules that ran on all three platforms, Haxe could detect many subtle problems at compile time: where two sides talked to each other, it was simultaneously aware of what both sides were doing. I built them all and deployed them all and … I think, for the very first time in this poor application’s entire history … “everything worked.” And, from Haxe’s point of view, it was one very big program that compiled-out to nine target files. One thing for me to maintain, not nine.

Later, I was working on “another god-forsaken application,” this time one that was trying to use five or six big JavaScript libraries to create a – well, a “web-site in drag” … :roll_eyes: … mobile game. The libraries, many of which actually contributed very little, knew nothing of each other and interfered with each other. Once again, I re-did the whole thing in Haxe. It turned out to be much faster to “do it right” than to keep hammering my head against the past. Haxe’s optimizing compiler now inserted into the output exactly the JavaScript that the program needed, and I was able to eliminate dependency on all-but-one of the original external libraries. Once again, errors were detected at compile time which otherwise would have had to be ferreted-out dynamically in the web browser, if they were detected at all.

The client is now considering whether to deploy native versions of their system (which wouldn’t be web-technology based), or WebAssembly, or … or … or … and the reason why they are now able to reasonably consider such a thing is Haxe. They actually could deploy a native version to Android and iOS and to other platforms, without rewriting it. That’s unprecedented. The value of their investment in source-code just multiplied.

Haxe is a very powerful post-modern system that actually does what its backers say it will do. It is a significantly better and more-productive way to do a great many things, and it has very broad application. As a professional programmer of more than 30 years’ experience, I will very-flatly say: “You must learn Haxe. And, you will not look back.”


(Dan Korostelev) #3

Wow, that sounds like an awesome experience you had there! Any chance you’d make a proper blog post with more details about that? :wink:


(Mike Robinson) #4

I would be happy to write one if you’d tell me where to put it – email miker@sundialservices.com

I’ve used a lot of “JavaScript compilers” over the years, including Google’s necessarily-famous one, but the core problem with all of them is that they are specific to, and written in, JavaScript. They continue to be based on that language and the very-many irreverent things … :wink: … that this language purposely(!) allows you to do. (When visiting almost any commercial web-site, have a peek at the “JavaScript console” sometime. You’ll find it filled with error and warning messages, some apparently-serious but obviously un-detected. Very enlightening.)

A key factor in Haxe’s success and in its unique position is the language, itself. It is a far more advanced tool than most of the languages I’ve seen, including C# 6.0 and recent Java. (And I’ve been programming for more than 30 years now.) So, it naturally brings that kind of stricture to even “JavaScript” deployments, which JavaScript by itself cannot do. Because it generates the source-code, in JavaScript or otherwise, it brings concepts into that world which are normally only found in static compilers, such as static binding of external code. And because it can generate output for more than one target, it can generate code for both sides of a hybrid environment (e.g. JS + Flash or WebAssembly) at the same time, or for both the client and the server at the same time, and do so with rigor.

The thing that kills you, especially with JavaScript, is literally discovering that errors exist. Like other languages of its type (PHP, anyone?) the language allows you to do anything and assumes that you must know what you are doing. They will often “log a message someplace that no one will ever see, and keep right on going.” (You didn’t define the constant FOOBAR? Okay, I’ll just assume that its value should be "FOOBAR" and keep right on truckin’":exploding_head: ) Haxe’s much more rigorous architecture can detect these problems at compile time and swat them dead.

It can also generate efficient code that runs noticeably faster than alternatives do. You actually feel confident that the generated program actually will match the source code that went into it – not always the case with Google’s(!) very-different compiler!

Being "truly cross-platform" is another key factor, not yet appreciated. I’m experimenting with a mobile game application to be deployed on iOS, Android, and one or more game-platforms at the same time using Armory3Danother Haxe-based system, fully-integrated into Blender, which I think is about to take the gaming world by storm.

“You’ve built a better mouse-trap …”


(Dan Korostelev) #5

A good place would be haxe.org blog, actually. We already have similar posts, like FlowPlay case study. Basically you just PR a markdown page like this (see RAW version for blog-specific metadata) and it gets published :slight_smile:


(Mike Robinson) #6

Thanks. I’ll look into it.


(Valentin Lemière) #7

I added some instructions on how to add a blog post: https://github.com/HaxeFoundation/haxe.org#adding-a-blog-post which might help you.


(Mike Robinson) #8

Blog post should be ready tomorrow.


(Mike Robinson) #9

“Hmmmm… maybe not …” :upside_down_face: