Release of the programming language Haxe 4.0

Available toolkit release Hax 4.0, which includes the eponymous multi-paradigm high-level programming language with strong typing, a cross-compiler and a standard library of functions. The project supports translation to C++, HashLink/C, JavaScript, C#, Java, PHP, Python, and Lua, as well as compilation to JVM, HashLink/JIT, Flash, and Neko bytecode, with access to the native capabilities of each target platform. Compiler Code spreads under the GPLv2 license, but the standard library and the virtual machine developed for Haxe Neko under the MIT license.

Language is expression-oriented strongly typed. Object-oriented, generic, and functional programming approaches are supported.
Haxe syntax is close to ECMAScript and extends the its features such as static typing, type inference, pattern matching, generics, iterator-based "for" loop, AST macros, GADT (Generalized Algebraic Data Types), abstract types, anonymous structures, simplified array definitions, expressions for conditional compilation , attaching metadata to fields, classes and expressions, string interpolation ('My name is $name'), type parameters ("new Mainβ€ΉStringβ€Ί('foo')"), and more.

class Test {
static function main() {
var people = [
"Elizabeth" => "Programming",
"Joel" => "Design"
];

for (name in people.keys()) {
var job = people[name];
trace('$name does $job for a living!');
}
}
}

All innovations version 4.0:

  • New syntax for specifying the function type "(name:String, age:Int)->Bool" or "(String, Int)->Bool" instead of "String->Int->Bool".
  • Arrow function syntax is "(a, b) -> a + b" instead of "function(a, b) return a + b".
  • Protection against problems associated with the use of Null values ​​(experimental feature, optionally enabled for certain fields, classes or packages).
  • The "final" keyword for class fields and local variables that are immutable. "final" can also be used to define functions to prevent them from being overridden when inherited, and for classes/interfaces that cannot be inherited.
  • Support the Unicode standard for the base type "String" on all compilation targets except Neko.
  • A built-in interpreter rewritten from scratch, now shipped under the name Evaluate. Thanks to the new interpreter, scripts and macros run much faster. Supports interactive debugging mode.
  • New target system for compilation (target) hashlink is a high-performance runtime designed specifically for Haxe, supporting compilation to JIT or C bytecode, easy integration with C, and access to low-level numeric types and pointers.
  • New JVM target system - allows you to generate jvm bytecode by skipping the Java code compilation step by adding the "-D jvm" flag when targeting in Java.
  • The ability to inline-expand at the site of a function or constructor call, even if they are not declared as such.
  • Possibility of inclusion static extensions when declaring a type (e.g. "enum") with "@:using(path.ToExtension)".
  • Abstract types now support a "set" version of the "@:op(ab)" operator to reload "obj.foo = bar" expressions.
  • The "for" loop syntax now supports key-value iteration: "for (key => value in collection) {}".
  • Support for using xml-like markup in expressions: "var a = β€Ήhi/β€Ί;". So far, this feature is only available for parsing with macros and is at the design stage.
  • The syntax for optional fields in the "full" notation of anonymous structure types is: "{ var ?f:Int; }" (an alternative to the "short" "{ ?f:Int }").
  • Enum values ​​can now be default values ​​for function arguments: "function fooβ€ΉTβ€Ί(option:Optionβ€ΉTβ€Ί = None)".
  • The "enum abstract Name(BasicType) {}" syntax no longer requires the "@:" prefix in "enum".
  • Auto-numbering for abstract enums:

    enum abstract Foo(Int) {
    varA; // 0
    varB; // 1
    }
    enum abstract Bar(String) {
    varA; // "A"
    varB; // "B"
    }

  • The "extern" keyword no longer requires the use of the "@:" prefix.
  • Removed option "implements Dynamic" to access class fields via strings. Available to extern classes or through implementation by an abstract type.
  • Added "A & B" syntax for type intersection, which currently only applies to anonymous structures and type parameter constraints. The old constraint syntax has been removed.
  • Creating empty instances of "Map" is available through the syntax "var map:Mapβ€ΉInt, Stringβ€Ί = [];" similar to an array.
  • Added "haxe.ds.ReadOnlyArray" data structure.
  • Metadata can now have namespaces ("@:prefix.name function() {...}"). Similarly with definitions: "#if (some.flag ... #end".
  • New service protocol for IDEs used in plugin for VSCode.
  • Updated external definitions (extern) for Web APIs and added missing ones.

Source: opennet.ru

Add a comment