9 ms·
HaXe - Code Once. Deploy Everywhere.
- georgemcbay 15y agoI became a huge fan of haxe when I was working at chumby industries and was limited by the firmware to working on AVM1/ActionScript 2 projects. haxe allowed me to use a much more modern language with far better features (eg. compile time macros, inline functions) than AS2 allowed even while hitting the same VM. It is a really fantastic language for many different platforms and I definitely recommend checking it out.
- rabidsnail 15y ago1. While haxe has macros, they're like ocaml macros not like lisp macros. You can write a function that takes an ast and returns an ast, but because the language isn't homoiconic it feels a lot more like working with dom than like macros in lisp. 2. as2 is a superset of javascript, so it also has inline functions. 3. Having worked in haxe quite a bit, I found that the fancy type system got in the way more than it helped. I can't think of one case where it caught a bug, but I do have memories of spending hours writing typedefs and casting things to Dynamic. 4. You can't really target multiple platforms in practice, because nearly everything you might want to do depends on host-specific features. A multi platform codebase would be riddled with "if (flash) { } else if (c++) { } else if (javascript) { ...".
- georgemcbay 15y ago1. True, but whether or not this is good or bad is subjective. 2. It (AS2 & JS) has functions as a first class type that you can define anywhere, but it does not have inline functions in the commonly accepted C/C++ sense of the definition. Actual inline function support as included in haxe can be hugely important on devices with underpowered CPUs since making a function call has significant overhead in ActionScript when you are running on a dinky ARMv5 core. With inline functions there is no function call thus no overhead (at the cost of making the 'compiled' code larger, which is often a perfectly fine tradeoff). 3. I love the type system, so again I guess this is subjective. 4. There is some truth to this but it is easy to encapsulate code that has to be platform aware (generally UI stuff) into libraries and then keep your primary app code platform independent.
- andrewem 15y agoAs to #2, I think georgemcbay is talking about where the contents of a short function can be copied into the place where it's called (as with the 'inline' keyword in C or C++), thus avoiding the overhead of a function call [1], whereas it sounds like rabidsnail is talking about inner or nested functions, which you can do in JavaScript [2]. [1] http://en.wikipedia.org/wiki/JavaScript#Functional http://en.wikipedia.org/wiki/JavaScript#Functional [2] http://en.wikipedia.org/wiki/Inline_function http://en.wikipedia.org/wiki/Inline_function
- tluyben2 15y ago4. I have worked with haxe quite a bit and I haven't seen this; after a while you create enough libs for yourself to avoid this. Or maybe i'm missing the point here; what kind of host-specific features are you talking about? Maybe you are creating totally different software from what I am making :)
- rabidsnail 15y agoNetworking, drawing to the screen, video and audio, click events, etc. I think that's most of what most apps are doing. If you're doing something numeric (like a simulation or a computer algebra system) my previous statement doesn't apply.
- tluyben2 15y agoBut these things are encapsulated; if you work with haxe a lot, you'll have libs which, besides maybe a config setting per platform, are code compatible...
- lignuist 15y agoI really hope, HaXe gets a JVM compile target one day. In my opinion that would make it a perfect language for writing libraries for a large number of problems for a big audience.
- nkvoll 15y agohttp://haxe.org/doc/intro http://haxe.org/doc/intro says "C# and Java targets are coming soon!", and links to the following tweet: http://twitter.com/cwaneck/status/15486381623091200 http://twitter.com/cwaneck/status/15486381623091200, which is dated 16. December 2010. In other words, I wouldn't get my hopes up :/
- ktizo 15y agoHave been writing swf with haXe ever since AS2, I use it with jedit, it is awesome and Nicolas Cannasse is a god.
- bcrescimanno 15y agoAh, "code once. deploy everywhere." Few examples of marketing to engineers spark quite the same level of skepticism as this oft-repeated claim. Ignoring, for a moment, the complexity of deploying software across multiple platforms, it's important to remember the multiple form-factor problem. The same software doesn't work from a user's standpoint on multiple platforms if the UI isn't correct for that device. The best example I can give is "mobile versions" of sites and apps, clearly targeted at the form factor of a phone, being delivered to a 10" tablet. It's crappy. Bring in the obvious elephant in the room of the number of times this claim has been made from an engineering standpoint and truly failed to deliver, and I yawn every time HaXe is mentioned.
- drostie 15y agoIt should be required that anyone who says "Write once, run everywhere" must write an essay about how they avoid the Java pitfall: "We look consistent everywhere -- but consistently crappy." JavaScript has almost solved this problem, if one views HTML and CSS as the domain-specific languages which JavaScript deploys for rendering its GUIs. You have to know a lot of quirks, but when you finish a site which looks nice in Firefox you can have a reasonable assurance that it doesn't look absolutely horrible in WebKit browsers. What's more surprising is that it has come this close to solving that problem, but I don't remember anyone ever promising JavaScript as something of this nature. There exists some JavaScript pride today, especially with CoffeeScript and Node.js, but since at least my first internship in the summer of 1999 it has been faced with inconsistency and standardization pains -- and I don't remember anyone before that time promising that you could run the same HTML/CSS/JS everywhere. By those standards it's more of a 15-year goal than an initial pitch.
- moe 15y ago"Write once. Debug everywhere."
- GavinB 15y agohttp://unity3d.com/ http://unity3d.com/ Yes, you have to make allowances for the actual differences between platforms (physical buttons, screen sizes, input methods), but the rest of the code deploys extremely well across platforms. When moving between platforms, you only have to rewrite the pieces that you actually want to be different.
- DasIch 15y agoIf they would have something that is worth being called documentation I might have actually taken this seriously.
- benastan 15y agoagreed
- EmmanuelOga 15y agoLike the gigantic wiki? http://haxe.org/doc http://haxe.org/doc Or the API docs? http://haxe.org/api http://haxe.org/api Or maybe you rather reading a book? http://www.amazon.com/Professional-haXe-Neko-Programmer/dp/0470122137 http://www.amazon.com/Professional-haXe-Neko-Programmer/dp/0... http://www.amazon.com/haXe-Beginners-Guide-Benjamin-Dasnois/dp/1849512566 http://www.amazon.com/haXe-Beginners-Guide-Benjamin-Dasnois/...
- lexoyo 15y agoBut the libraries are what makes haXe so powerful, and they clearly do lack documentation...
- emmett 15y agoWe use HaXe at Justin.tv. It has some very nice points, but "code once, deploy everywhere" is ridiculous. So many of the crucial APIs are platform dependent that there is absolutely no way your HaXe application is going to be portable.
- reitzensteinm 15y agoAgreed - my Haxe games run on iPhone, PC, Mac and Flash from the same code base. It's way less work than it would be rewriting them, but it's certainly not a panacea. However, the NME project (http://code.google.com/p/nekonme/ http://code.google.com/p/nekonme/) is getting pretty good; it emulates the Flash APIs on other platforms. Great for games; probably not usable for the kinds of stuff you do at Justin.tv.
- reitzensteinm 15y agoI should mention too that if anyone's interested in Haxe and would like to talk to me for a few minutes about my experience porting the games at http://www.bigblockgames.com http://www.bigblockgames.com and the feasibility of swapping to it from your current solution, hit me up at michael@bigblockgames.com. I don't do contract or consulting work, so you don't have to worry about me trying to sell you something. :)
- ramanujan 15y agoWould you be so kind as to post that experience here?
- reitzensteinm 15y agoSure! * The Haxe C++ output is very solid. Sometimes there are compiler errors that you have to reverse engineer, like for when you use a try{} without a catch{}, which is valid in Haxe, but throws an error in C++. It's relatively easy though; the C++ output contains which haxe file and line number each line is from, and it has never taken more than a minute or two to figure out what's going on. There has only been one logic error I've experienced - Haxe guarantees that arugments of a function are called left to right (i.e. something( readbyte(), readbyte() );), but of course C++ does not. Other than that, as far as the core compiler and code generation goes, if it compiles, the generated code is sound. * Use NekoNME - bootstrapping on the iPhone without it would require a whole bunch of work. It is an API compatibility layer with Flash, and most basic stuff is replicated. So you code against the Flash APIs, and it spits out a native app on the iPhone, etc. That said, call as few of the Flash APIs as possible; roll stuff by hand, because they kind of suck. * The garbage collector is quite slow, especially on the iPhone. So you have to be careful about the number of objects you've got in flight, even/especially strings. I don't keep Black Market's story in memory even on the PC version of the game because of this. * The C++ generated code is very very fast. Though of course some optimisations aren't possible, like creating vectors on the stack, so for example the Haxe Box2d port is slower than the original C++ version of Box2D (I had to use pooled Vectors in Super Goblin). * If you're making something using 2D graphics, catering to the myriad of display resolutions is going to suck. But that's not a function of Haxe. * Similarly, you end up doing a whole bunch of work per platform anyway; stuff like putting in app purchasing into the iPhone apps required (at least when I did it) hacking it into the native sections of the NME libraries (a pain, but doable). * Checkout NME once, and stop updating when it's working well - it breaks often, and is in constant development. * That said, if you're a hacker, get commit access to NekoNME. If you commit solid changes back they'll love the extra help, and you're likely to want to add some missing features (not as many these days as there were when I did it a year ago). Now that Unity3D supports Flash, my next game is actually going to be written in that (see http://www.underthegarden.com http://www.underthegarden.com). However, if Haxe fits your needs (eg write your website backend, Javascript, SWF, iPhone app, PC downloadable all from the same codebase), it's solid and will likely be around for a long time; there'll be some teething pain, but it isn't a lemon technology wise. The reason I suggested people email me is so I can help figure out if it actually does fit their use case!
- azakai 15y ago> Unlike JavaScript which can take hours to debug, haXe has a very strict compile-time type checking feature that allows you to catch errors before testing your program in the browser It's great that you invented a new programming language. haXe is very cool. But why do you feel the need to disparage other programming languages? If you personally don't like dynamic typing, that's fine. But putting that in the blurb for haXe will annoy a large potential audience for your language. For what?
- wavephorm 15y agoThe biggest problem for Haxe is with appropriate JavaScript libraries that abstract the shrinking number of differences between browsers, plus the advent of NodeJS working on pretty much every possible operating system, JavaScript is becoming what Haxe wants to be.
- FlemishBeeCycle 15y agoWhile I disproportionally use Ruby and JavaScript on a daily basis, this statement is referring to a specific type of (common) error, which is largely alleviated by the use of static typing, and therefore not exactly untrue. I didn't take it as a disparaging of dynamic typing.
- azakai 15y agoIt's not untrue. But why the singling out of JavaScript? The statement is true for Python, Ruby and Lua as well. And why even mention another language or class of language in a negative way? I propose that the sentence would better have been written as > haXe has a very strict compile-time type checking feature that allows you to catch errors before testing your program in the browser It loses nothing by removing the disparaging part.
- mkramlich 15y ago"multi-platform. code once. deploy everywhere." wow, that claim makes me feel old. i've lost track of how many existing/legacy ways we have to write once, deploy anywhere, multi-platform apps. it's like what they say about the great thing about universal ultimate standards: there are so many to choose from!
- troymc 15y agoIndeed, this was the promise of C, and it was largely realized: there are C compilers for almost every platform. (You can even use Emscripten to "compile" C to JavaScript, but don't expect miracles.)
- malkia 15y agoI think there was no promise of C. There were two guys that needed somewhat portable compiler to avoid tying them to one system for their ubiquitous by now operating system. Kernighan, Richie, UNIX and C. Or to take more lighthearted - If there really was promise, there would've not been need for a preprocessor.
- ternaryoperator 15y agoThat's right, And even putting aside the preprocessor, prior to C89, C was a mess portability-wise. (Actually, even after C89, portability was still frustrated by the problem of the varying size of ints.) Ritchie designed C to get above the assembly level so that portability would be possible. But it was certainly not attained until much later.
- jamesu 15y agoI've used HaXe in a few projects. Its a nice abstraction with strong typing and so on which helps with larger code bases. Combined with NME it is very powerful: one can compile code for html5, flash, ios, and android with little to no modification. My only criticism would be the 32bit integer handling in the neko target. I'm not sure if its changed recently, but the last time i used it i had to wrap all operations in "Int32.<operation>(<int32 object>)" function calls which to me was a completely braindead solution.
- fufulabs 15y agoSo what would be the perfect requirements for HaXe to make sense? (i.e. target desktop + iOS for a game)
- wensing 15y agoThe Stormpulse map was originally written in AS2 by yours truly. We recently moved it over to haXe and are now generating a .swf and an iOS app from the same codebase. I should say by "we moved it over" I mean an MIT Media Lab PhD. No way could I have figured out how to manage haXe/NME/X Code the way he did to pull it off. But it does work. The biggest work left is to make the iOS app feel like a proper iOS app rather than the Flash app on an iPad.
- srid68 15y agoWhy is there so much skepticism in this. I am also trying to develop something like this by creating a embedded in-process web (resource) server ever where (android/iphone/wp7*/linux/win/osx), then we need to use web technology using jquery mobile with backend rpc to develop the application which should make it cross platform as well native deployed. I am developing this to simplify my clients cross platform headache. Sometimes i wonder why there is no product in the market which can do this, which will make my life easier. Music had 7 symbols and they have perfect interoperability, Software has 2 symbols and interoperability is a dream.
- chc 15y agoSoftware has two symbols? I'm not sure what the analogy is, but the best I can think of would be either opcodes or functions, and pretty much everybody has a lot more than two.
- srid68 15y agoWhat i meant was software is based on binary
- tylerlh 15y ago0110100101100110001000000111100101101111011101010010000001100011011000010110111000100000011101000111001001100001011011100111001101101100011000010111010001100101001000000111010001101000011010010111001100100000011101110110100101110100011010000110111101110101011101000010000001101100011011110110111101101011011010010110111001100111001000000110100101110100001000000111010101110000001011000010000001110100011010000110010101101110001000000110100100100111011011000110110000100000011000100110010101101100011010010110010101110110011001010010000001111001011011110111010100100000011010110110111001101111011101110010000001110111011010000110000101110100001000000111100101101111011101010010011101110010011001010010000001110100011000010110110001101011011010010110111001100111001000000110000101100010011011110111010101110100 ;)
- johns 15y ago
- cromwellian 15y agoAnother option, if you're a Java programmer and want to reuse existing Java libraries you've written: http://code.google.com/p/playn/ http://code.google.com/p/playn/ which is the library initially developed to port Angry Birds to HTML5 (although it's true purpose was to allow Web and Android simultaneous development) This is a multiplatform API for 2D games. It runs as native Dalvik code on Android with a GL backend. On the Web, it runs as JS using GWT for compilation, and either a Canvas or a WebGL backend. For flash, it uses the http://code.google.com/p/gwt-flash http://code.google.com/p/gwt-flash addon for the GWT compiler to produce SWFs. For iOS, it uses iKVM to run Java bytecode on Monotouch. I believe the same code can also run on the XBox and perhaps Windows phone. Box2D is builtin. See http://www.youtube.com/watch?v=VtwUyu7UzcM http://www.youtube.com/watch?v=VtwUyu7UzcM for http://www.youtube.com/watch?v=F_sbusEUz5w http://www.youtube.com/watch?v=F_sbusEUz5w for a longer presentation I did at Google I/O.
- singmajesty 15y agoThe "deploy everywhere" saying may feel a bit tired, but before you hate on haXe before having given it a try, NME is a perfect example of what's possible. I recently wrote a haXe version of "Pirate Pig", a sample game originally written for Enyo in JavaScript. It took me about a day of work to write, and it went straight to webOS, Android, Windows, Linux, Linux 64-bit, Flash, Mac and the iOS simulator. It would have gone to an actual iOS device, too, but I was too lazy to pull out my iPod Touch. If you are interested, please feel free to view the game online, in the webOS App Catalog, Android Market or downloadable. All the source code and assets are available, too: http://www.joshuagranick.com/blog/2012/02/22/nme-game-example-pirate-pig/ http://www.joshuagranick.com/blog/2012/02/22/nme-game-exampl... I am very thankful for haXe, which makes the NME project possible. The great part is that it really works.
- happywolf 15y agoAfter so many years and so many promises like "Write Once and Run Everywhere" and "Framework that solves all your <you name it> problems", now I will only give a language/framework more attention after it is used commercially. What I have in mind are: Go, Lift, D, HaXe, and Scala. But I admit I am not tracking these closely, so my understanding could be wrong.
- aritraghosh007 15y agoAnother programming language which claims to improve productivity by reducing multi-platform portability. Java starter this revolution , by quoting "Write Once , Run Anywhere". That phrase has seriously taken a huge leap today and has been used in all sorts of context. If I start learning this language , I am not sure if I am actually getting the full benefit of what a Java/Python provides. I am not convinced until I actually see a production ready solution.
- jxcole 15y agoHaving been writing in Haxe for a long time, I think the "Code once deploy everwhere" line is an exaggeration. However, it is a nice framework and has some advantages. In Haxe, you can easily break out into the native language with c-like # compiler directives, so you can do #if platform=ipod. Now, this isn't a perfect solution but it does mean that you can keep a good portion of your code the same source which could save you some time. For certain elements like the UI, though, you probably have to write a custom version for each platform no matter what programming language you use.
- Radzell 15y agoAs long as is not javascript i am ok with it. It look kind of like c# or java which i like though.