Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Cross-language benchmark suite

This benchmark compares **Coderive** against:
This benchmark compares:

- Java
- C
- C++
- Rust
- Python

The Coderive benchmark now lives in `src/main/cod/demo/src/main/test/loop/BMark.cod`.

## Workload

Each implementation runs the same deterministic kernels:
Expand Down
10 changes: 3 additions & 7 deletions benchmarks/run_cross_language_benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ echo "Expected checksum: ${EXPECTED_CHECKSUM}"
echo

# Build Coderive runtime for benchmark execution.
echo "[setup] compiling Coderive Java runtime..."
rm -rf "$WORK_DIR/coderive-java" "$WORK_DIR/java-bin" "$WORK_DIR/c-bin" "$WORK_DIR/cpp-bin" "$WORK_DIR/rust-bin"
mkdir -p "$WORK_DIR/coderive-java" "$WORK_DIR/java-bin"
javac -d "$WORK_DIR/coderive-java" $(find "$ROOT_DIR/src/main/java" -name '*.java')
echo "[setup] compiling benchmark binaries..."
rm -rf "$WORK_DIR/java-bin" "$WORK_DIR/c-bin" "$WORK_DIR/cpp-bin" "$WORK_DIR/rust-bin"
mkdir -p "$WORK_DIR/java-bin"

# Build language-specific binaries where toolchains exist.
if has_cmd javac; then
Expand Down Expand Up @@ -105,9 +104,6 @@ echo
echo "Language | Median ms"
echo "---------|----------"

run_many "Coderive" env COD_BENCHMARK_MODE=true java -cp "$WORK_DIR/coderive-java" cod.runner.CommandRunner \
"$BENCH_DIR/coderive/CrossLanguageBenchmark.cod" --quiet | awk -F'|' '{printf "%-8s | %s\n", $1, $2}'

if [[ -f "$WORK_DIR/java-bin/CrossLanguageBenchmark.class" ]]; then
run_many "Java" java -cp "$WORK_DIR/java-bin" CrossLanguageBenchmark | awk -F'|' '{printf "%-8s | %s\n", $1, $2}'
fi
Expand Down
28 changes: 28 additions & 0 deletions drafts/Changelog-0.9.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Changelog Draft

## [v0.9.6] - Runtime & Benchmark Consolidation - 2026-05-01

### ⚙️ Lexer & Parser Architecture
- Introduced `CharClassifier` and `LexerSource` to centralize fast ASCII classification and lexer state access.
- Reworked `MainLexer` to use zero-allocation skipping for whitespace/comments and streamlined token creation.
- Updated lexer components (comment/identifier/number/string/symbol/whitespace) and parser contexts for more consistent token flow and error handling.
- Added lexer aliases so `continue` maps to `skip` and `return` maps to `exit` in `.cod` sources.

### 🧠 Interpreter & Runtime Refactor
- Split loop/array/lambda behavior into dedicated handlers (`LoopHandler`, `ArrayHandler`, `LambdaHandler`) and simplified loop decision paths.
- Added `Exit` AST node and refreshed interpreter visit logic around early exits, loop flow, and tail-call handling.
- Refined execution context, literal registry integration, and method/slot invocation flow for improved consistency.

### 📦 Range & Formula System Updates
- Added unified `AccumulationFormula` + `AccumulationPattern` to cover flat/nested sums and recurrence variants.
- Removed legacy recurrence formula classes and refreshed `NaturalArray`/pattern handling to use the new accumulation path.

### 🧩 Standard Library & Demo Coverage
- JSON standard library improvements: streamlined object access loops, expanded escape handling (`\b`, `\f`), and simplified Unicode hex formatting.
- SciMath loops updated with safer continue-style early exits in statistical helpers.
- Demo refreshes across control flow, lazy loop, recurrence, and JSON coverage.
- Added `BMark.cod` benchmark in loop tests plus a new `BigNumTest` Java test scaffold.

