Introduction to the Haxe Standard Library

The Haxe Standard Library provides common purpose tools without trying to be an exhaustive collection of data structures and algorithms. A Haxe distribution comes with a std directory containing the Haxe Standard Library. Its contents can be categorized like so:

  • General purpose: The std directory itself contains a few top-level classes such as Array, Map or String which can be used on all targets. The haxe sub-directory provides additional data structures, input/output APIs and many more tools.

  • System: The sys sub-directory contains APIs related to file systems and database. Additionally, the Sys top-level class allows various interaction with the operating system. They can only be accessed when compiling to a target of the sys-category (C++, C#, Java, Neko, PHP).

  • Target specific: Each Haxe target has a distinct sub-directory containing target-specific APIs. These can only be accessed when compiling to the given target.

General purpose API:

Available on all targets.

Top-level:

  • Array: Typed collection which defines several ECMA-compliant operations
  • Date, DateTools: Operations related to dates and timestamps
  • EReg: Regular Expressions
  • Lambda: Operations over iterables
  • Map: Key-to-value mapping data structure
  • Math: ECMA-compliant mathematical functions
  • Reflect: Field-related reflection
  • Std: Runtime type-checking; numerical parsing; conversion to Int and String
  • String: Basic operations on String
  • StringBuf: Optimized for building Strings
  • StringTools: Various extensions to String
  • Type: Type-related reflection
  • Xml: Cross-platform XML

The haxe package:

The haxe.ds package:

The haxe.io package:

System API:

Available on C++, C#, Java, Neko and PHP.

  • Sys: Execute native commands; interact with stdin, stdout and stderr; various other native operations
  • sys.FileSystem: Read and modify directories; obtain information on files and directories
  • sys.db: APIs for working with MySQL and SQLite databases
  • sys.io.File: Read and write file content; copy files
  • sys.io.Process: Use native processes
  • sys.thread: API for multi-threaded applications.

Target Specific APIs:

  • cpp:

    • cpp.Lib: Provides platform-specific functions for the C++ target.
    • cpp.vm: Thread API, debugger, profiler etc.
  • js:

    • js.Lib: Provides some platform-specific functions for the JavaScript target.
    • js.Browser: Shortcuts for common browser functions.
    • js.html: Externs for interacting with the native JavaScript API's / DOM.
    • js.Syntax: Helper for low-level JavaScript specific code generation.
  • php:

    • php.Lib: Provides platform-specific functions for the PHP target.
    • php.Syntax: Helper for low-level PHP specific code generation.
    • php.Session: Work with native PHP sessions
    • php.Web: Work with HTTP requests and responses
    • php.db.PDO: Additional PDO driver for database interactions
  • cs: API for C# target

    • cs.Lib: Provides platform-specific functions for the C# target.
    • cs.system: Externs for interacting with native C# classes.
  • java: API for Java target

    • java.Lib Provides platform-specific functions for the Java target.
    • java.* Externs for interacting with native Java classes.
  • python:

    • python.Lib: Provides platform-specific functions for the Python target.
    • python.Syntax: Helper for low-level Python specific code generation.
    • python.Syntax: Externs for interacting with native Python classes.
  • flash:

  • neko:

    • neko.Lib: Low level interactions with the Neko VM target.
    • neko.Web: Work with HTTP requests and responses.
    • neko.net: Tools for interacting with networks and running servers.
    • neko.vm: API for multi-threaded applications.
  • hl: Low level interactions with the HashLink target

  • lua: Low level interactions with the lua target