Misplaced Pages

Haxe

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

Haxe is a high-level cross-platform programming language and compiler that can produce applications and source code for many different computing platforms from one code-base. It is free and open-source software , released under an MIT License . The compiler, written in OCaml , is released under the GNU General Public License (GPL) version 2.

#139860

34-526: Haxe includes a set of features and a standard library supported across all platforms , including numeric data types , strings , arrays , maps , binary , reflective programming , maths, Hypertext Transfer Protocol ( HTTP ), file system and common file formats . Haxe also includes platform-specific application programming interfaces ( APIs ) for each compiler target. Kha , OpenFL , and Heaps.io are popular Haxe frameworks that enable creating multi-platform content from one codebase. Haxe originated with

68-459: A PC and expect it to run on Java-enabled mobile phones , as well as on routers and mainframes equipped with Java, without any adjustments. This was intended to save software developers the effort of writing a different version of their software for each platform or operating system they intend to deploy on. This idea originated no later than the 1960s, with the IBM M44/44X , and in

102-424: A programming language . Often, a standard library is specified by its associated programming language specification , however, some are set in part or whole by more informal practices of a language community. Some languages define a core part of the standard library that must be made available in all implementations while allowing other parts to be implemented optionally. As defined with the core language aspects,

136-585: A type system which is both strong and dynamic . The compiler will check types implicitly via type inference and give compile-time errors, but it also enables programs to bypass type-checking and rely on a target platform's dynamic type-handling. All of the native target APIs can be used. Haxe has a sophisticated and flexible type system. The type kinds it offers are classes , interfaces, function-method types, anonymous types, algebraic data types (called enum in Haxe), and abstract types. Parametric polymorphism

170-476: A joke among Java developers: Write Once, Debug Everywhere . In comparison, the Squeak Smalltalk programming language and environment boasts of being truly write once run anywhere, because it runs bit-identical images across its wide portability base. Like Squeak, MicroEJ provides a virtual execution environment that guarantees one unique Java thread policy across all implementations, ensuring

204-486: A much more inclusive vision of the standard library. Python attempts to offer an easy-to-code, object-oriented, high-level language. In the Python tutorial, he writes: Python has a "batteries included" philosophy. This is best seen through the sophisticated and robust capabilities of its larger packages. Van Rossum goes on to list libraries for processing XML , XML-RPC , email messages , and localization, facilities that

238-428: A type-safe manner, like C++ header files can describe the structure of existing object files . This enables to use the values defined in the files as if they were statically typed Haxe entities. Beside externs, other solutions exist to access each platform's native capabilities. Many popular IDEs and source code editors have support available for Haxe development. No particular development environment or tool set

272-623: Is an optimizing compiler , and uses field and function inlining , tail recursion elimination , constant folding , loop unrolling and dead code elimination (DCE) to optimize the run-time performance of compiled programs. The Haxe compiler offers opt-in null-safety , it checks compile-time for nullable values. In Haxe, supported platforms are known as "targets", which consist of the following modules: The following table documents platform and language support in Haxe. The Haxe language allows developers to gain access to many platform features, but Haxe

306-469: Is an example of the identity function . Enumerated types are an important feature of the language; they can have type parameters and be recursive. They provide basic support for algebraic data types , allowing the inclusion of product types , in a fashion similar to Haskell and ML . A switch expression can apply pattern matching to an enum value, allowing for elegant solutions to complex programming problems: Examples of parametric enum types are

340-477: Is denoted by using arrows between argument types, and between the argument type(s) and return type, as common in many functional languages. However, unlike in prominent examples like Haskell or the ML language family, not all functions are unary functions (functions with one argument only), and in Haxe, functions can't be partially applied per default. Thus, the following type signatures have different semantics than in

374-474: Is not a full featured engine, they might need frameworks that enable create content for certain platforms. Haxe is a general-purpose programming language supporting object-oriented programming , generic programming , and various functional programming constructs. Features such as iterations , exceptions , and reflective programming (code reflection) are also built-in functions of the language and libraries. Unusual among programming languages, Haxe contains

SECTION 10

#1732791970140

