2. About me
Senior Server Developer at Creative Mobile
Haxe user since 2008
Introduced Haxe in our company
3. What is Haxe?
First release in April 2006
Open source language
Strictly typed
Developed by Nicolas Cannasse
(Well known in Flash community thanks to MTASC compiler)
4. Why Haxe is cool?
Cross-platform OOP language
Good syntax
Provides good API for extending language
Generates sources for target language
Big community
Haxelib - repository for your Haxe libs
online REPL try.haxe.org
9. It's not JS! We have classes:)
interface Placeable<T> {
public var x:T;
public var y:T;
}
class Main implements Placeable<Float> {
public var x:Float;
public var y:Float;
public function new() {
trace("I'm constructor!");
}
}
11. How about abstract types?
abstract StringSplitter(Array<String>) {
inline function new(a:Array<String>)
this = a;
@:from
static public inline function fromString(s:String) {
return new StringSplitter(s.split(""));
}
}
var splitter:StringSplitter = "Hello";
trace(splitter); // [H,e,l,l,o]
15. We have algebraic data types too
enum Color3 {
Red;
Green;
Blue;
Rgb( r : Int, g : Int, b : Int );
Alpha( a : Int, col : Color3 );
}
function toInt( c : Color3 ) : Int {
return switch( c ) {
case Red: 0xFF0000;
case Green: 0x00FF00;
case Blue: 0x0000FF;
case Rgb(r,g,b): (r << 16) | (g << 8) | b;
case Alpha(a,c): (a << 24) | (toInt(c) & 0xFFFFFF);
}
}
29. Conditional compilation
for platform-specific code
#if flash8
// Haxe code specific for flash player 8
#elseif flash
// Haxe code specific for flash platform (any version)
#elseif js
// Haxe code specific for javascript plaform
#elseif neko
// Haxe code specific for neko plaform
34. Haxe shortcomings
Not-so-good IDE support:
Good support in FlashDevelop (Windows only)
Limited support in IntelliJ IDEA for all platforms
Few other IDEs like FDT
Verbosity (i.e. no short lambdas)
Written in OCaml:)
37. Drag Racing Social
Simulation library port from Java to Haxe
Main functionality in game
Same simulation code base for client and server
Not afraid of floating point
Good performance!
39. Gradle Haxe plugin!
Created by me:)
Compile Haxe with Gradle build system
Basic haxelib support
Multi-target aware
Source code:
https://github.com/bsideup/graxe