Quartex Pascal Compiler Adds Generics, RTTI, Binary Records, and Self-Hosting
Quartex Pascal releases a new compiler with Delphi-compatible generics, full RTTI, binary records for low-level memory access, near-doubled compilation speed, and self-hosting capability, demonstrated by porting the Reticulum network protocol from C to Object Pascal.
Quartex Pascal (QTX) is a modern Object Pascal development system comprising an IDE, compiler, and runtime library (RTL) that compiles Pascal code to high-performance JavaScript for browsers and Node.js. The new compiler version builds on DWScript for parsing and symbol modeling, then adds several long-missing capabilities.
Core Features
Full compatibility with Delphi-style generics
Complete RTTI (Run-Time Type Information) aligned with Delphi
Compilation speed nearly doubled
New binary record type
Variant and interface support in WebAssembly
These improvements achieve a compiler singularity : the compiler can now compile its own source code. The original roadmap estimated at least two more years to run the compiler in browser and Node.js environments; that goal is now realized.
Binary Records
Standard Pascal records compile to plain JavaScript objects, sufficient for most web apps (JSON serialization, server interaction). However, porting native code that writes structs directly to streams or memory buffers requires a different memory layout.
Case Study: Porting Reticulum
The team ported Reticulum (a mesh networking protocol similar to Meshtastic/Meshcore) from C to Object Pascal. Reticulum communicates via USB serial and mesh radio devices, implementing a TCP/IP-like datagram protocol. Interoperability demands three layers of complex protocols built on record structs, bitmasks, and native memory field behavior.
Without binary records, each of the ~60 data structures would need manual constructor, read, and write methods — about 180 boilerplate functions. The new compiler introduces binary records as a native language feature using the existing packed keyword. When a record is marked packed, the compiler automatically generates a buffer object; field reads and writes invoke the buffer's typed read/write interfaces, eliminating nearly all manual coding.
type
TMyMessage = packed record
rId: UInt32;
rSize: UInt16;
rX: uint8;
rY: uint8;
rlabel: string[255];
end;Writing binary records directly to streams or buffers becomes an out-of-the-box capability. QTX's RTL already provides comprehensive binary processing classes and utilities, so even when targeting JavaScript the compiler gains near-native low-level abilities.
Generics
Generics are the highest-impact feature; official estimates indicate up to 60% code reduction in RTL modules. A generic dictionary example:
type
TQTXDictionary<K,T> = class(TObject)
private
fLUT: array[K] of T;
public
property Count: int32 read (fLUT.Count);
property Keys: array of K read (fLUT.Keys);
property Items[const AKey: K]: T
read (fLUT[K])
write (fLUT[K] := Value);
procedure Clear; virtual;
end;Previously, QTX used associative arrays with fixed key/value types:
type
TQTXDictionary = array[string] of TMyObject;The key difference: the old approach hard-codes specific key and value types, while the generic class supports almost any basic type as key and most types as value. Generics decouple business logic from concrete data types.
Valid instantiations include:
var dict := TQTXDictionary<string, TQTXLocalDisk>.Create;
var dict := TQTXDictionary<int32, TQTXPixmap>.Create;
var dict := TQTXDictionary<THandle, variant>.Create;RTTI (Run-Time Type Information)
RTTI enables reading type metadata at runtime, commonly used for object persistence and serialization. QTX's prior persistence relied on base class TQTXPersistent with virtual methods ReadObject, WriteObject, and Assign. Without RTTI, developers had to manually override these methods field by field, emitting JSON. IDE-external scenarios also lacked support for loading form/design files; layouts were converted to source code and compiled with the form constructor.
With RTTI implemented, any class inheriting from TQTXPersistent automatically serializes published properties. Most existing RTL components don't yet use this mechanism, so achieving Delphi-comparable persistence comes at low cost. Future TQTXPersistent will behave like Delphi/Lazarus: auto-enumerating published properties for serialization, accompanied by a TFiler -like mechanism for streams, managed memory, and other complex types.
Conclusion
Quartex Pascal is iterating rapidly. The team plans to fully detach from DWScript and is evaluating LLVM integration for native binary executables, though current focus remains on the web development stack.
Author: 场长 Original: https://quartexdeveloper.com/2026/09/13/generics-rtti-a-new-compiler
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
