-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Oriented-Direct is a modern, high-performance, unambiguous programming language that transpiles directly into clean, standard ECMAScript (ES Modules) with zero external runtime dependencies.
Designed from first principles for browser and Node.js environments, Oriented-Direct eliminates historic JavaScript verbosity, replaces legacy DOM APIs with native compile-time directives, enforces immutability by default, guarantees strict equality, and provides a built-in zero-configuration multi-module bundler and local development server (ospc dev).
JavaScript was conceived in 1995 as a lightweight browser scripting language. Over three decades, web development accumulated complex layers of external abstractions (frameworks, virtual DOM engines, transpilers, and package managers) to mitigate language deficiencies.
Oriented-Direct resolves these architectural challenges directly at the language level:
-
DOM as a First-Class Citizen: Native
@directives eliminate the verbosity ofdocument.querySelectorand event listener boilerplate. -
Immutability by Default: Variables declared with
valare immutable constants; mutable state requires explicitmut. -
Strict Equality Guarantee: Comparison operators (
is,is not,==,!=) compile exclusively to strict identity checks (===and!==). Loose type coercion bugs are eliminated. -
Linear Data Pipelines: The pipeline operator (
|>) allows clean, readable, left-to-right functional data transformations. -
Zero-Dependency Project Ecosystem: The compiler (
ospc) contains a built-in module resolver, multi-module bundler, and development server, removing the requirement for Webpack, Vite, or Babel.
The compiler binary is ospc (or oriented-direct).
| Command | Description |
|---|---|
ospc dev [port] |
Compiles the project, copies declared assets, and launches an HTTP development server with automatic file-watching recompilation (default port: 3000). |
ospc serve [port] |
Alias for ospc dev. |
ospc build [entry.osp] |
Compiles and bundles the project according to package.json or CLI flags. |
ospc build --public |
Bundles code into public/app.js and copies static assets (index.html, styles.css) into public/. |
ospc compile <file.osp> |
Transpiles a single .osp file to an equivalent .js file. |
ospc run <file.osp> |
Transpiles/bundles the target file and immediately executes it using Node.js. |
ospc watch [entry.osp] |
Monitors the file tree and recompiles automatically upon filesystem modifications. |
ospc --help / ospc -v
|
Displays usage instructions or compiler version details. |
Oriented-Direct projects are configured declaratively in package.json under the "osp" property or inside a dedicated osp.json file.
{
"name": "my-oriented-direct-app",
"version": "1.3.0",
"type": "module",
"scripts": {
"dev": "ospc dev",
"build": "ospc build --public",
"watch": "ospc watch --public"
},
"osp": {
"entry": "src/main.osp",
"outDir": "public",
"outFile": "app.js",
"bundle": true,
"format": "esm",
"port": 3000,
"minify": false,
"assets": [
"index.html",
"styles.css",
"assets/"
]
}
}my-project/
├── package.json # Build, bundler, and server configuration
├── index.html # Source HTML5 interface
├── styles.css # Source styles
├── src/ # 100% Oriented-Direct source code
│ ├── main.osp # Application entry point
│ ├── utils/ # Helper utilities and shared functions
│ └── modules/ # Domain-specific components
└── public/ # Self-contained production distribution directory
├── index.html # Asset copied automatically by compiler
├── styles.css # Asset copied automatically by compiler
└── app.js # Monolithic bundled JavaScript output
Oriented-Direct prohibits let, const, and var.
val maximumDepth = 450; // Immutable constant (compiles to const)
mut currentHeartRate = 110; // Reassignable variable (compiles to let)
currentHeartRate = 45;
All comparisons compile to strict JavaScript operators.
| Operation | Oriented-Direct Syntax | Compiled JavaScript |
|---|---|---|
| Strict Equality |
a is b or a == b
|
a === b |
| Strict Inequality |
a is not b or a != b
|
a !== b |
| Logical Conjunction | a and b |
a && b |
| Logical Disjunction | a or b |
a || b |
| Logical Negation | not a |
!a |
| Nullish Coalescing | a ?? b |
a ?? b |
if (currentHeartRate < 20 and not isSurfaceBreathing) {
@info("Deep bradycardia active");
}
if (depth > 200) {
@log("Mesopelagic zone");
} else {
@log("Epipelagic zone");
}
// Inverted conditional (executes when condition is falsy)
unless (isInitialized) {
initializeSubsystems();
}
val label = match (statusCode) {
case 200 => "Operation Successful"
case 404 => "Resource Not Found"
case 500 => "Internal System Fault"
default => "Unrecognized Status"
};
Oriented-Direct provides four optimized looping paradigms:
// 1. C-Style 3-Part Loop (Use 'mut' for mutable iteration counters)
for (mut i = 0; i < buffer.length; i += 4) {
processBufferChunk(i);
}
// 2. Numeric Range Loop
for (val step in 0..100 step 10) {
@log("Progress checkpoint:", step);
}
// 3. Iterable / Array Collection Loop
for (val item in itemArray) {
renderItem(item);
}
// 4. Object Key Enumeration Loop
for (val key of configurationObject) {
@log(key, configurationObject[key]);
}
Defining a struct automatically generates a class constructor fortified with Object.seal(this). This guarantees memory integrity and prevents accidental property additions at runtime.
struct TelemetryRecord { specimenId, latitude, longitude, depthMeters }
val record = new TelemetryRecord("HS-409", 47.5, -61.8, 382.4);
class AcousticSynthesizer {
constructor(sampleRate) {
this.sampleRate = sampleRate;
this.audioContext = null;
}
start() {
this.audioContext = new (@win.AudioContext || @win.webkitAudioContext)();
}
}
The pipeline operator passes the result of the left-hand expression as the first argument to the right-hand function.
val normalizedString = rawInput |> trimText |> toLowerCase |> sanitize;
Directives provide zero-cost abstractions over the DOM, browser window, and console subsystems.
| Directive | Signature | Description |
|---|---|---|
@doc |
@doc |
Points safely to the global document object. |
@win |
@win |
Points safely to the global window object. |
@find |
@find(selector, parent?) |
Executes parent.querySelector(selector). Safe against null parents. |
@all |
@all(selector, parent?) |
Executes Array.from(parent.querySelectorAll(selector)). |
@id |
@id(idString) |
Fast lookup via document.getElementById(idString). |
@text |
@text(el, content?) |
Getter/setter for el.textContent. |
@html |
@html(el, content?) |
Getter/setter for el.innerHTML. |
@val |
@val(el, value?) |
Getter/setter for form element value (el.value). |
@attr |
@attr(el, name, value?) |
Getter/setter for element attributes. |
@css |
@css(el, { key: val }) |
Applies inline styles via Object.assign(el.style, { ... }). |
@create |
@create(tag, attrs, ...children) |
Declaratively constructs DOM elements with properties, inline styles, and child nodes. |
| Directive | Signature | Description |
|---|---|---|
@on |
@on(target, event, handler, opts?) |
Attaches an event listener (addEventListener). Returns the target. |
@off |
@off(target, event, handler, opts?) |
Detaches an event listener (removeEventListener). |
@emit |
@emit(target, event, detailObj) |
Dispatches a CustomEvent with { detail: detailObj, bubbles: true }. |
| Directive | Compiled Equivalent |
|---|---|
@log(...) |
console.log(...) |
@info(...) |
console.info(...) |
@warn(...) |
console.warn(...) |
@error(...) |
console.error(...) |
Oriented-Direct v1.3.0 supports modular code splitting with import and export.
When bundling modules, the compiler wraps each module inside an isolated scope. In JavaScript, const and class variables exist within the Temporal Dead Zone (TDZ) before their declaration lines. Function declarations (function) are hoisted.
Always export utility and lifecycle routines using export fn:
// File: src/utils/formatters.osp
export fn formatPercentage(value) {
return value + "%";
}
export fn formatPressure(atm) {
return atm.toFixed(1) + " ATM";
}
// File: src/main.osp
import { formatPercentage, formatPressure } from "./utils/formatters.osp";
val formatted = formatPercentage(98.5);
Critical Rule: Always include the
.ospfile extension in the import specifier path (from "./utils/formatters.osp").
Oriented-Direct interfaces directly with WebGL contexts and 3D graphics libraries without requiring external type packages or runtime wrappers.
import { setupLighting } from "./observatory/lighting.osp";
import { buildEnvironment } from "./observatory/environment.osp";
export fn init3DHabitat() {
val container = @id("webglViewport");
unless (container) return;
val THREE = @win.THREE;
val scene = new THREE.Scene();
val camera = new THREE.PerspectiveCamera(45, container.clientWidth / container.clientHeight, 0.1, 1000);
val renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(container.clientWidth, container.clientHeight);
container.appendChild(renderer.domElement);
setupLighting(scene, THREE);
buildEnvironment(scene, THREE);
fn renderLoop() {
requestAnimationFrame(renderLoop);
renderer.render(scene, camera);
}
renderLoop();
}
export fn synthesizePulse(frequencyHz, durationSeconds) {
val AudioContextClass = @win.AudioContext || @win.webkitAudioContext;
unless (AudioContextClass) return;
val ctx = new AudioContextClass();
val osc = ctx.createOscillator();
val gain = ctx.createGain();
osc.type = "sine";
osc.frequency.setValueAtTime(frequencyHz, ctx.currentTime);
gain.gain.setValueAtTime(0.01, ctx.currentTime);
gain.gain.linearRampToValueAtTime(0.3, ctx.currentTime + 0.05);
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + durationSeconds);
osc.connect(gain);
gain.connect(ctx.destination);
osc.start();
osc.stop(ctx.currentTime + durationSeconds + 0.05);
}
- Incorrect:
if (isValid && !hasError) - Correct:
if (isValid and not hasError)
- Incorrect:
for (val i = 0; i < count; i++)(Triggers constant mutation error) - Correct:
for (mut i = 0; i < count; i++)
- Incorrect:
let status = "ready"; - Correct:
mut status = "ready";
- Incorrect:
export val calculateMass = (vol) => vol * 1.025; - Correct:
export fn calculateMass(vol) { return vol * 1.025; }
- Incorrect: Manually transpiling single files to root
app.js. - Correct: Configure
package.jsonwith"outDir": "public"and executeospc build --publicorospc dev.
Compared to equivalent TypeScript / JavaScript enterprise configurations:
- Token Density: ~45% to 50% fewer source tokens required to express complex DOM, event, and state pipelines.
- Runtime Footprint: Zero runtime framework overhead (~1 KB micro-helper injection).
-
Cold-Start Build Time: Instantaneous compilation and bundling via built-in Node.js compiler engine without dependency graphs in
node_modules.
Oriented-Direct (.osp) Programming Language — Zero-Overhead, High-Performance Web & Node.js Platform
Documentation | CLI Reference | Syntax Guide | Source Maps | Directives | GitHub Repository
Quick Start: ospc dev (Local Dev Server) | ospc build --public --sourcemap (Production Bundle with Source Maps)
Maintained under the Open Source Initiative. Oriented-Direct Compiler (ospc) Version 1.4.0.