Release of the programming language Haxe 4.2

A release of the Haxe 4.2 toolkit is available, 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. The compiler code is distributed under the GPLv2 license, and the standard library and the HashLink and Neko virtual machines developed for Haxe are licensed under the MIT license.

The language is expression-oriented with strong typing. Object-oriented, generic and functional programming techniques are supported. Haxe syntax is close to ECMAScript and extends it with 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 definitions arrays, expressions for conditional compilation, attaching metadata to fields, classes and expressions, string interpolation ('My name is $name'), type parameters ('new Main ("foo")') and many more. class Test { static function main() { final people = [ "Elizabeth" => "Programming", "Joel" => "Design" ]; for (name => job in people) { trace('$name does $job for a living!'); } } }

New features in version 4.2:

  • Declaring static variables and functions at the module level, without the need to wrap it in a class.
  • Support for "classic" abstract classes and functions.
  • Native implementation of variant functions for all target platforms (haxe.Rest) and addition of the "f(...array)" argument expansion operator.
  • Implementing an event loop for individual threads ("sys.thread.Thread.events").
  • "@:inheritDoc" metadata for type/field documentation inheritance.
  • Method overloading support for external methods on all target platforms.
  • Forwarding to the abstract of the constructor underlying its type using the "@:forward.new" metadata.
  • The "EIs" constructor has been added to "haxe.macro.Expr".
  • Ability to make an abstract type variant with "@:forward.variance".
  • Representation of type "Any" as "Dynamic" when unifying variance.
  • Some basic exception types have been added to the "haxe.exceptions" package.
  • Support for attaching metadata when declaring variables.
  • The "StringTools.unsafeCharAt" function used in string iteration.
  • eval (interpreter): Added bindings to libuv in package "eval.luv".
  • eval: Bindings to native "Int64" and "UInt64" implementations via the "eval.integers" package.
  • cs: UDP socket implementation.
  • cs: "cs.Syntax" module for inline inserts of C# code.
  • jvm: Added "-D jvm.dynamic-level=x" flag to control how many optimizations are generated for dynamic code. 0 = none, 1 = field read/write optimization, 2 = compile-time method closures.
  • java, jvm: Support for "-java-lib <directory>" flag.
  • python: implementation of the threading API.

General improvements:

  • "expr is SomeType" does not require parentheses.
  • Increased precedence for "@:using" type extensions.
  • The use of static type extensions via "super" is allowed.
  • Ability to set metadata for "@:noDoc" fields.
  • The abstract type "Map" is made transitive.
  • Support for "@:native" on enum constructors.
  • Support for "@:using" on type declarations ("typedefs").
  • Multi-line errors use "..." as a prefix for subsequent lines.
  • Reworked type inference, anonymous structures are better converted to explicit types and "closed" at the end of the function.
  • Displaying the type of functions without arguments as "()->…" instead of "Void->…".
  • The "function" keyword is allowed as a package name.
  • Improved inlining of objects.
  • cs: Added support for .NET 5.0.
  • cpp: Support for native constructors in external classes.
  • php: Added "php.Syntax.customArrayDecl" for native array declaration.
  • php: Updated external methods (externs) for various functions and classes.
  • php: Implementation of anonymous structures has been optimized.
  • hl: Skip compilation if there are no changes to modules.
  • lua: Using "hx-lua-simdjson" to parse json.
  • jvm: Reduced CPU usage in "sys.thread.Lock" implementation.
  • js: Improved compatibility with Google Closure Compiler.
  • Null Safety: Consider "@:nullSafety(Off)" when declaring variables: "var @:nullSafety(Off) v".

Also, the addition to the VSCode editor has been updated to the new version of the compiler, in which tips have appeared with the generation of missing fields of interfaces, simple and abstract classes, as well as property methods.

Source: opennet.ru

Add a comment