Meet JSON's functional half-brother.

JSOL Mascot

If your business logic has a single-source-of-truth (SSOT) problem, JSOL may help.

I built JSOL because I didn't want to keep maintaining the same rules twice (once for the server, once again for the browser) on IPAX, a color science framework for accessible design systems. Every change meant updating both, testing both, and hoping they still agreed.

Did you know that something as simple as modulo can give you different results across languages? My LLM didn't. Turns out that 7.5 % 2 is 1.5 in JS… and 1 in PHP. And that's just one bug that slipped through code review.

Since most general-use languages today are somehow C-like, I wondered if there was some lingua franca we could use to declare business logic once, and include afterwards in our code with bit-for-bit parity.

That's how JSOL was born: a strict subset of JavaScript that transpiles to JavaScript, PHP, TypeScript and Python (with more targets planned), guaranteeing deterministic parity. Write the rule once, change it once, test it once.

Think JSON, but for business logic.


Is it worth your time?

The first question we developers ask about a new tool is: "Should I bother learning this?"

JSOL has strict syntax, zero syntactic sugar, and a learning curve. Writing it — even with an AI's help — will take you longer than writing native code you've already mastered. But JSOL's upfront cost can pay off in iterative maintenance.

The honest way to answer that question is with a model. So the first example below is exactly that: an adoption-economics model written in JSOL, running live in the REPL. And compiled to every target for inspection.

Play with the inputs: how many targets you maintain, how often your rules change, how many iterations until the upfront cost pays for itself. Add rows to evaluate different scenarios. And while you're at it, you're watching JSOL do what it was built to do.

📊 JSOL Spreadsheet REPL — v0.2.96

Function: $aSiftDown

// @JSOL v0.2.94

/**
 @description
 Sorts an array of numbers into ascending order using heapsort (CLRS
 chapter 6): treats the array as a binary heap using standard implicit
 indexing (a node at index i has children at 2i+1 and 2i+2), builds a
 max-heap out of the whole array, then repeatedly swaps the root (the
 current largest value) with the last unsorted element and re-heapifies
 the shrinking heap.
  No pointers or node objects needed: the parent/child relationship is
 entirely arithmetic on array indices, which is why heapsort is one of
 the few classic tree-based algorithms that translates directly into
 JSOL's array-only data model.
  O(n log n) in every case, and unlike merge-sort.jsol.js, sorts in place
 with no extra array needed.

@param {array<number>} $aValues - Numbers to sort.
@returns {array<number>} - A new array with the same numbers in ascending order.
*/

/**
 @contract
 {
   "cases": [
     { "$aValues": [5, 2, 9, 1, 5, 6] },
     { "$aValues": [] }
   ]
 }
*/

const $aSiftDown = function($aValues, $qHeapSize, $qRoot) {
    // JSOL.use: Explicitly binds self-reference for recursive closure execution across target runtimes.
    JSOL.use($aSiftDown);

    let $qLargest = $qRoot;
    const $qLeftChild = (2 * $qRoot) + 1;
    const $qRightChild = (2 * $qRoot) + 2;

    if ($qLeftChild < $qHeapSize && $aValues[$qLeftChild] > $aValues[$qLargest]) {
        $qLargest = $qLeftChild;
    }
    if ($qRightChild < $qHeapSize && $aValues[$qRightChild] > $aValues[$qLargest]) {
        $qLargest = $qRightChild;
    }

    if ($qLargest !== $qRoot) {
        const $nTemp = $aValues[$qRoot];
        $aValues[$qRoot] = $aValues[$qLargest];
        $aValues[$qLargest] = $nTemp;
        
        // Cross-Engine Parity Note: Array reassignment guarantees that in-place mutations persist
        // on target runtimes where arrays are passed by value (e.g., PHP) vs by reference (e.g., JS/TS).
        $aValues = $aSiftDown($aValues, $qHeapSize, $qLargest);
    }

    return $aValues;
};

