# Comparing C and OCaml Implementations ## Quick Comparison To verify that the OCaml jam/cue implementation produces identical output to the C implementation: ```bash ./compare_jam.sh ``` This script: 1. Builds and runs the C comparison program (`zig build jam-compare`) 2. Runs the OCaml comparison program (`dune exec test/jam_compare.exe`) 3. Compares the hex outputs byte-by-byte ## Manual Comparison ### C Side ```bash cd vere zig build jam-compare ``` ### OCaml Side ```bash cd ocaml dune exec test/jam_compare.exe ``` Both programs output the jam encoding (in hex) for the same set of test nouns: - Simple atoms: 0, 1, 2, 42, 255, 256 - Simple cells: [1 2], [0 0], [42 43] - Nested cells: [[1 2] 3], [1 [2 3]] - Trees: [[1 2] [3 4]], [[[1 2] [3 4]] [[5 6] [7 8]]] ## Example Output ``` 0: 02 1: 0c 2: 48 42: 5015 255: 20fe01 256: 600002 [1 2]: 3112 [0 0]: 29 [42 43]: 4155e80a [[1 2] 3]: c54834 [1 [2 3]]: 714834 [[1 2] [3 4]]: c5c8d098 [[[1 2] [3 4]] [[5 6] [7 8]]]: 15234363162e76f81004 ``` ## Verification ✅ The C and OCaml implementations produce **identical byte-for-byte** output for all test cases. This confirms that the OCaml implementation is a correct port of the C jam/cue serialization.