HaXe, un language universel orienté web

TwitterFacebook
Get flash to fully experience Pearltrees
Cet article a pour but de vous présenter le langage de programmation HAXE . Quel est donc ce nouveau langage ? Quel sont ses fonctionnalités ?

Présentation du Langage HAXE | Delfiweb - Ressources Flash, Fram

http://www.delfiweb.com/langage-haxe/article12903.html
It seems that the Windows Installer is reported as infected by some antivirus software. This is a false report and you can safely run the program on your system: if it happens, please contact the antivirus' vendor so they can fix the issue as soon as possible. Due to some ACL issues with Windows Vista and Win7, haXe will install itself in C:/Motion-Twin/haxe on these systems.

haXe - Téléchargements

http://haxe.org/download
http://haxe.org/ref/basic

haXe - Types Basiques

The haXe syntax is Java/ActionScript/C++ like. A source code file is composed of an optional package name followed by several imports and type declarations. By convention, package names are composed of several identifiers each of which start with a lowercase letter and are separated from one another by periods ".
In Haxe , all expressions have the same level. It means that you can nest them together recursively without any problems, for example foo(if (x == 3) 5 else 8) is a valid Haxe expression. As this example shows, it also means that every expression returns a value of a given type . The following constant values can be used : 0 ; - 134 ; 0xFF00; 123.0 ; . 14179 ; 13e50; -1e- 99 ; "hello" ; "hello \"world\" !" http://haxe.org/ref/syntax

haXe - La Syntaxe

haXe - L'Inférence de type

http://haxe.org/ref/type_infer Type Inference means that the type information is not only checked in the program, it's also carried when typing, so it doesn't have to be resolved immediately. For example a local variable can be declared without any type (it will have the type Unknown ) and when first used, its type will be set to the corresponding one. Anywhere in your program, you can use the type operation to know the type of a given expression. At compilation, the type operation will be removed and only the expression will remain : Type Inference enables the whole program to be strictly typed without any need to put types everywhere. In particular, local variables do not need to be typed, their types will be inferred when they are first accessed for reading or writing :
Variables and methods can have the following flags : static : the field belongs to the Class itself and not to instances of this class. Static identifiers can be used directly in the class itself.

haXe - La Programmation Orientée Objet

http://haxe.org/ref/oop
http://haxe.org/ref/type_params Inside the Array class, the type T is abstract which means its fields and methods are not accessible. However when you declare an array you need to specify its type : Array or Array for example. This will act the same as if you had replaced all types T in the Array declaration by the type you're specifying. The type parameter is very useful in order to get strict typing of containers such as Array , List , and Tree .

haXe - Les Paramètres de type

haXe - Les énumérations

When you want to ensure that only a fixed number of values are used then enums are the best thing since they guarantee that other values cannot be constructed. This way, there is an infinite number of Color2 's possible, but there are five different constructors possible for it. The following values are all Color2 : A switch has a special behavior when used on an enum . If there is no default case then it will check that all an enum's constructors are used within the switch, and if not the compiler will generate a warning. http://haxe.org/ref/enums
http://haxe.org/ref/packages

haXe - Les Paquets et Importations

Each file can contain several classes , enums and imports . They are all part of the package declared at the beginning of the file. If package is not declared then the default empty package is used. Each type has then a path corresponding to the package name followed by the type name. package my . pack; enum E { } class C { } This file declares two types : my.pack.E and my.pack.C .
Disclaimer: Dynamic variables are often necessary to ensure interoperability with third party or platform dependent libraries, or for very specific cases where dynamic variables are absolutely required. Their use is not encouraged for normal use, as their behavior differs between targets. When you want to get some dynamically typed behavior and break free from the type system, you can use the Dynamic type which can be used in place of any type without any compile-time type-checking: http://haxe.org/ref/dynamic

haXe - Le type Dynamic

haXe - Les Types avancés

An structure type is the type of an anonymously declared object. It is also the type of a Class identifier (corresponding to all the static fields) or an Enum identifier (listing all the constructors). Here's an example that shows it: You can define type definitions which are a kind of type shortcut that can be used to give a name to an structure type or a long type that you don't want to repeat everywhere in your program :
You can use the for syntax in order to execute iterators. The simplest iterator is the IntIter iterator which can easily be built using the operator ... (three dots). For example this will list all numbers from 0 to 9 : You don't need to declare the variable i before using a for, since it will be automatically declared.

haXe - Les Itérateurs

Properties are a specific way to declare class fields, and can be used to implement several kinds of features such as read-only/write-only fields or fields accessed through getter-setter methods. For instance, the following two functions are equivalent, although the methods getX and setX are private and then can't be accessed directly as in f2 : var c : C; function f1 ( ) { c . x *= 2 ; } function f2 ( ) { c . setX ( c . getX ( ) * 2 ) ; } Getter and setter methods only work if the type of the class is known. There is no runtime properties handling , so for instance the following code will always trace null since the method getX will never be called : Similarly, read-only and write-only properties will be both readable and writable using a dynamic variable since the type of the class is unknown.

haXe - Les Propriétés

haXe - Les Arguments optionnels

When not specified, an optional parameter will have the default value null . It's also possible to define another default value, by using the following syntax : Although it is advised to put optional parameters at the end of the function parameters, you can use them in the beginning or in the middle also.

haXe - Compilation conditionelle

Sometimes you might want to have a single library using specific API depending on the platform it is compiled on. At some other time, you might want to do some optimizations only if you turn a flag ON. For all that, you can use conditional compilation macros (AKA preprocessor macros):
DOM, XML, JSON