### 🧪 Benchmarks
- Coderive cross-language benchmark moved into `src/main/cod/demo/src/main/test/loop/BMark.cod`.
- Cross-language benchmark script now measures non-Coderive toolchains only.
6 changes: 0 additions & 6 deletions src/main/cod/demo/src/idx/sample.toml

This file was deleted.

6 changes: 3 additions & 3 deletions src/main/cod/demo/src/main/test/controlflow/ControlFlow.cod
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ share ControlFlow {

out("sum=" + sum)

out("fin:before")
fin
out("fin:after-should-not-print")
out("exit:before")
exit
out("exit:after-should-not-print")
}
}
2 changes: 0 additions & 2 deletions src/main/cod/demo/src/main/test/helloworld/HelloWorld.cod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
unit test.helloworld (main: this)

out("Hello World!")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ share JsonStandardLibraryComprehensive {
share check(label: text, actual: text, expected: text) {
if actual == expected {
out("PASS " + label)
fin
return
}
out("FAIL " + label)
out(" actual: " + actual)
Expand All @@ -16,7 +16,7 @@ share JsonStandardLibraryComprehensive {
share checkBool(label: text, actual: bool, expected: bool) {
if actual == expected {
out("PASS " + label)
fin
return
}
out("FAIL " + label)
out(" actual: " + actual)
Expand Down Expand Up @@ -49,20 +49,16 @@ share JsonStandardLibraryComprehensive {
mixedArray := Json.parse("[1, true, null, \"x\", [2,3]]")
JsonStandardLibraryComprehensive.checkBool("array kind", mixedArray.isArray(), true)
JsonStandardLibraryComprehensive.check("array size", "" + mixedArray.size(), "5")
nestedArray := mixedArray.get(4)
JsonStandardLibraryComprehensive.checkBool("array nested kind", nestedArray.isArray(), true)
nestedValue := nestedArray.get(1)
JsonStandardLibraryComprehensive.check("array nested value", nestedValue.asNumberText(), "3")
JsonStandardLibraryComprehensive.checkBool("array nested kind", mixedArray.get(4).isArray(), true)
JsonStandardLibraryComprehensive.check("array nested value", mixedArray.get(4).get(1).asNumberText(), "3")

objectValue := Json.parse("\{\"name\":\"Coderive\",\"ok\":true,\"n\":10,\"tags\":[\"lang\",\"json\"],\"meta\":\{\"major\":0\}\}")
JsonStandardLibraryComprehensive.checkBool("object kind", objectValue.isObject(), true)
JsonStandardLibraryComprehensive.checkBool("object has name", objectValue.has("name"), true)
JsonStandardLibraryComprehensive.check("object name", objectValue.getKey("name").asText(), "Coderive")
JsonStandardLibraryComprehensive.checkBool("object ok", objectValue.getKey("ok").asBool(), true)
tagsValue := objectValue.getKey("tags")
JsonStandardLibraryComprehensive.check("object nested array value", tagsValue.get(1).asText(), "json")
metaValue := objectValue.getKey("meta")
JsonStandardLibraryComprehensive.check("object nested object value", metaValue.getKey("major").asNumberText(), "0")
JsonStandardLibraryComprehensive.check("object nested array value", objectValue.getKey("tags").get(1).asText(), "json")
JsonStandardLibraryComprehensive.check("object nested object value", objectValue.getKey("meta").getKey("major").asNumberText(), "0")

compact := Json.serialize(objectValue)
JsonStandardLibraryComprehensive.check("compact serialize", compact, "\{\"name\":\"Coderive\",\"ok\":true,\"n\":10,\"tags\":[\"lang\",\"json\"],\"meta\":\{\"major\":0\}\}")
Expand Down
3 changes: 0 additions & 3 deletions src/main/cod/demo/src/main/test/lazyloop/LazyLoop.cod
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ b := arrB[100] == 300
c := arrA[600] == 600
d := arrB[600] == 1200


// Error tho. Interpolation doesnt handle this yet.
// Verify:
out("arrA[100] == 200 is {a}") // Should be true
out("arrB[100] == 300 is {b}") // Should be true
out("arrA[600] == 600 is {c}") // Should be true
Expand Down
Loading