const $aHeapSort = function($aValues) {
    // JSOL.use: Injects helper functions into closure scope for isolated target runtimes.
    JSOL.use($aSiftDown);

    let $aSorted = Arr.slice($aValues, 0, Arr.count($aValues));
    const $qLen = Arr.count($aSorted);

    // Build the max-heap: sift down every non-leaf node, from the last one back to the root.
    for (let $qI = Math.floor($qLen / 2) - 1; $qI >= 0; $qI = $qI - 1) {
        // Capture returned array to ensure mutation persistence across value-type array engines.
        $aSorted = $aSiftDown($aSorted, $qLen, $qI);
    }

    // Repeatedly move current max (root) to the end of unsorted region, then re-heapify.
    for (let $qEnd = $qLen - 1; $qEnd > 0; $qEnd = $qEnd - 1) {
        const $nTemp = $aSorted[0];
        $aSorted[0] = $aSorted[$qEnd];
        $aSorted[$qEnd] = $nTemp;
        
        // Capture returned array to ensure mutation persistence across value-type array engines.
        $aSorted = $aSiftDown($aSorted, $qEnd, 0);
    }

    return $aSorted;
};
// @JSOL v0.2.94

/**
 @description
 Sorts an array of numbers into ascending order using heapsort (CLRS
 chapter 6): treats the array as a binary heap using standard implicit
 indexing (a node at index i has children at 2i+1 and 2i+2), builds a
 max-heap out of the whole array, then repeatedly swaps the root (the
 current largest value) with the last unsorted element and re-heapifies
 the shrinking heap.
  No pointers or node objects needed: the parent/child relationship is
 entirely arithmetic on array indices, which is why heapsort is one of
 the few classic tree-based algorithms that translates directly into
 JSOL's array-only data model.
  O(n log n) in every case, and unlike merge-sort.jsol.js, sorts in place
 with no extra array needed.

@param {array<number>} $aValues - Numbers to sort.
@returns {array<number>} - A new array with the same numbers in ascending order.
*/

/**
 @contract
 {
   "cases": [
     { "$aValues": [5, 2, 9, 1, 5, 6] },
     { "$aValues": [] }
   ]
 }
*/

const $aSiftDown = function($aValues, $qHeapSize, $qRoot) {
  // JSOL.use: Explicitly binds self-reference for recursive closure execution across target runtimes.
    

    let $qLargest = $qRoot;
    const $qLeftChild = (2 * $qRoot) + 1;
    const $qRightChild = (2 * $qRoot) + 2;

    if ($qLeftChild < $qHeapSize && $aValues[$qLeftChild] > $aValues[$qLargest]) {
    $qLargest = $qLeftChild;
  }
  if ($qRightChild < $qHeapSize && $aValues[$qRightChild] > $aValues[$qLargest]) {
    $qLargest = $qRightChild;
  }
  if ($qLargest !== $qRoot) {
    const $nTemp = $aValues[$qRoot];
        $aValues[$qRoot] = $aValues[$qLargest];
        $aValues[$qLargest] = $nTemp;
        
        // Cross-Engine Parity Note: Array reassignment guarantees that in-place mutations persist
        // on target runtimes where arrays are passed by value (e.g., PHP) vs by reference (e.g., JS/TS).
        $aValues = $aSiftDown($aValues, $qHeapSize, $qLargest);
  }
  return $aValues;
};
const $aHeapSort = function($aValues) {
  // JSOL.use: Injects helper functions into closure scope for isolated target runtimes.
    

    let $aSorted = $aValues.slice( 0,  $aValues.length);
    const $qLen = $aSorted.length;

    // Build the max-heap: sift down every non-leaf node, from the last one back to the root.
    for (let $qI = Math.floor($qLen / 2) - 1; $qI >= 0; $qI = $qI - 1) {
    // Capture returned array to ensure mutation persistence across value-type array engines.
        $aSorted = $aSiftDown($aSorted, $qLen, $qI);
  }
  // Repeatedly move current max (root) to the end of unsorted region, then re-heapify.
    for (let $qEnd = $qLen - 1; $qEnd > 0; $qEnd = $qEnd - 1) {
    const $nTemp = $aSorted[0];
        $aSorted[0] = $aSorted[$qEnd];
        $aSorted[$qEnd] = $nTemp;
        
        // Capture returned array to ensure mutation persistence across value-type array engines.
        $aSorted = $aSiftDown($aSorted, $qEnd, 0);
  }
  return $aSorted;
};
window['$aSiftDown'] = $aSiftDown;
<?php
// @JSOL v0.2.94