408-683: Is officially recommended by the Haxe Foundation, although VS Code , IntelliJ IDEA and HaxeDevelop have the most support for Haxe development. The core functionalities of syntax highlighting , code completion , refactoring , debugging , etc. are available to various degrees. Development of Haxe began in October 2005. The first alpha version was released on November 14, 2005. Haxe 1.0 was released in April 2006, with support for Adobe Flash , JavaScript , and NekoVM programs. Support for PHP

442-411: Is possible with classes, algebraic types and function types, giving the language support for generic programming based on type erasure. This includes support for variance in polymorphic functions , although not in type constructors . The type system is static unless annotations for dynamic typing are present, for use with targets that support them. Type checking follows nominal typing with

476-544: Is released under the GNU General Public License version 2 or later. The Haxe language can compile into bytecode that can be executed directly by the virtual machines it targets. It can compile to source code in C++ , JavaScript , PHP , C# , Java , Python , and Lua . Haxe also has an interpreter called eval . This same interpreter is also used compile-time to run macros, which allow modification of

510-432: The abstract syntax tree (AST). This strategy of compiling to multiple source code languages is inspired by the write once, run anywhere paradigm. It also allows the programmer to choose the best platform for the job. Typical Haxe programs run identically on all platforms, but developers can specify platform-specific code and use conditional compilation to prevent it from compiling on other platforms. The Haxe compiler

544-561: The C++ standard library omits. This other philosophy is often found in scripting languages (as in Python or Ruby ) or languages that use a virtual machine , such as Java or the .NET Framework languages. In C++, such facilities are not part of the standard library, but instead are included in other libraries, such as Boost . Write once, run anywhere Write once, run anywhere ( WORA ), or sometimes Write once, run everywhere ( WORE ),

578-464: The Haxe standard library types Option and Either: Haxe also supports generalized algebraic data types (GADTs). Anonymous types are defined by denoting their structure explicitly, using a syntax that follows the mathematical record-based representation of a type. They can be used to implement structural typing for function arguments (see below), and can be given an alias with the keyword typedef : Functions are first-class values in Haxe. Their type

612-545: The accessors public and private , and more advanced methods for access control that are denoted using annotations. Methods and static constant variables can be inlined using the keyword inline . Fields can be marked as final to declare a constant that must be initialized immediately or in the constructor and cannot be written to, in case of function final will mark as non-overridable in subclasses. Interfaces in Haxe are very similar to those in, for example, Java. Haxe supports generic programming . The following

646-407: The aforementioned languages. The type F1 is a function that takes a String as arguments and returns a value of type Float . Types F1 and F2 denote the same type, except that F2 uses labelled parameter, which is useful for completion and documentation. Types F4 and F5 denote the same type. Both are binary functions that return a binary function of type F3 . For F5

680-408: The exception of anonymous types where structural typing is used instead. Finally, type inference is supported, allowing for variable declarations without type annotations . All Haxe code is organized in modules, which are addressed using paths. In essence, each .hx file represents a module which may contain several types. For example, to create the type A in the package my.pack as shown,

714-717: The folder structure should be my\pack and the file could be A.hx in the folder pack . In other modules, other types can be imported by putting import statements below the package definition, e.g. import my.pack.A; A module can contain multiple types, such as the following. It is possible to import one type at a time from that module, using import my.pack2.A; . A type may be private , in which case only its containing module can access it. Classes (keyword class ) in Haxe are similar to those in Java or TypeScript. Their fields can be either methods, variables, or properties, each static or per instance respectively. Haxe supports

SECTION 20

#1732791970140

748-517: The idea of supporting client-side and server-side programming in one language, and simplifying the communication logic between them. Code written in Haxe can be compiled into JavaScript , C++ , Java , JVM , PHP , C# , Python , Lua and Node.js . Haxe can also directly compile SWF , HashLink, and NekoVM bytecode and also runs in interpreted mode. Haxe supports externs (definition files) that can contain data type information of extant libraries to describe target-specific interaction in

