Static Type and Garbage Collection

Cangjie is a statically typed language. The types of all variables and expressions in a program are determined during compilation and do not change during program running. Compared with dynamic type systems, static type systems have more constraints on developers, but they can detect errors in programs as early as possible during compilation, improving program security. In addition, static type systems make behaviors of programs easier to predict, enabling more compilation optimization and improving program performance.

Garbage collection (GC) is an automatic memory management mechanism. It can automatically identify and reclaim objects that are no longer needed, freeing developers from manually releasing memory. This not only improves development efficiency, but also effectively avoids common memory errors, improving program security. Common garbage collection technologies include tracing and reference counting (RC). The Cangjie language uses tracing GC technology to trace reference relationships between objects during run-time to identify active objects and junk objects.