/**
 @description
 Sorts an array of numbers into ascending order using heapsort (CLRS
 chapter 6): treats the array as a binary heap using standard implicit
 indexing (a node at index i has children at 2i+1 and 2i+2), builds a
 max-heap out of the whole array, then repeatedly swaps the root (the
 current largest value) with the last unsorted element and re-heapifies
 the shrinking heap.
  No pointers or node objects needed: the parent/child relationship is
 entirely arithmetic on array indices, which is why heapsort is one of
 the few classic tree-based algorithms that translates directly into
 JSOL's array-only data model.
  O(n log n) in every case, and unlike merge-sort.jsol.js, sorts in place
 with no extra array needed.

@param {array<number>} $aValues - Numbers to sort.
@returns {array<number>} - A new array with the same numbers in ascending order.
*/

/**
 @contract
 {
   "cases": [
     { "$aValues": [5, 2, 9, 1, 5, 6] },
     { "$aValues": [] }
   ]
 }
*/

$aSiftDown = function($aValues, $qHeapSize, $qRoot) use (&$aSiftDown) {
  $qLargest = $qRoot;
    $qLeftChild = (2 * $qRoot) + 1;
    $qRightChild = (2 * $qRoot) + 2;

    if ($qLeftChild < $qHeapSize && $aValues[$qLeftChild] > $aValues[$qLargest]) {
    $qLargest = $qLeftChild;
  }
  if ($qRightChild < $qHeapSize && $aValues[$qRightChild] > $aValues[$qLargest]) {
    $qLargest = $qRightChild;
  }
  if ($qLargest !== $qRoot) {
    $nTemp = $aValues[$qRoot];
        $aValues[$qRoot] = $aValues[$qLargest];
        $aValues[$qLargest] = $nTemp;
        
        // Cross-Engine Parity Note: Array reassignment guarantees that in-place mutations persist
        // on target runtimes where arrays are passed by value (e.g., PHP) vs by reference (e.g., JS/TS).
        $aValues = $aSiftDown($aValues, $qHeapSize, $qLargest);
  }
  return $aValues;
};
$aHeapSort = function($aValues) use (&$aSiftDown) {
  $aSorted = array_slice($aValues,  0,  count($aValues));
    $qLen = count($aSorted);

    // Build the max-heap: sift down every non-leaf node, from the last one back to the root.
    for ($qI = floor($qLen / 2) - 1; $qI >= 0; $qI = $qI - 1) {
    // Capture returned array to ensure mutation persistence across value-type array engines.
        $aSorted = $aSiftDown($aSorted, $qLen, $qI);
  }
  // Repeatedly move current max (root) to the end of unsorted region, then re-heapify.
    for ($qEnd = $qLen - 1; $qEnd > 0; $qEnd = $qEnd - 1) {
    $nTemp = $aSorted[0];
        $aSorted[0] = $aSorted[$qEnd];
        $aSorted[$qEnd] = $nTemp;
        
        // Capture returned array to ensure mutation persistence across value-type array engines.
        $aSorted = $aSiftDown($aSorted, $qEnd, 0);
  }
  return $aSorted;
};
declare var JSOL: any;
declare var Rgx: any;

// @JSOL v0.2.94

/**
 @description
 Sorts an array of numbers into ascending order using heapsort (CLRS
 chapter 6): treats the array as a binary heap using standard implicit
 indexing (a node at index i has children at 2i+1 and 2i+2), builds a
 max-heap out of the whole array, then repeatedly swaps the root (the
 current largest value) with the last unsorted element and re-heapifies
 the shrinking heap.
  No pointers or node objects needed: the parent/child relationship is
 entirely arithmetic on array indices, which is why heapsort is one of
 the few classic tree-based algorithms that translates directly into
 JSOL's array-only data model.
  O(n log n) in every case, and unlike merge-sort.jsol.js, sorts in place
 with no extra array needed.

@param {array<number>} $aValues - Numbers to sort.
@returns {array<number>} - A new array with the same numbers in ascending order.
*/

/**
 @contract
 {
   "cases": [
     { "$aValues": [5, 2, 9, 1, 5, 6] },
     { "$aValues": [] }
   ]
 }
*/

