Cangjie Programming Language Library API

The Cangjie programming language library provides the std module (standard library module) and some common extension modules. Each module contains several packages that provide specific and rich functions related to the module.

The standard library provides developers with the most common APIs, including input and output functions, basic data structures and algorithms, and date and time representation. The extension library focuses on a specific field. For example, the compress module provides compression and decompression capabilities, the crypto module provides encryption and decryption capabilities, and the net module provides efficient network protocol parsing and network communication capabilities.

Both the standard library and the official extension library comply with the Cangjie programming specifications as well as official standards in terms of function, performance, and security.

Note:

  • The standard library and official extension library are released with the Cangjie compiler and toolchain and do not need to be downloaded separately.
  • According to the subsequent evolution plan, the extension library may be separated from the Cangjie compiler and tool chain release and placed in a dedicated repository for management.

Usage Description

In the Cangjie programming language, a package is the minimum unit for compilation. Each package can output products such as AST files, static library files, and dynamic library files. A package can define subpackages to form a tree structure. A package without a parent package is called a root package. The entire tree consisting of the root package and its subpackages (including the subpackages of the subpackages) is called a module. The name of a module is the same as that of the root package. A module is the minimum unit released by a third-party developer.

The rules for importing packages are as follows:

  • A top-level declaration or definition in a package can be imported. The syntax is as follows:

    import fullPackageName.itemName
    

    fullPackageName indicates the full path package name, and itemName indicates the declaration name. For example:

    import std.collection.ArrayList
    
  • If more than one itemName to be imported belong to the same fullPackageName, run the following command:

    import fullPackageName.{itemName[, itemName]*}
    

    For example:

    import std.collection.{ArrayList, HashMap}
    
  • All public-qualified top-level declarations or definitions in the fullPackageName package can also be imported. The syntax is as follows:

    import fullPackageName.*
    

    For example:

    import std.collection.*
    

Module List

Currently, the Cangjie standard library provides the following modules:

NameDescription
stdRefers to a standard library. A standard library refers to a group of functions, classes, and structs predefined in a programming language and aims to provide common functions and tools for developers to compile programs more quickly and efficiently.
compressProvides the compression and decompression functions.
cryptoProvides the security encryption capability.
encodingProvides the character encoding and decoding capabilities.
fuzzProvides the fuzzing capability based on coverage feedback.
logProvides log recording capabilities.
netProvides capabilities related to network communication.
serializationProvides the serialization and deserialization capabilities.