Meet JSON's functional half-brother.
A Single-source-of-truth (SSOT) for keeping business logic up to date and giving the same results on different codebases (e.g. front & backend).
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. And that's just one bug that slipped through code review.
The ugliest common denominator
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. Also, think dumb and ugly: the foundation was to find an economical point where C-like languages "naturally" meet, to the point an AST was not even needed. That lowest common denominator is usually PHP.
| Case | JS | PHP | Python |
|---|---|---|---|
| 7.5 % 2 | 1.5 | 1 | 1.5 |
| Math.round(2.5) | 3 | 3 | 2 |
| Math.round(-2.5) | -2 | -3 | -2 |
| "😀".length | 2 | 4 | 1 |
| String(true) | true | 1 | True |
| "12abc" as int | 12 | 12 | ValueError |
| "12abc" as int | 12 | 12 | ValueError |
| "10" < "9" | true | false | true |
| [10, 1, 2].sort() | 1, 10, 2 | 1, 2, 10 | 1, 2, 10 |
| "abc".split("") | a,b,c | a,b,c | ValueError |
| "a" || "b" | a | true | a |
| min(NaN, 5) | NaN | 5 | nan |
| [].pop() | undefined | null | IndexError |
| "" as number | 0 | 0 | ValueError |
Every language behaves slightly differently. When maintaining business rules across several of them, it's a disaster waiting to happen. JSOL is being developed to give the same canonical answer on every target, considering more than 140 semantic differences to sort out.
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.
(INPUT)
(OUTPUT)
Function: $sBuildNotice
// @JSOL v0.2.97
/**
Test: literal string replacement must never reinterpret special
tokens inside the replacement value.
Naive JavaScript, verified:
```js
function buildNotice(template, placeholder, replacement) {
return template.replace(placeholder, replacement);
}
buildNotice("Total a pagar: MONTO", "MONTO", "$&");
// -> "Total a pagar: MONTO"
// Looks like nothing happened. It didn't insert "$&" literally, it
// re-inserted the matched text ("MONTO") in its place. If "$&" was
// meant to be a literal reference code, it silently vanished.
```
Naive PHP, verified against documented behavior (str_replace is a
byte-for-byte literal operation, no meta-characters):
```php
function buildNotice($template, $placeholder, $replacement) {
return str_replace($placeholder, $replacement, $template);
}
buildNotice("Total a pagar: MONTO", "MONTO", "$&");
// -> "Total a pagar: $&" (correct, PHP has nothing to fix here)
```
Naive Python, same story as PHP (str.replace is always literal):
```python
def build_notice(template, placeholder, replacement):
return template.replace(placeholder, replacement)
build_notice("Total a pagar: MONTO", "MONTO", "$&")
# -> "Total a pagar: $&" (correct, Python has nothing to fix here)
```
Only one of the three targets is broken, and it is broken silently,
which is worse than a crash: the output still reads as plausible
text. JSOL's Str.replaceAll must compile to something on the JS side
that is immune to this (split+join instead of native replace, for
example) so the source line means the same thing everywhere without
the author needing to know this is a JS-only footgun.
*/
/**
@contract
{
"cases": [
{
"in": { "$sTemplate": "Total a pagar: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$&" },
"expect": "Total a pagar: $&"
},
{
"in": { "$sTemplate": "Saldo anterior: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$100.000" },
"expect": "Saldo anterior: $100.000"
},
{
"in": { "$sTemplate": "Referencia: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$$$$" },
"expect": "Referencia: $$$$"
}
]
}
*/
const $sBuildNotice = function($sTemplate, $sPlaceholder, $sReplacement) {
return Str.replaceAll($sTemplate, $sPlaceholder, $sReplacement);
};
// @JSOL v0.2.97
/**
Test: literal string replacement must never reinterpret special
tokens inside the replacement value.
Naive JavaScript, verified:
```js
function buildNotice(template, placeholder, replacement) {
return template.replace(placeholder, replacement);
}
buildNotice("Total a pagar: MONTO", "MONTO", "$&");
// -> "Total a pagar: MONTO"
// Looks like nothing happened. It didn't insert "$&" literally, it
// re-inserted the matched text ("MONTO") in its place. If "$&" was
// meant to be a literal reference code, it silently vanished.
```
Naive PHP, verified against documented behavior (str_replace is a
byte-for-byte literal operation, no meta-characters):
```php
function buildNotice($template, $placeholder, $replacement) {
return str_replace($placeholder, $replacement, $template);
}
buildNotice("Total a pagar: MONTO", "MONTO", "$&");
// -> "Total a pagar: $&" (correct, PHP has nothing to fix here)
```
Naive Python, same story as PHP (str.replace is always literal):
```python
def build_notice(template, placeholder, replacement):
return template.replace(placeholder, replacement)
build_notice("Total a pagar: MONTO", "MONTO", "$&")
# -> "Total a pagar: $&" (correct, Python has nothing to fix here)
```
Only one of the three targets is broken, and it is broken silently,
which is worse than a crash: the output still reads as plausible
text. JSOL's Str.replaceAll must compile to something on the JS side
that is immune to this (split+join instead of native replace, for
example) so the source line means the same thing everywhere without
the author needing to know this is a JS-only footgun.
*/
/**
@contract
{
"cases": [
{
"in": { "$sTemplate": "Total a pagar: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$&" },
"expect": "Total a pagar: $&"
},
{
"in": { "$sTemplate": "Saldo anterior: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$100.000" },
"expect": "Saldo anterior: $100.000"
},
{
"in": { "$sTemplate": "Referencia: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$$$$" },
"expect": "Referencia: $$$$"
}
]
}
*/
const $sBuildNotice = function($sTemplate, $sPlaceholder, $sReplacement) {
return $sTemplate.split( $sPlaceholder).join( $sReplacement);
};
window['$sBuildNotice'] = $sBuildNotice;
<?php
// @JSOL v0.2.97
/**
Test: literal string replacement must never reinterpret special
tokens inside the replacement value.
Naive JavaScript, verified:
```js
function buildNotice(template, placeholder, replacement) {
return template.replace(placeholder, replacement);
}
buildNotice("Total a pagar: MONTO", "MONTO", "$&");
// -> "Total a pagar: MONTO"
// Looks like nothing happened. It didn't insert "$&" literally, it
// re-inserted the matched text ("MONTO") in its place. If "$&" was
// meant to be a literal reference code, it silently vanished.
```
Naive PHP, verified against documented behavior (str_replace is a
byte-for-byte literal operation, no meta-characters):
```php
function buildNotice($template, $placeholder, $replacement) {
return str_replace($placeholder, $replacement, $template);
}
buildNotice("Total a pagar: MONTO", "MONTO", "$&");
// -> "Total a pagar: $&" (correct, PHP has nothing to fix here)
```
Naive Python, same story as PHP (str.replace is always literal):
```python
def build_notice(template, placeholder, replacement):
return template.replace(placeholder, replacement)
build_notice("Total a pagar: MONTO", "MONTO", "$&")
# -> "Total a pagar: $&" (correct, Python has nothing to fix here)
```
Only one of the three targets is broken, and it is broken silently,
which is worse than a crash: the output still reads as plausible
text. JSOL's Str.replaceAll must compile to something on the JS side
that is immune to this (split+join instead of native replace, for
example) so the source line means the same thing everywhere without
the author needing to know this is a JS-only footgun.
*/
/**
@contract
{
"cases": [
{
"in": { "$sTemplate": "Total a pagar: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$&" },
"expect": "Total a pagar: $&"
},
{
"in": { "$sTemplate": "Saldo anterior: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$100.000" },
"expect": "Saldo anterior: $100.000"
},
{
"in": { "$sTemplate": "Referencia: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$$$$" },
"expect": "Referencia: $$$$"
}
]
}
*/
$sBuildNotice = function($sTemplate, $sPlaceholder, $sReplacement) {
return str_replace( $sPlaceholder, $sReplacement, $sTemplate);
};
declare var JSOL: any;
declare var Rgx: any;
declare var Str: any;
declare var Arr: any;
declare var Bool: any;
declare var Cast: any;
// @JSOL v0.2.97
/**
Test: literal string replacement must never reinterpret special
tokens inside the replacement value.
Naive JavaScript, verified:
```js
function buildNotice(template, placeholder, replacement) {
return template.replace(placeholder, replacement);
}
buildNotice("Total a pagar: MONTO", "MONTO", "$&");
// -> "Total a pagar: MONTO"
// Looks like nothing happened. It didn't insert "$&" literally, it
// re-inserted the matched text ("MONTO") in its place. If "$&" was
// meant to be a literal reference code, it silently vanished.
```
Naive PHP, verified against documented behavior (str_replace is a
byte-for-byte literal operation, no meta-characters):
```php
function buildNotice($template, $placeholder, $replacement) {
return str_replace($placeholder, $replacement, $template);
}
buildNotice("Total a pagar: MONTO", "MONTO", "$&");
// -> "Total a pagar: $&" (correct, PHP has nothing to fix here)
```
Naive Python, same story as PHP (str.replace is always literal):
```python
def build_notice(template, placeholder, replacement):
return template.replace(placeholder, replacement)
build_notice("Total a pagar: MONTO", "MONTO", "$&")
# -> "Total a pagar: $&" (correct, Python has nothing to fix here)
```
Only one of the three targets is broken, and it is broken silently,
which is worse than a crash: the output still reads as plausible
text. JSOL's Str.replaceAll must compile to something on the JS side
that is immune to this (split+join instead of native replace, for
example) so the source line means the same thing everywhere without
the author needing to know this is a JS-only footgun.
*/
/**
@contract
{
"cases": [
{
"in": { "$sTemplate": "Total a pagar: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$&" },
"expect": "Total a pagar: $&"
},
{
"in": { "$sTemplate": "Saldo anterior: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$100.000" },
"expect": "Saldo anterior: $100.000"
},
{
"in": { "$sTemplate": "Referencia: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$$$$" },
"expect": "Referencia: $$$$"
}
]
}
*/
const $sBuildNotice = function($sTemplate: any, $sPlaceholder: any, $sReplacement: any): string {
return $sTemplate.split( $sPlaceholder).join( $sReplacement);
};
import math
import functools
from jsol_core import JSOL
# @JSOL v0.2.97
#*
#Test: literal string replacement must never reinterpret special
#tokens inside the replacement value.
#
#Naive JavaScript, verified:
#
#```js
#function buildNotice(template, placeholder, replacement) {
# return template.replace(placeholder, replacement);
#}
#buildNotice("Total a pagar: MONTO", "MONTO", "$&");
#// -> "Total a pagar: MONTO"
#// Looks like nothing happened. It didn't insert "$&" literally, it
#// re-inserted the matched text ("MONTO") in its place. If "$&" was
#// meant to be a literal reference code, it silently vanished.
#```
#
#Naive PHP, verified against documented behavior (str_replace is a
#byte-for-byte literal operation, no meta-characters):
#
#```php
#function buildNotice($template, $placeholder, $replacement) {
# return str_replace($placeholder, $replacement, $template);
#}
#buildNotice("Total a pagar: MONTO", "MONTO", "$&");
#// -> "Total a pagar: $&" (correct, PHP has nothing to fix here)
#```
#
#Naive Python, same story as PHP (str.replace is always literal):
#
#```python
#def build_notice(template, placeholder, replacement):
# return template.replace(placeholder, replacement)
#
#build_notice("Total a pagar: MONTO", "MONTO", "$&")
## -> "Total a pagar: $&" (correct, Python has nothing to fix here)
#```
#
#Only one of the three targets is broken, and it is broken silently,
#which is worse than a crash: the output still reads as plausible
#text. JSOL's Str.replaceAll must compile to something on the JS side
#that is immune to this (split+join instead of native replace, for
#example) so the source line means the same thing everywhere without
#the author needing to know this is a JS-only footgun.
#
#*
#@contract
#{
# "cases": [
# {
# "in": { "$sTemplate": "Total a pagar: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$&" },
# "expect": "Total a pagar: $&"
# },
# {
# "in": { "$sTemplate": "Saldo anterior: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$100.000" },
# "expect": "Saldo anterior: $100.000"
# },
# {
# "in": { "$sTemplate": "Referencia: MONTO", "$sPlaceholder": "MONTO", "$sReplacement": "$$$$" },
# "expect": "Referencia: $$$$"
# }
# ]
#}
#
def sBuildNotice(sTemplate, sPlaceholder, sReplacement):
return sTemplate.replace( sPlaceholder, sReplacement);
Every example is also a test.
To be released, every JSOL build has to pass every example correctly, with exactly the same results across every supported target. A "minor" change that resulted in a test giving out "8" in JavaScript and "8.0" in PHP? Rejected.
The language and compiler are continuosly improved because of what these 70+ examples demand. 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
Finance & Rules
Computer Science
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 is intentionally worse and slower than writing native code on any single target. It is currently validating its core hypotheses on portability first. These are the engine-level restrictions you accept when using it:
| Feature | Native JS / PHP / Python | JSOL | Why it was stripped |
|---|---|---|---|
| Developer Speed & Syntax | Fast (Syntactic sugar, modern abstractions) | Slower (Dumb, ugly, spartan & strictly constrained) | To eliminate the need for an AST compiler, JSOL severely restricts grammar to flat, lowest-common-denominator patterns. |
| Control Flow | Async, Promises, Threads | Strictly Synchronous (Single-thread blocking) | Async control flow has no shared syntax between JS, PHP, and Python. |
| State & Collections Performance | Classes, this, Reference Passing |
Flat Dicts & Value Semantics (Higher GC pressure) | Forbidding classes guarantees simple $O(1)$ property access, but forces copying for immutability across targets, making JSOL slower on large arrays. |
| Text Parsing | Native Regex (PCRE / V8 / RE2) | Restricted Regex subset & procedural loops | Regex engines differ across runtimes. Complex patterns, lookarounds, and backreferences can cause catastrophic backtracking (ReDoS) in one engine but not another. |
| Floating Point Precision | Native floating-point masking / coercion quirks | Strict IEEE-754 across all targets | For $n, JSOL enforces strict IEEE-754 behavior across all runtimes for predictable standardization. For exact accounting where IEEE-754 is unsuitable, future specs project incorporating other mature, mathematically proven standards. |
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.