One Object Definition to Rule Them All
Define once. Export to 14+ languages & formats. Store in binary.
Memory-mapped monolithic block. Zero-copy, unbuffered, non-blocking I/O.
Java, JavaScript, JSON, TypeScript, C, Go, Swift, Rust, Kotlin, C#, TOML, WASM, MessagePack, ODL.
Objects can contain Objects. Multi-dimensional arrays. Sparse arrays.
HEAP, STACK, IPC, GPU, CLOUD, REGISTRY, PAGE — all in one memory model.
Send Objects over sockets with zero-copy, endian-safe binary protocol.
Query Objects with SQL-like commands. Monolithic index. Non-blocking.
Default: All fields reside in the HEAP (dynamic memory) unless explicitly prefixed. The following qualifiers are parsed but ignored by the ODL compiler — they serve as hints for the runtime or for higher‑level frameworks. They do not affect the binary layout.
// Prefix is optional; without it, HEAP is assumed STACK char name[64] = "USS Enterprise"; GPU float warp_speed = 9.975; // no prefix → HEAP int64_t registry = 1701;
Monolithic Block Design. The ObjectWhack runtime serializes an entire object graph into a contiguous memory region. This eliminates per‑field marshalling overhead and enables memory‑mapped I/O (mmap) for near‑zero‑copy deserialization.
Protocol Specification. The binary format (.chd) begins with a fixed header (SerialHeader) containing a magic number (0x4F57424A), version, flags, name length, field count, and total size. All multi‑byte integers are converted to network byte order (big‑endian) to ensure portability across architectures.
Unbuffered System Calls. The implementation uses write() and read() directly (wrapped as write_exact/read_exact). This bypasses the stdio buffer, ensuring that data is pushed to the kernel immediately — critical for low‑latency networking and real‑time systems. The entire object is written in a single write loop when possible, minimising system call overhead.
Bytecode Derivation. The serialization routine derives the bytecode directly from the in‑memory field descriptors — no intermediate AST or reflection is required. This yields a constant‑time serialization cost proportional to the total data size, with zero heap allocations during the write path.
Endian‑Aware Element Packing. Each elementary type (int8, int16, int32, int64, float, double) is individually byte‑swapped if the host is little‑endian. This ensures that the stored representation is canonical and can be read on any platform without further conversion.
FSendObject / FReceiveObject. The library provides two functions for direct socket I/O:
int64_t FSendObject(struct Object *obj, int fd); – serializes obj into a contiguous buffer and sends it via write_exact.struct Object* FReceiveObject(int fd); – reads the header and payload via read_exact, reconstructing the object graph.Because the serialised buffer is written directly to the socket descriptor, the data travels from the object’s memory to the network interface with zero intermediate copies in user space. This is what we call a "Socket Blast" – a single, unbuffered push of the entire object state over the wire.
Example (server side):
int client_fd = accept(listen_fd, ...);
struct Object *ship = LoadObject("Starship");
if (ship) {
int64_t bytes = FSendObject(ship, client_fd);
printf("Sent %lld bytes\n", bytes);
FreeObject(ship);
}
close(client_fd);
Client side:
int server_fd = connect(...);
struct Object *ship = FReceiveObject(server_fd);
if (ship) {
PrintObject(ship);
FreeObject(ship);
}
close(server_fd);
The same mechanism works for IPC (Unix domain sockets) and even stdin/stdout redirection, making ObjectWhack ideal for microservices and side‑car architectures.
typedef struct __attribute__((packed)) {
uint32_t magic; // 0x4F57424A
uint32_t version; // 1
uint64_t flags; // user flags
uint32_t name_len;
uint32_t field_count;
uint32_t total_size; // entire serialised block size
} SerialHeader;
The ODL parser recognises both the standard C‑style names (from type_table) and the
short‑form aliases listed in the table below. These aliases are accepted in
all contexts — full multi‑line definitions, shorthand single‑line descriptions, and nested
object initialisers.
The parser maps i8 → int8_t, i16 → int16_t,
i32 → int32_t, i64 → int64_t,
u8 → uint8_t, u16 → uint16_t,
u32 → uint32_t, u64 → uint64_t,
f32 → float, and f64 → double.
| Syntax | Description | Example |
|---|---|---|
| OBJECT Name; | Start an object definition | OBJECT Ship; |
| { ... } | Encloses field definitions | { ... } |
| HEAP|STACK|IPC|GPU|CLOUD|REGISTRY|PAGE type name; | Memory type prefix (optional, default HEAP) | GPU float warp_speed; |
| type name; | Scalar field | int32_t x; or i32 x; |
| type name[n]; | Fixed‑size array | char name[64]; |
| type name[]; | Sparse / dynamic array | int32_t coords[]; or i32 coords[]; |
| type name[n][m]; | Multi‑dimensional array | int32_t grid[10][10]; |
| Object name; | Nested object reference | Object pilot; |
| type name = "value"; | Scalar initializer | char name[32] = "Enterprise"; |
| type name = { 1, 2, 3 }; | Array initializer | int32_t coords[] = {1, 2, 3}; |
// Full form with short‑form aliases and braces OBJECT Starship; { i64 registry = 1701; char name[64] = "USS Enterprise"; f32 warp_speed = 9.975; i32 crew[3][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; Object captain; }
The interactive n (new object) command accepts a comma‑separated single‑line description.
This form omits the OBJECT keyword and trailing semicolon, but supports the same type names, array
brackets, and initialisers as the full multi‑line syntax. The parser (AllocObject) splits on
top‑level commas (respecting quotes and braces) and builds the object in one pass.
Aliases are fully supported — use i32, i64, f32, etc. for brevity.
Object captain = { ... }). It is designed for rapid prototyping and interactive use;
for persistent definitions, the multi‑line OBJECT … ; { ... } form is recommended for clarity.
The examples below use the canonical type names for clarity; you may replace them with aliases at any time.
Memory prefixes are omitted except where they add semantic value (e.g., GPU).
All definitions use the brace‑enclosed syntax.
OBJECT Starship; { int64_t registry = 1701; char name[64] = "USS Enterprise"; float warp_speed = 9.975; int32_t position[3] = {0, 0, 0}; float orientation[4] = {0.0, 0.0, 0.0, 1.0}; int32_t shield_level = 100; int32_t hull_integrity = 100; Object captain; Object crew[]; // Sparse array }
OBJECT NeuralNetwork; { char model_name[128] = "resnet50"; int32_t layers = 50; int32_t neurons[] = {784, 256, 128, 10}; float weights[][]; // 2D weights matrix float biases[]; int8_t activation = 0; // 0=ReLU,1=Sigmoid,2=Tanh float learning_rate = 0.001; int32_t epochs = 100; char dataset[256] = "mnist"; }
OBJECT WebSocketConnection; { int64_t connection_id = 0; char remote_addr[64] = "127.0.0.1"; int32_t port = 8080; char protocol[32] = "ws"; int8_t state = 0; // 0=Connecting,1=Open,2=Closing,3=Closed uint64_t bytes_sent = 0; uint64_t bytes_received = 0; float latency = 0.0; }
OBJECT BlockchainBlock; { int64_t index = 0; char timestamp[32] = "2026-01-01T00:00:00Z"; char prev_hash[64] = "0000..."; char hash[64]; int32_t nonce = 0; uint64_t difficulty = 4; Object transactions[]; int64_t merkle_root = 0; }
OBJECT GPUBuffer; { int32_t width = 1920; int32_t height = 1080; int32_t depth = 1; int32_t format = 0; // 0=RGBA8,1=Float32,2=Int32 uint64_t size = 0; GPU uint8_t data[]; // Raw GPU data float memory_usage = 0.0; int8_t is_allocated = 0; }
OBJECT DNSRecord; { char domain[256] = "example.com"; int32_t ttl = 3600; int16_t record_type = 1; // 1=A,2=NS,5=CNAME,15=MX,28=AAAA char value[256] = "93.184.216.34"; int32_t priority = 10; // For MX records int32_t weight = 0; int16_t port = 0; }
OBJECT GameEntity; { int64_t entity_id = 1; char tag[64] = "Player"; float position[3] = {0.0, 0.0, 0.0}; float rotation[4] = {0.0, 0.0, 0.0, 1.0}; float scale[3] = {1.0, 1.0, 1.0}; int8_t active = 1; uint64_t component_mask = 0; Object components[]; }
OBJECT APIRoute; { char path[256] = "/api/v1/users"; int8_t methods[] = {0, 1}; // 0=GET,1=POST,2=PUT,3=DELETE,4=PATCH char handler[128] = "UserController"; char middleware[][]; int32_t timeout = 30; int32_t rate_limit = 100; char description[512] = "User CRUD endpoints"; }
OBJECT SensorData; { char sensor_id[64] = "temp-01"; char type[32] = "temperature"; double value = 23.5; int64_t timestamp = 0; float accuracy = 0.1; char unit[16] = "C"; int32_t battery = 100; int8_t status = 0; // 0=OK,1=Warning,2=Error }
OBJECT KubernetesPod; { char name[128] = "nginx-pod"; char namespace[64] = "default"; char labels[][]; Object containers[]; char node[128]; int32_t cpu_request = 100; int32_t memory_request = 128; int8_t phase = 0; // 0=Pending,1=Running,2=Succeeded,3=Failed }
OBJECT AITransformer; { char model_id[128] = "gpt-style"; int32_t num_layers = 12; int32_t num_heads = 12; int32_t embed_dim = 768; int32_t vocab_size = 50257; float dropout = 0.1; float weight[][][]; // 3D weight tensor float bias[][]; // 2D bias tensor }
OBJECT CloudResource; { char resource_id[128] = "i-0abc123"; char provider[32] = "aws"; char region[32] = "us-east-1"; char type[64] = "ec2"; char tags[][]; float cost_per_hour = 0.0464; int32_t cpu = 2; int64_t memory = 4096; int8_t state = 1; // 0=Stopped,1=Running,2=Terminated }
Usage: ./ow [options] [file.odl ...]
If files are given they are processed; otherwise stdin is read.
If no files and stdin is a terminal → interactive mode.
| Flag | Export Format | Notes |
|---|---|---|
| -j | Java (.java) | public class |
| -k | JavaScript (.js) | const object |
| -z | JSON (.json) | name + fields |
| -v | TypeScript (.ts) | interface |
| -c | C Header (.h) | struct + include guard |
| -g | Go (.go) | type struct |
| -w | Swift (.swift) | struct |
| -o | ODL (.odl) | re-emit definition |
| -a | All formats | sets EXFLAG_ALL (includes Rust, Kotlin, C#, TOML, WASM, MessagePack) |
Interactive mode commands (when run with no arguments on a TTY):
| Key | Action |
|---|---|
| n | New object (compact single-line description) |
| P | Process all .odl files in object directory |
| l | Load object |
| s | Save object (.chd) |
| p | Print current object |
| t | List saved objects |
| b | Print all objects |
| a | Export current object to all formats |
| o / j / k / z / v / y / c / g / w | Export specific language |
| h | Help |
| q | Quit |