const $aSiftDown = function($aValues: any, $qHeapSize: any, $qRoot: any): any[] {
  // JSOL.use: Explicitly binds self-reference for recursive closure execution across target runtimes.
    

    let $qLargest: number = $qRoot;
    const $qLeftChild: number = (2 * $qRoot) + 1;
    const $qRightChild: number = (2 * $qRoot) + 2;

    if ($qLeftChild < $qHeapSize && $aValues[$qLeftChild] > $aValues[$qLargest]) {
    $qLargest = $qLeftChild;
  }
  if ($qRightChild < $qHeapSize && $aValues[$qRightChild] > $aValues[$qLargest]) {
    $qLargest = $qRightChild;
  }
  if ($qLargest !== $qRoot) {
    const $nTemp: number = $aValues[$qRoot];
        $aValues[$qRoot] = $aValues[$qLargest];
        $aValues[$qLargest] = $nTemp;
        
        // Cross-Engine Parity Note: Array reassignment guarantees that in-place mutations persist
        // on target runtimes where arrays are passed by value (e.g., PHP) vs by reference (e.g., JS/TS).
        $aValues = $aSiftDown($aValues, $qHeapSize, $qLargest);
  }
  return $aValues;
};
const $aHeapSort = function($aValues: any): any[] {
  // JSOL.use: Injects helper functions into closure scope for isolated target runtimes.
    

    let $aSorted: any[] = $aValues.slice( 0,  $aValues.length);
    const $qLen: number = $aSorted.length;

    // Build the max-heap: sift down every non-leaf node, from the last one back to the root.
    for (let $qI = Math.floor($qLen / 2) - 1; $qI >= 0; $qI = $qI - 1) {
    // Capture returned array to ensure mutation persistence across value-type array engines.
        $aSorted = $aSiftDown($aSorted, $qLen, $qI);
  }
  // Repeatedly move current max (root) to the end of unsorted region, then re-heapify.
    for (let $qEnd = $qLen - 1; $qEnd > 0; $qEnd = $qEnd - 1) {
    const $nTemp: number = $aSorted[0];
        $aSorted[0] = $aSorted[$qEnd];
        $aSorted[$qEnd] = $nTemp;
        
        // Capture returned array to ensure mutation persistence across value-type array engines.
        $aSorted = $aSiftDown($aSorted, $qEnd, 0);
  }
  return $aSorted;
};
import math
from jsol_core import JSOL

# @JSOL v0.2.94

#*
# @description
# Sorts an array of numbers into ascending order using heapsort (CLRS
# chapter 6): treats the array as a binary heap using standard implicit
# indexing (a node at index i has children at 2i+1 and 2i+2), builds a
# max-heap out of the whole array, then repeatedly swaps the root (the
# current largest value) with the last unsorted element and re-heapifies
# the shrinking heap.
#  No pointers or node objects needed: the parent/child relationship is
# entirely arithmetic on array indices, which is why heapsort is one of
# the few classic tree-based algorithms that translates directly into
# JSOL's array-only data model.
#  O(n log n) in every case, and unlike merge-sort.jsol.js, sorts in place
# with no extra array needed.
#
#@param {array<number>} $aValues - Numbers to sort.
#@returns {array<number>} - A new array with the same numbers in ascending order.
#

#*
# @contract
# {
#   "cases": [
#     { "$aValues": [5, 2, 9, 1, 5, 6] },
#     { "$aValues": [] }
#   ]
# }
#

def aSiftDown(aValues, qHeapSize, qRoot): 

  # JSOL.use: Explicitly binds self-reference for recursive closure execution across target runtimes.


  qLargest = qRoot;
  qLeftChild = (2 * qRoot) + 1;
  qRightChild = (2 * qRoot) + 2;

  if qLeftChild < qHeapSize and aValues[qLeftChild] > aValues[qLargest]: 

    qLargest = qLeftChild;


  if qRightChild < qHeapSize and aValues[qRightChild] > aValues[qLargest]: 

    qLargest = qRightChild;


  if qLargest != qRoot: 

    nTemp = aValues[qRoot];
    aValues[qRoot] = aValues[qLargest];
    aValues[qLargest] = nTemp;

    # Cross-Engine Parity Note: Array reassignment guarantees that in-place mutations persist
    # on target runtimes where arrays are passed by value (e.g., PHP) vs by reference (e.g., JS/TS).
    aValues = aSiftDown(aValues, qHeapSize, qLargest);


  return aValues;


