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

Target Specific APIs:

  • cpp:

    • cpp.Lib: Low level interactions with cpp target
    • cpp.net: Tools for interacting with networks and running servers
    • cpp.vm: Thread API, debugger, profiler etc.
    • cpp.zip: API for working with zip compression
  • cs: API for C# target

  • flash:

  • flash8:

    • flash8 Externs for Flash 8 API
  • java: API for Java target

  • js:

    • js.Browser: Shortcuts for common browser functions
    • js.Cookie: Helpers for interacting with HTTP cookies in the browser
    • js.JQuery: Extern class and helpers for jQuery
    • js.Lib: Shortcuts for alert(), eval() and debugger
    • js.html: Externs for interacting with the browser DOM
  • neko:

    • neko.Lib: Low level interactions with the neko platform
    • 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
    • neko.zip: API for working with zip compression
  • php:

    • php.Lib: Low level interactions with PHP platform
    • php.Session: Work with native PHP sessions
    • php.Web: Work with HTTP requests and responses
    • php.db.PDO: Additional PDO driver for database interactions