HAXE
One codebase to rule ‘em all
GETTING AQUAINTED
• Created by Nicolas Cannasse (who also created the MTASC-compiler) in 2005
• First Beta released on 2006/02/04=> only Neko and SWF8 targets available
• 2006/05/01: version 1.0 released=> JavaScript target added
• Today: version 2.08=> Neko, SWF8, SWF9, JS, C++, PHP targets available=> C# and Java targets under heavy development
• Open Source• Very active and bright community• Mature and fast compiler
LANGUAGE FEATURES
• Multi-platform: write haXe source code and deploy to=> mobile (Windows Phone, iOS, Android, webOS all using native code)=> desktop (native code, AIR)=> server (NekoVM, PHP, NodeJS)=> web (Flash 6-11/HTML-Canvas-WebGL/JavaScript/PHP)=> command line (C++, Neko)
• Elegant remoting across all platforms: compiling the same remoting classes source code to different targets allows for successful and fast deserialization between different platforms
• Syntax based on ECMAScript: easy switching for AS/JS developers, easy to learn for new developers or developers coming from other platforms
• Strictly typed: compile-time checking across all targets, even for non-compiled languages like JS and PHP
• Very fast compiler, blazing-fast serialization.
LANGUAGE FEATURES
• Macro’s allow you to write code that executes against your application at compile-time. This allows for advanced code generation/customisation/optimization.
• Use conditional compilation to handle different platforms
• Type inference allows for less and more beautiful code
• Function and constants inlining makes fast code faster
• Enrich types and fields with metadata=> accessible at runtime through the haxe.rtti.Meta API=> or to be used by the compiler internals at compile-time
• Fantastic Reflection API: using Reflect and Type allows for painless runtime type-checking and variable instantiation
• Standard libraries work across all client and server targets (Math, Xml, Date, Http, …)
LANGUAGE FEATURES
• Rich Type system=> Void, Null, Dynamic, untyped (bypass type-checking)=> Array, List, Hash with native iterators=> Generics (with optional constraints), Typedefs, Enums
• Function type inference
• Dynamic functions: execute function logic on different data types using the Dynamic type for parameters and return type
• Local functions: functions that exist as the value of a variable=> e.g.: var functionVariable : ParamOne [[- > ParamTwo] ...]- > ReturnValue;
• Advanced cross-platform debugging with CallStack and ExceptionStack
• Cross-platform logging and tracing
LANGUAGE FEATURES
• SPOD Macro’s: Simple Persistent Objects Database Library=> similar to an ultra-lightweight version of Hibernate=> write haXe expressions instead of SQL=> benefit from type-safety=> supports metadata
• Duck typing using type inference and anonymous types
• Access full target platform API’s
• Interface with existing platform libraries using Extern classes or use haxelib
• Generated code is 100% compatible with existing target platform native code
• Excellent runtime performance on all target platforms
THAT’S COOL!
IT COMPENSATES A LITTLE FOR EVERYDAY REALITY FOR MOST OF US…
SO, IS IT ALL GREAT?
Actually: YES!
BUT:
• Writing cross-platform code is not always easy
• It takes some practice and experience to use it right
• A solid IDE is only available for Windows (FlashDevelop). IDE’s for Mac and Linux exist, but they are not nearly a match for FD.
• “PR” could be better: not always easy to find what you’re looking for on the website, most valuable info & help only available through the mailing list=> BUT, big improvement: community moved to Google Groups last week
• Unknown == often not loved: not always easy to convince your bosses/clients to move to a little-known platform
CROSS-PLATFORM TIPS
Abstract display hierarchy through composition
CROSS-PLATFORM TIPS
Encapsulate low-level drawing and styling
CROSS-PLATFORM TIPS
Separate domain and presentation layers
=> application logic is universal=> presentation logic can differ greatly between targets and devices
CROSS-PLATFORM TIPS
Implement a device-agnostic UI
=> the number of devices that applications can (and will!) run on increases very fast
CROSS-PLATFORM TIPS
CROSS-PLATFORM TIPS
CROSS-PLATFORM TIPS
CROSS-PLATFORM TIPS
Criticise yourself
• Just because you have the power to do a lot of things doesn’t mean you always should
• Make sense when writing your code and try to keep it maintainable
• With great power comes great responsability
CROSS-PLATFORM TIPS
Get started easily using NME
• NME stands for Neko Media Engine
• It’s an SDL-like wrapper for the haXe and Neko platform
• Abstract away low-level stuff, deal with the funky juice
DEMO TIME
RESOURCES
Books:
• Professional haXe and Neko (Wrox)• haXe 2 Beginner’s Guide (Packt Publishing)
Online:
• http://haxe.org (official haXe website)• http://groups.google.com/group/haxelang (new Google Group)• http://lists.motion-twin.com/mailman/listinfo/haxe (old mailing list)• http://www.haxenme.org (official haXe NME website)• http://www.joshuagranick.com/blog/
Twitter: @haxelang, @ncannasse, @fponticelli, @tarwin, @internetsurfing, @cwaneck, @brunofonzi, @gamehaxe, @polygonal, @leesylvester
MY CONTACT DATA
@sventunusfacebook.com/sventunushttp://be.linkedin.com/in/[email protected]@thesedays.com
THANK YOU
A BIG thank you also goes out to all my friends and fellow-haXe-coders on the mailinglist for inspiring me and allowing me to use/demo some of their stuff!
Top Related