
HaXe - a multiplatform language - revorad
http://haxe.org/doc/intro
======
georgemcbay
I've been using haxe as a way to make programming to an avm1/ActionScript 2
target (embedded-device Flash Lite, pre-Flash Lite 4) bearable. I'm absolutely
delighted Nicolas hasn't stripped out the backend for that target though
surely it must not be too widely used these days.

Our devices (I work at Chumby) will soon be AS3-capable but at this point I'd
like to stick with Haxe anyway because I've grown to love the language for
things like generics, inline methods and it'll be cool to be able to access
the Alchemy memory directly from non-C++/Alchemy-compiled code when I can.

Protip: Don't just look at the release version of haxe, there is a ton of cool
new stuff in the svn that hasn't yet been wrapped into a release, including a
very flexible compile-time code generating macro system.

~~~
revorad
(Sorry this is a bit offtopic.)

You work at Chumby! I'm trying to get into some hardware hacking and came
across your site just recently. I'd love to talk about it and ask some
questions. Can I email you? Or please drop me a note (my email's in profile).
Thanks!

------
code_duck
I wrote a small application in Haxe earlier this year. The task was to contact
a Flash server (FMS) and sync the RSOs. This needed to run as a cron job, so
without a browser or a Desktop. That meant Adobe's tools in this regard were
not useful at all.

I was able to get a small program working with Haxe, however I figured out
that you still need Adobe's runtimes, so it didn't solve our problems. I ended
up using Smaxe ( <http://smaxe.com/> ), which is a commercial (non OSS)
library that allows you to work with all sorts of Flash technology from Java.

I found the whole Haxe system to be intriguing. The Neko VM appears to be
quite sophisticated. The idea of writing PHP in another language is certainly
appealing, as is developing Flash and ActionScript outside of Adobe's IDE.

------
d0m
Quick suggestion about the website: It would be great to have a feel of the
language on the homepage. I.e. I had to dig in in the doc to see how the
language felt like (I used the syntax section).

So, a kind of hello world code that compiles in different platforms could be a
great way to show the strength of the language.

For an example of this, see jquery.com.

~~~
jdonaldson
I agree with this, but the look and feel of the syntax is typical ecmascript,
and not that interesting. I think a simple "hello world" is all that is
needed.

There's a list of snippets here: <http://haxe.org/doc/snip>

some of them handle common tasks in a platform independent manner, or show off
a cool trick:

------
elliottcarlson
I have used HaXe for a while - however no where near the level that it could
be used for.

It's developed by Nicolas Canesse of MTASC fame as well as the developer of
the Neko VM and HaXe which runs on top of it. Excellent and active community
and the features are constantly expanding (considering the additions of output
targets such as iPhone, PHP, JS, etc).

Well worth a look for any developer (even if you aren't interested in the
Flash portion which seems to be the biggest usage area).

~~~
mhd
Is NekoVM interesting? As you said, using it for Flash is the most interesting
part, as it's a good alternative to the official tools, especially on
platforms Adobe doesn't like that much. Yet compiling to PHP for the web
(page/service) part of it seems oddly wrong to me.

JavaScript/node would be another option, but something more native might pique
my interest.

~~~
elliottcarlson
I agree that the PHP portion seems wrong - but it is in active development and
I know a lot of people are indeed using that feature - so while it might not
be my personal output target of choice, it does get used.

The biggest benefit of all this is a build once, deploy multiple architecture,
so if you are a Flash developer, you can also target iPhone or C++ for
desktop, or other outputs with slight code changes.

~~~
jdonaldson
When developing for php or any target, you still need to be aware of some of
the quirks: <http://haxe.org/com/quirks> These are familiar to php devs, but
maybe less so for people who just want to work with haxe on php platforms.

------
znt
It should also be noted that there's an active progress for targeting iOS and
Android targets with HaXe. So if you're an experienced Android/iOS programmer
you may consider lending a hand.

~~~
unwiredben
There's also a great HP webOS runtime for haXe that's already been used for
several projects in our app catalog.

------
revorad
I just came across it. If anyone has any experience with this, please share
your thoughts.

~~~
abstractbill
All of justin.tv's Flash code is written in haXe, because I got fed up with
Adobe's tools a couple of years ago.

It's a very nice Flash compiler, which makes up for some very poor language
design choices imho (for example static typing and type-inference, but the
type inference sucks and frequently infers the wrong type).

~~~
chipsy
Interesting that you dislike the type inference. I think you may be the first
person to say that.

I have found it invaluable for refactoring.

~~~
regularfry
Buggy type inference, on the other hand, may well be infuriating.

Not that I'm accusing haxe of being buggy, but that's the GP's implication...

~~~
chipsy
It's not buggy. It is a straightforward implementation of structural
subtyping. The main flaw of that is that structural subtypes are imprecise and
easy to confuse the compiler with. For example:

Sometimes you will write a function signature with an inferred type that
manipulates properties x,y,z, expecting to pass in class Foo(which has
x,y,z,q,r...). Instead haXe will say something like, "expected Object{x,y,z},
got Foo..." and so you have to add an annotation.

This is a small annoyance, but overall, it's not nearly as bad as Java-style
nominal types. And it is not a source of runtime errors - it's a huge
preventer.

~~~
jdonaldson
This problem will probably get fixed soon. To get an idea of things that
Nicholas (the language author) is working on, you can keep tabs on this page:

<http://haxe.org/com/features> (e.g. optional structure types)

There are still a few kinks in the generics as well, more complex (but common)
method signatures won't work, like this one:

class GenericMap { static public function map <A, B, C:IFold<A>,
D:(ICreateEmpty<B>, IAdd<B>) > ( c : C, f : A -> B ) : D return c.fold(
createEmpty(), function(a,d) return d.add(a) ) }

The haxe compiler is geared to be very quick, and I'm assuming recursive
structural subtyping and complex generics might make things too slow.

The compiler is intimately integrated into most haxe workflows... it is used
not only for compilation, but it also plays a key role in providing automatic
field completions.

------
jdonaldson
HaXe is a "web" oriented language, so the strength is in the write-once,
deploy anywhere style of development. However, another key strength is
handling communication between layers in a website... such as between php and
javascript, or javascript and swf: <http://haxe.org/doc/remoting>

Since each layer is written in the same language, it is simple to write
proxies and connection layers between them. It's also easy to update or change
these protocols all at once. There are already some great serialization,
proxy, and remoting classes in the base library.

------
ubasu
As with any new language, the most important question is: is there an emacs
mode for it? ;-)

~~~
elliottcarlson
<http://people.debian.org/~jps/misc/haxe-mode.el>

:)

