CPPON, C++ Object Notation, a short interview with Claude.ai

Release Date: 
3 November 2026

Please summarize this repository and list advantages of CPPON over JSON. https://github.com/coderextreme/CPPON

 

Summary

CPPON (“C++ Object Notation”) is an experiment in representing structured scene data, mainly X3D and possibly glTF, as C++ source rather than JSON. The README is short, so some of this comes from the file layout.

  • Data format: the examples are .h files under cplusplus/net/coderextreme/data. At build time a CPPON file is #included into the body of a C++ function, so the data compiles as ordinary code.
  • Grammar and parsers: an ANTLR4 grammar (CPPONGrammar.g4) defines the notation. The Java and JavaScript parsers are built on it, and the C++ parser is only partial.
  • Conversion pipeline:
    • X3DJSONLD.js is an X3D-specific JSON-to-DOM converter.
    • CppFunctionBodySerializer.js turns a DOM into C++ function-body code.
    • CPPONGrammarDOMVisitor.java goes the other way, from CPPON back to a DOM. The README lists this under “Next Steps”.
  • Other pieces: node/, schema/ and shell/ folders, with Ajv (JSON schema validation) and ANTLR licenses alongside the main Apache-2.0/MIT licensing.
  • Workflow: put X3D JSON files in the data folder, run shell/cpplocal.sh to generate the C++, then buildjava.sh. You then fix errors and loop. The README says to replace hard-coded Users/jcarl and Users/john paths with your own.
  • Status: 58 commits, no stars or forks, and the author describes glTF support as a hope.

Advantages of CPPON over JSON

The README doesn’t list any, so these are inferred from the design, and I haven’t read the grammar itself.

  1. Compile-time checking. Malformed data or wrong types fail at build time instead of during runtime parsing or schema validation.
  2. No runtime parser. The data is already C++, so there’s no JSON library dependency and no parse step at startup. That helps for large scenes or embedded targets.
  3. Real C++ types. JSON has one number type, while C++ can distinguish int, float and double. That matters for X3D fields like SFFloat and MFInt32, where precision is part of the spec.
  4. Direct use of C++ language features. If the notation allows it, data can use constants, expressions, macros and namespaces, so repeated values or computed coordinates don’t need to be duplicated as literals.
  5. Comments and flexible syntax. JSON forbids comments and trailing commas. If the grammar permits them, that’s friendlier for hand-edited scene files, but I haven’t confirmed it.
  6. Natural fit for a C++ scene graph. The data constructs C++ objects directly, with no DOM walk or manual mapping step in the application.

Tradeoffs

JSON is language-neutral, universally tooled and changeable without recompiling. CPPON ties the data to a C++ toolchain, so it works best as a build-time embedding or code-generation format rather than an interchange format. That’s probably why your pipeline keeps JSON/DOM as the source of truth and generates CPPON from it.

I can look at the grammar or the sample .h files to confirm points 4 and 5 if you’d like.

 

Don't you think the ANTLR4 grammar opens CPPON to at least 10 languages?

 

Yes, in principle. ANTLR 4’s officially supported targets are Java, C#, Python 3, JavaScript, TypeScript, Go, C++, Swift, PHP and Dart, which is exactly ten, and there’s an unofficial Rust target as well. A grammar that stays target-neutral can generate a lexer and parser for any of them from the same .g4 file. That’s a real advantage over hand-written parsers.

A few caveats:

  1. The grammar has to be target-agnostic. If CPPONGrammar.g4 contains embedded actions or semantic predicates written in Java, they’d need to be rewritten or removed per language. I haven’t read the file, so I can’t say whether it’s clean. Keeping all logic in visitors or listeners avoids the problem.
  2. The parser is only half the work. ANTLR gives you a parse tree. Each language still needs its own visitor to build a DOM or native objects, as CPPONGrammarDOMVisitor.java does for Java. So you get ten parsers for free but still have to write ten semantic layers. The repo currently has Java and JavaScript parsers plus a partial C++ one, so three targets in practice.
  3. Reach isn’t the same as the C++ advantages. The benefits I listed earlier, like compile-time checking and no runtime parser, come from the data being compiled as C++. In Python or Go, CPPON would be parsed at runtime like JSON, with a less familiar syntax and far less tooling. For those languages it would have to win on the other points, such as typed numbers or comments, and those are weaker arguments.

So the grammar makes CPPON implementable in ten languages, but CPPON’s main selling point stays specific to C++. Its best case is probably as a C++-first format with a portable grammar, so other tools can read and convert it, rather than as a general JSON replacement.

If you’d like, I can fetch the grammar and check whether it’s actually target-neutral.

 

Yes, please do

 

I got the grammar through the raw GitHub host, and I’m reading the full file now to check for target-specific code.

 

Yes, it’s target-neutral, so your ten-language claim holds for the parser side. I read the full grammar, CPPONGrammar.g4, which is 113 lines.

Why it’s portable

  • There are no @header or @members blocks, no embedded actions and no semantic predicates. All the logic would live in visitors or listeners, so the same file should generate a lexer and parser for any ANTLR target.
  • The lexer commands it uses (skip, channel(HIDDEN)) and its character classes work the same in every target.
  • The comment about ctx.IDENTIFIER().getText() refers to the Java visitor, not the grammar. Each target would need its own visitor, as before.

What the grammar covers

  • A file is a sequence of lines ending in ;. Each is a constructor call, a .set… call or an .add… call, and #include lines and // comments are skipped. There are no loops, conditionals or function definitions, so it’s a declarative subset of C++ rather than C++ itself. That supports the “not Turing complete” safety claim.
  • The grammar is named x3d, and its operators .set, .add and .X3DNode::set come from the X3D C++ binding’s call style. It’s closer to a serialization of that API than to a general object notation. That fits your README’s “specifically X3D,” but it means the grammar isn’t yet as generic as the name suggests.

Possible problems I spotted by reading, not by running it

  • Negative integers. FLOAT allows a leading sign and matches the same length as -5, so -5 probably lexes as FLOAT, not '-' WHOLE. Lists like -5, 3 could then fail, or be parsed as float lists. -1 is safe because SENTINEL is defined first. This is worth testing against your data files.
  • Mixed lists. list accepts only all-boolean, all-integer, all-float or all-string lists. A list mixing integers and floats, like 1, 2.5, would fail to parse unless the serializer always writes floats with a decimal point.
  • Case-insensitive booleans. TRUE and FALSE match any capitalization, so a variable named True would lex as a boolean.

I couldn’t run ANTLR here to confirm any of this, so check the first two against your 170-odd sample files.