782-455: The implicit interfaces of the language Go as to typing. In contrast with Go interfaces, it is possible to construct a value using an anonymous type. The Haxe compiler is divided into one frontend and multiple backends. The frontend creates an abstract syntax tree (AST) from the source code, and performs type checking, macro expansion , and optimization on the AST. The various backends translate

816-520: The java.lang.String class. Smalltalk defines an anonymous function expression (a "block") as an instance of its library's BlockContext class. Scheme does not specify which portions must be implemented as core language vs. standard library. Depending on the constructs available in the core language, a standard library may include: Commonly provided functionality includes: Philosophies of standard library design vary widely. For example, Bjarne Stroustrup , designer of C++ , writes: What ought to be in

850-688: The late 1970s the UCSD Pascal system was developed to produce and interpret p-code . UCSD Pascal (along with the Smalltalk virtual machine) was a key influence on the design of the JVM, as is cited by James Gosling . The catch is that since there are multiple JVM implementations, on top of a wide variety of different operating systems, there could be subtle differences in how a program executes on each JVM/OS combination, possibly requiring an application to be tested on each target platform. This gave rise to

884-440: The latter. A standard library is something every implementer must supply so that every programmer can rely on it. This suggests a relatively small standard library, containing only the constructs that "every programmer" might reasonably require when building a large collection of software. This is the philosophy that is used in the C and C++ standard libraries. By contrast, Guido van Rossum , designer of Python , has embraced

918-426: The line between the core language and its standard library is relatively subtle. A programmer may confuse the two aspects even though the language designers intentionally separate the two. The line between the core language and its standard library is further blurred in some languages by defining core language constructs in terms of its standard library. For example, Java defines a string literal as an instance of

952-466: The processed AST into source code or generate bytecode , depending on their target. The compiler is written in OCaml . It can be run in server-mode to provide code completion for integrated development environments (IDEs) and maintain a cache, to further speed compiling. Standard library In computer programming , a standard library is the library made available across implementations of

986-524: The right thing. Abstract types are entirely a compile-time feature of Haxe and do not exist at all at program runtime. As an example, both variables using abstract types above Mile and Kilometer will be of the type Float at runtime. In many functional programming languages, structural typing plays a major role. Haxe employs it in the presence of anonymous types, using the nominative typing of object-oriented programming , when only named types are involved. Anonymous types in Haxe are analogous to

1020-408: The risk of mixing up values of the same underlying type, but with different meanings (e.g., miles vs. km). The following example assumes that the metric system is the default, while a conversion to miles is needed for legacy data. Haxe can automatically convert miles to kilometers, but not the reverse. As the example shows, no explicit conversion is needed for the assignment "km = one100Miles;" to do

1054-404: The standard C++ library? One ideal is for a programmer to be able to find every interesting, significant, and reasonably general class, function, template, etc., in a library. However, the question here is not, "What ought to be in some library?" but "What ought to be in the standard library?" The answer "Everything!" is a reasonable first approximation to an answer to the former question but not

Haxe - Misplaced Pages Continue

1088-544: The syntax to declare a function type within a function type is used. In Haxe, anonymous functions are called lambda, and use the syntax function(argument-list) expression; . A relatively new addition to the Haxe type system is a concept termed abstract types . As used in Haxe, this refers to something different from a conventional abstract type . They are used to make conversions between types implicit, allowing reuse of existing types for specific purposes, like implementing types for units of measurement. This greatly reduces

1122-521: Was a 1995 slogan created by Sun Microsystems to illustrate the cross-platform benefits of the Java language . Ideally, this meant that a Java program could be developed on any device, compiled into standard bytecode , and be expected to run on any device equipped with a Java virtual machine (JVM). The installation of a JVM or Java interpreter on chips, devices, or software packages became an industry standard practice. A programmer could develop code on

1156-472: Was added in 2008, and C++ was added in 2009. More platforms such as C# and Java were added with a compiler overhaul in 2012. Haxe was developed by Nicolas Cannasse and other contributors, and was originally named haXe because it was short, simple, and "has an X inside", which the author asserts humorously is needed to make any new technology a success. Haxe is the successor to the open-source ActionScript 2 compiler MTASC , also built by Nicolas Cannasse and

#139860