def aHeapSort(aValues): 

  # JSOL.use: Injects helper functions into closure scope for isolated target runtimes.


  aSorted = aValues[ 0: len(aValues)];
  qLen = len(aSorted);

  # Build the max-heap: sift down every non-leaf node, from the last one back to the root.
  qI = math.floor(qLen / 2) - 1;
  while qI >= 0: 

    # Capture returned array to ensure mutation persistence across value-type array engines.
    aSorted = aSiftDown(aSorted, qLen, qI);

    qI = qI - 1;


  # Repeatedly move current max (root) to the end of unsorted region, then re-heapify.
  qEnd = qLen - 1;
  while qEnd > 0: 

    nTemp = aSorted[0];
    aSorted[0] = aSorted[qEnd];
    aSorted[qEnd] = nTemp;

    # Capture returned array to ensure mutation persistence across value-type array engines.
    aSorted = aSiftDown(aSorted, qEnd, 0);

    qEnd = qEnd - 1;


  return aSorted;


Each example started as a test.

The language and compiler improved because of what these examples demanded. The CLRS examples are here for the same reason: if JSOL aims to be a language someone can read rather than just compile, it has to survive contact with computer science, not just invoicing.

💳

Strict Validation

Luhn, IBAN, CUIT, ISBN-13. Checksum algorithms that have to produce the exact same result in the browser and on the server: the exact scenario where a divergent implementation means a rejected payment or a failed compliance check.
📈

Finance & Rules

Loan amortization, progressive tax tiers, stacked discounts, shipping rate matrices. Rules that change when the business changes, and that silently produce wrong invoices when the frontend and backend disagree.
🧮

Computer Science

Dynamic Programming vs. Greedy (Coin Change), searching algorithms, sorting algorithms, Caesar/Rot13 ciphers, Sieve of Eratosthenes. Executable pseudocode that compiles and runs, not just sits in a textbook.

What JSOL is NOT

JSOL is not a full-stack framework, and it's not a general-purpose language. It is an isolated, pure, synchronous calculator. It doesn't touch the DOM, it doesn't make network requests (no fetch or Async), and it doesn't talk to databases.

Every alternative to JSOL (like Haxe or WebAssembly) buys generality or performance at the cost of requiring a toolchain. JSOL buys zero-toolchain portability by aggressively restricting what you can write.


The Honest Tradeoffs (Where JSOL is worse)

JSOL costs more to write than a native implementation. These are the engine-level restrictions you accept when using it:

Feature Native JS / PHP JSOL Why it was stripped
Developer Speed Fast (Syntactic sugar, functional methods) Slower (Spartan syntax, mandatory imperative loops) Functional arrays and sugar don't map 1:1 across engines without AST pipelines.
Control Flow Async, Promises, Threads Strictly Synchronous (Single-thread blocking) Async control flow has no shared syntax between JS and PHP.
State & OOP Classes, this, Prototypes Flat Dicts & Primitives (Higher GC pressure) Classes diverge wildly. Forbidding them guarantees O(1) property access but forces state copying for large loops.
Text Parsing Native Regex (PCRE / V8) Procedural loops only (No native regex) Regex engines differ. Complex patterns can cause ReDoS in one engine but not another.

Design Pillars

Four principles shape every rule in the specification.

1. Clarity

A JSOL algorithm has to be readable by the person who owns the business logic, not just by a compiler.

This is also why JSOL doesn't standardize how you structure code (nested functions vs. flat scope, for instance) — that's implementation shape, not business logic.

2. Portability

The same source runs correctly on every proven target.

This is where Deterministic Parity comes from: given identical inputs, every target's output has to match, bit for bit.

3. Performance

The compiled output should be no heavier and no slower than it has to be.

This is where Zero Dead Code comes from: nothing gets shipped that a given file doesn't actually use.

4. Developer Experience

Writing, compiling, and debugging JSOL should be as frictionless as the constraints allow.

This is where the AST-free compiler pipeline and Zero Runtime Dependencies come from.

This is an open problem, not a finished product

JSOL works today for JavaScript, PHP, TypeScript and Python. The compiler is self-hosting (i.e., it compiles itself) and the fixed-point convergence tests prove that the output is stable across generations and hosts. But the really interesting work is what comes next.

The project's real bet is that the same approach can extend to other targets. TypeScript, Go, C#, Python, Rust, C: each one is a separate compiler backend, and each one teaches you something different about what "portable business logic" actually requires.

If you're a CS educator or student, EXTENDING.md lays out the feasibility matrix, the JSOL-C leverage effect, and the specific compiler design problems involved.

Fork it. Break it. Build a target. The compiler architecture is deliberately modular: adding a language means writing one compiler file, not rewriting the core.