envzn
0.8 · beta · not released

An Introduction to Envzn

What Envzn Is, and What It Isn't

Envzn (pronounced envision) is a modern, fast, and readable systems programming language. It uses an ahead-of-time compiler that produces native code and achieves memory safety without the overhead of a garbage collector. Designed to be intuitive for developers, Envzn is primarily targeted at data science, finance, and systems development.

Envzn includes the essential features expected in a modern programming language:

  • A dedicated package manager
  • A robust compiler with 670 error and warning codes
  • Integration with commonly used IDEs: VS Code, Vim, Emacs, CotEditor, plus a language server (LSP)
  • Object-oriented architecture
  • An extensive standard library
  • Support for generics/templates
  • Column-major arrays

Design Influences

The design of Envzn draws inspiration from many industry-standard languages. While it incorporates memory safety similar to Rust, it takes a different approach (discussed below). It also adopts generics like many languages, matrix handling like Fortran, data manipulation like Python, mathematical capabilities similar to Julia, an intermediate representation like Java, and aspires to the versatility of Go.

Core Philosophy

Envzn intentionally avoids common developer pain points, such as pre-processor commands (e.g. #pragma, #define), silent integer wrapping, and steep learning curves.

To eliminate the complexities associated with pointers, Envzn uses stack-based object handles and references. While object creation is explicit with CREATE(), deletion is handled automatically; a destructor runs as soon as a handle falls out of scope. Furthermore, explicit conversion operators are used in place of traditional type casting.

Why Build Another Language?

The concept for Envzn originated in 1995 when language author Brian Haughton met with the original Java team at Sun Microsystems. This meeting inspired the vision for a memory-safe language that operates without garbage collection while remaining readable, modern, world-class, fast, and intuitive.

These six principles became the core tenets of Envzn. After initial design work in 2001, followed by revisions in 2011 and 2018, the language was fully implemented in 2026. Envzn aims to relocate the cost of complexity inward, providing a better experience for both software engineers and end-users. For example, the compiler automatically detects the target platform and emits platform-specific adjustments, freeing the developer from manual configuration.

Terminology

This guide assumes familiarity with basic development concepts (such as libraries and JSON) as well as object-oriented principles. The following terms are specific to Envzn:

  • Module: A directory containing related code that compiles into a library or executable. All files in a module are compiled simultaneously to reduce build times.
  • EvIR (Envzn Intermediate Representation): The intermediate code generated by the compiler before native code is produced. It is saved as a modulename.evir file.
  • Handle: A stack-based variable for a class or object whose data resides on the heap. Handles can be owned, references, or mutable references.
  • Reference: A type of handle that points to an object without taking ownership.

Hello, World, One Line at a Time

MODULE hello                         // Define the module

// Double-slash for single-line comments
/* C-style for multi-line
   comments */
CLASS Main IMPLEMENTS TaskStarter {  // TaskStarter is a standard interface
    METHOD start() RETURNS STATUS {  // start() is where the program begins
        printline("hello world")     // Print to standard output
        RETURN (SUCCESS)             // Return success status
    }
}

Four Unique Features

  • Template Qualifiers: Mandatory, readable type constraints on generics that support multiple types with specific exceptions.
  • Either-or Return: Return any type (an object handle or value) or a FAILURE status from a method.
  • Cross-Library Memory Safety Checks: Verification of memory safety across external library boundaries.
  • Actionable Compiler Errors: Every compiler error points directly to the problem spot, includes a suggested fix, and cites the specific language rule from the Constitution document.

An Overview of the Essentials

You will notice that all keywords are in uppercase, with the exception of primitive types. This is so that all keywords stand out.

Primitives

Envzn has 29 distinct types divided into families:

  • Signed Integer: int8, int16, int32, int64*, int128
  • Unsigned Integer: uint8, uint16, uint32, uint64, uint128
  • Float: float32, float64*
  • Character: char8, char16, char32*
  • boolean: holds TRUE or FALSE
  • binary: an uninterpreted octet; a bit pattern, not a number
  • number: a self-aware integer-or-float that auto-promotes from int64 to uint64 to float64
  • complex: a pair of number types written with the im literal — 3 + 4im
  • decimal128: an exact base-10 number with round-half-even arithmetic
  • opaque: container for heterogenous storage and typed FOREIGN pointers
  • UNSAFE: a family of types that may only be used within an UNSAFE block
  • UNSAFE.HANDLE: container for an untyped FOREIGN pointer
  • UNSAFE.MUTEX: raw OS mutex; use the kernel Mutex class instead
  • UNSAFE.CONDVAR: raw OS condition variable; use the kernel ThreadCondition class instead
  • C: a family of types for use only with the C ABI: C.size_t, C.ssize_t, C.long, C.unsignedLong, C.mode_t

* the default for that family, e.g. int is an alias for int64

Class, Struct, and Namespace

  • STRUCT: a C-style data structure that only contains data fields; it cannot inherit or implement an interface
  • NAMESPACE: a C++-style namespace that only contains functions and constants; it cannot inherit or implement an interface
  • CLASS: a combination of data fields, constants, and methods; it may inherit from one other class and implement many interfaces. There are multiple modifiers of CLASS, some are mutually-exclusive:
  • Plain: normal class with polymorphic traits
  • FINAL: class that cannot be a parent for another class
  • VALUE: class that should be treated like a STRUCT
  • INTERNAL: class that cannot be seen outside its module
  • SINGLETON: class that has only one instance
  • SHARED: class that could use the SHARED MUTABLE REFERENCE handle
  • ABSTRACT: class with at least one method declared but not defined
  • HIDDEN: class that when instantiated must be assigned to its interface

Native Arrays

Envzn has strong native arrays available on any type in three forms (T[], T[size], T[size+]) for rank 1 with examples below:

  • int32[]: native array of int32 elements, growable, with starting size=0
  • binary[64]: native array of binary elements, fixed size of 64
  • char32[128+]: native array of char32 elements, growable with a starting size of 128 char32 elements (512 bytes)

For rank 2:

  • int64[,]: native array of int64 elements, type spine
  • float64[m,n]: native array of float64 elements, extents defined at run time
  • float32[5,8]: native array of float32 elements, fixed size

For rank 3:

  • int64[,,]: native array of int64 elements, type spine
  • float64[j,k,l]: native array of float64 elements, extents defined at run time
  • float32[5,8,9]: native array of float32 elements, fixed size

Native arrays work with user defined types also, so class and struct types may also be used in these. Ranks are valid up to 15 dimensions.

Native arrays have a limited set of methods. (If you need more functionality, use the standard library Array class.)

Data Fields

Data fields are internal variables for a CLASS or STRUCT. Plain data fields are public; they may be marked INTERNAL, PROTECTED, or PRIVATE for limiting access. They are immutable by default and may only be changed in a MODIFY method. Example:

CLASS MyClass {
    String name          // public data field name of type String
    INTERNAL int8 age    // data field age of type int8;
                         // INTERNAL means it is only seen inside
                         // the module of MyClass
}

STATUS

STATUS is an in-built type to have a standard way for returning SUCCESS, FAILURE, or PARTIAL_SUCCESS to the caller. It is used often with the Either-Or Return of methods.

Handles and References

This handle can be assigned to a reference handle, which allows read-only access. For write access, the handle can be assigned to a mutable reference, though only one active mutable reference is permitted at a time. Alternatively, shared mutable references allow multiple references to modify the object for a class declared as SHARED.

Variable Assignments

To assign a value to a variable there are three assignment operators:

  • = assignment for a primitive or a String constant
  • := assignment for an owned handle of a class instance or object; moves ownership into the handle on the left hand side of the operator
  • =@ assignment for REFERENCE and MUTABLE REFERENCE handles

Examples:

int32 n = 5
Widget w := CREATE()
REFERENCE Widget rw =@ w

Text Handling

The Envzn standard library has four classes for text and two views to aid in searching those.

  • String: immutable char32 array (any change creates a new String object)
  • DynamicString: mutable char32 array (changes update the same object)
  • ByteBuffer: immutable binary array
  • DynamicByteBuffer: mutable binary array
  • StringView: search and other utility methods for String
  • ByteBufferView: search and other utility methods for ByteBuffer

While one may use native arrays for text storage, these 6 classes have a rich API to provide access developers expect in modern development.

Control Flow

Envzn has multiple means for flow control:

  • IF (conditional-expression) THEN { } ELSE { }: logical branching
  • WHILE (conditional-expression) DO { }: tests the conditional expression first, then executes the code block repeatedly as long as the conditional expression is TRUE
  • UNTIL (conditional-expression) DO { }: tests the conditional expression first, executes the code block repeatedly as long as the conditional expression is FALSE
  • DO { } WHILE (conditional-expression): executes the code block, repeats while the conditional expression is TRUE
  • DO { } UNTIL (conditional-expression): executes the code block, repeats while the conditional expression is FALSE
  • FOR i=a TO b STEP s { }: i is assumed to be int64
  • FOR (int32 i=0; i<5; i++) { }: C-style loop
  • FOR element IN MyArray { }: requires MyArray to have an Iterator
  • LOOP element IN MyArray WITH INDEX i { }: element plus its int64 position
  • REPEAT n { }: repeat the loop n times; an infinite loop without n
  • LABEL name <loop or block>: a name for a block of code
  • BREAK / CONTINUE: breaks out of a loop or continues at the start
  • BREAK name / CONTINUE name: breaks out of the named block of code to resume after it; continues at the start of the named block of code; very useful in nested loops

Method Parameters and MODIFY

Methods accept zero or more inbound arguments and may return multiple results. Any method that modifies an object's internal data fields must be explicitly declared with MODIFY. Read-only references cannot invoke modifying methods.

When plain handles are passed as arguments, ownership is transferred ("moved") into the method. Reference handles, however, do not transfer ownership. Primitive values and structs are always copied. Examples:

Widget w := CREATE()                  // Create a Widget; w is the owning handle
REFERENCE Widget rw =@ w              // Assign a read-only reference
MUTABLE REFERENCE Widget mrw =@ w     // Assign a mutable reference

METHOD foo(REFERENCE Widget myref) {  // pass in object handle 'w'
    myref->doSomething()              // the myref handle is read-only so
                                      // doSomething() cannot modify myref
}

Generics / Templates

Envzn allows generic types, and they are used extensively. Many types that developers expect in a modern language, such as Array[T], Dictionary[K,V,H], LinkedList[T], Set[T], and Queue[T], are found in the standard library. These have a rich API and describe the types that are allowed to be used with them. Each generic class has a "template qualifier" preamble prior to the class definition to constrain what types may be used by that class. An example:

TEMPLATE: GIVEN TYPE T IS Cloneable, PRIMITIVE (EXCEPT opaque, boolean):
CLASS Array[T] IMPLEMENTS Cloneable, Collection OF T, Shuffleable OF T {
    …
}

In this example, generic type T is constrained to something that implements the Cloneable interface, or be a primitive (like int32) but it cannot be opaque or boolean types.

A Note on Memory Safety

To achieve memory safety, Envzn aims to address eight main challenges:

  1. Escaping and dangling references: a reference outlives its origin object
  2. Use after move: an owning handle is read after ownership left
  3. Reference held after a mutation: the origin object is modified while a REFERENCE to the origin object is held by another
  4. Memory leaks: a strong reference cycle is never torn down
  5. Null or uninitialized memory: a slot is read before it is assigned, or after it has been reset to null
  6. Data races: concurrent access issues
  7. Spatial bounds: access out-of-bounds of an array
  8. Stack exhaustion: overflowing the stack, caused by deep recursion or dropping a long owned chain

The compiler today covers 7 of the 8 challenges: the only one that has not been built and tested thoroughly is #6, data races. Challenges #5, #7, and #8 are checked at runtime, while #2 and #4 are checked at compile time. For memory safety coverage of #1 and #3, the compiler generates an EvIR file for libraries, and at compile time, walks through code that has passed the analysis rules engine to track the lifecycle of every handle and reference from initial assignment to its end. By analyzing both the current program and the EvIR files of used libraries, Envzn works to ensure complete memory safety with minimal impact on compilation time.

Where to Go From Here