ROME 24-25 MARCH 2017
haxe language
my ten favorite
features
francis bourre
haxe
❤ story ?
why we chose haxe?
● Cross compiler for 10 targets (C++, JS, PHP, Java, Python, Lua…)
why we chose haxe?
● cross compiler for 10 targets (C++, JS, PHP, Java, Python, Lua…)
● free and open source toolkit
why we chose haxe?
● cross compiler for 10 targets (C++, JS, PHP, Java, Python, Lua…)
● free and open source toolkit
● statically typed programming language
And we discovered it was a
● cross compiler for 10 targets (C++, JS, PHP, Java, Python, Lua…)
● free and open source toolkit
● statically typed programming language
language features
So, what should I expect from a
GOOD programming language?
language features
● Great syntax/semantics
● Code readable and easily maintainable
● Compile time optimizations
● … And fun/intuitive to use :)
But, let’s start with...
Let’s start with
hello world
http://try.haxe.org/#8737E
conditional compiling
works in pair with compiler arguments
conditional compiling
works in pair with compiler arguments
inlining
Allows code blocks
to be directly inserted
instead of calling them
inlining
dry
http://try.haxe.org/#30082
inlining
constructor inlining
http://try.haxe.org/#B150C
● unused variables
● unreachable code
● and more...
http://try.haxe.org/#05485
dce and static analyser
code optimization
dce and static analyser
dce and static analyser
code optimization
type inference
strict typing without verbosity
automatic deduction of the data type
of an expression
type inference
type inference
http://try.haxe.org/#42127
type inference
how does it work?
type inference
works with composite types
static extension
augmenting types
static extension
augmenting types
static extension
augmenting types
array comprehension
initialize arrays with ease
abstract
modify/augment concrete type behaviors
abstract
example
abstract
Operators overloading
abstract
implicit casting
abstract
implicit casting
http://try.haxe.org/#859e3
metadata
@nnotations at runtime and compile-time
metadata
annotations @runtime and @compile-time
● class declaration
● any class field
● enum declaration and constructors
metadata
allowed values
● constants
● array declarations
● object declarations
metadata
example on class fields
metadata
example on method arguments
metadata
constant identifier
pattern matching
pattern matching
switch expression
Process of branching depending
on a value matching
pattern matching
match against values
pattern matching
match against fields
pattern matching
| operator
pattern matching
with guards
pattern matching
with extractors
Allows to check if transformations
match values
pattern matching
with extractors
pattern matching
with extractors
macros
macros
black magic @compile-time
macros
black magic @compile-time
● Initialization macro
macros
black magic @compile-time
● Initialization macro
● Build macro
macros
black magic @compile-time
● Initialization macro
● Build macro
● Expression macro
macros
expression example
macros
build example
macros
simple build example
macros
annotation/reflection parser example
hexMachina reflection builder
real macro use case
DSL compilation
DSL PARSING/ASSEMBLING FLOW
Xml Parser
parses
DSL PARSING/ASSEMBLING FLOW
Xml Parser Assembler
parses translates
DSL PARSING/ASSEMBLING FLOW
Xml Parser Assembler
Context
Factory
parses translates
Runtime @pplication
builds
DSL PARSING/COMPILING FLOW
Xml Parser Assembler
CompileTime
Factory
parses translates
Generated Code
generates
After compilation
JavaScript is generated
DSL CHECKING @compile time
type not found
and to conclude...
best feature ever
guess what
best feature ever
❤
haxe community
● haxelang - google group
● twitter - #haxe
● stack overflow
● HaxeFoundation - github
● haxe.io
questions ?

My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017