Lightweight Runtime
The Cangjie language provides the ultra-lightweight runtime function, which not only features low distribution overhead, but also achieves application deployment and running at extremely low overheads.
Through software engineering optimization, redundant code in the Cangjie runtime library is deleted, dependency on the C++ runtime library is removed, and definitions of externally invisible symbols are reduced. As a result, the binary size of the Cangjie runtime library is as small as 1 MB. The size of the runtime library with customized optimization for embedded systems completed can be as small as about 500 KB.
The Cangjie lightweight runtime function allows user-level threads to be created, run, and scheduled at extremely low overheads. It takes only hundreds of nanoseconds to create a user-level thread. User code costs only several kilo bytes of stack memory during execution, and a single scheduling takes only hundreds of nanoseconds.
The Cangjie lightweight runtime function achieves calls between the Cangjie language and the C language at nearly zero cost. In terms of underlying implementation, the ABI definition of the Cangjie language is highly compatible with that of the C language. Types compatible with the C language (that is, types modified by the "@C" keyword) in the Cangjie language have the same memory layout as the C language. In typical scenarios, data can be shared between the Cangjie language and the C language without conversion.
The Cangjie lightweight runtime function provides flexible application tailoring technologies to help developers optimize the application package size. The reflection mechanism of the Cangjie language can be enabled on demand, and can be disabled when it is not required. For private methods in the Cangjie package, redundant code can be cleared through on-demand links at the function granularity.
The Cangjie lightweight runtime function helps reduce the deployment and startup overhead of Cangjie applications to an extremely low level. The application startup duration is at the 10 ms level. Memory of applications carrying no service load is at the 1 MB level. In embedded scenarios, memory when no service load is carried is less than 1 MB.