------
pufuwozu
Not to hijack the HaXe attention but I also want to point out another
multiplatform language:

<http://fantom.org/>

Fantom has stable and working JVM and CIL targets. These targets are aren't
yet finished for HaXe.

Quick comparison of the languages:

<http://99-bottles-of-beer.net/language-haxe-2248.html>

<http://99-bottles-of-beer.net/language-fantom-2563.html>

These are both very interesting languages. Hopefully they'll get more
attention.

------
chipsy
I've used haXe since 2007 for Flash game projects. It's a good example of
"small language design" in action and cleans up a lot of warts in ECMAScript.

When I started there were unresolved issues making it unpalatable for all
Flash projects(e.g. preloader creation), but they have since all been overcome
and documented. It still requires some elbow grease to get working.

------
some1else
Not that it negates any of HaXe's abilities.. But JavaScript is also a
multiplatform language :-)

It's worth taking a look at though. I have to get over a fear of cross-
compiling (like CoffeScript or RJS to JavaScript), largely because I had bad
experience debugging such stuff in the past.

~~~
onthewings
haXe and JS are both multiplatform and haXe's syntax is ECMAScript like.
However, haXe is strongly typed. I'm not saying weakly typed language is bad,
just another option. Also, haXe can target JS, so platform-wise it owns a
superset of JS's.

------
PowerDev
Additionally haXe as also good support from IDEs like FlashDevelop on Windows
and FDT (Eclipse based IDE) for Mac and Linux as well.

------
jister
interesting but i am not impressed. why can't i just write c++ and compile it?
why would i need haxe for? a "standard" language doesn't need to be compiled
into other non-standard languages.

i thought this is supposed to be multi platform? i don't see C# (windows) or
other languages there? kind of misleading to me, sorry.

~~~
timtadh
If I am not mistaken, this language's main target is the web. As such it
targets both server side programming and client side. It will run on multiple
stacks on both sides. Desktop application programming doesn't appear to be the
target of this language, ie. the lack of C# or Java.

~~~
elliottcarlson
Yes and no... you can do desktop development for it as well (that has been my
main use for it) - for more information check out:

<http://haxe.org/com/libs/swhx> and <http://hippohx.com/>

Primarily I have used it as a custom wrapper around Flash applications being
developed by my Flash team. By creating these custom wrappers I can give full
access to the filesystem and databases without the Flash guys needing much
knowledge of the surrounding development. This is a lot like Zinc is, however
gives me a lot more control over what is happening and I can create additional
dll's to hook in to to further extend what is going on behind the scenes.

