🧬 G-Expressions

A Minimal Computational Substrate for AI-Native Programming

"you don't give a dolphin acid and try to teach it to speak english!" - probably nobody

Research Prototype Active Development

What are G-Expressions?

G-Expressions (Generative Expressions) are an experimental approach to representing computation as semantic structures rather than syntax. Instead of text that must be parsed, G-Expressions are JSON structures that are always structurally valid.

This project explores whether computational intent can be separated from execution, making code queryable, verifiable, and transformable in ways traditional languages don't easily support.

{"g": "lit", "v": value} Literal values
{"g": "ref", "v": "name"} References to bound names
{"g": "app", "v": {...}} Function applications
{"g": "vec", "v": [...]} Vectors of G-Expressions

The Hypothesis

These projects test several related ideas about computation:

πŸ€– AI-Native Generation

Can LLMs generate semantic structures (that are always valid) more reliably than generating text (that must parse correctly)? Early experiments suggest yes, but more research needed.

πŸ”„ Cross-Language Compilation

Can one representation compile to multiple targets (JavaScript, Python, Rust)? G-Expressions β†’ JavaScript works. Other targets are prototyped but not production-ready.

πŸ“œ Computational Provenance

Can we track exactly how, when, and by whom code was generated? The metadata system supports this, but real-world validation is limited.

πŸ”€ Runtime Evolution

Can languages extend themselves at runtime through "sugar rules"? G-Lisp's sugar-lang system demonstrates this is technically feasible.

Basic Examples

Simple Arithmetic

(2 * 3) + 4 - demonstrates nested function applications

{
  "g": "app",
  "v": {
    "fn": {
      "g": "ref",
      "v": "+"
    },
    "args": {
      "g": "vec",
      "v": [
        {
          "g": "app",
          "v": {
            "fn": {
              "g": "ref",
              "v": "*"
            },
            "args": {
              "g": "vec",
              "v": [
                {
                  "g": "lit",
                  "v": 2
                },
                {
                  "g": "lit",
                  "v": 3
                }
              ]
            }
          }
        },
        {
          "g": "lit",
          "v": 4
        }
      ]
    }
  }
}

Structure Breakdown:

    Lambda Function

    A function that multiplies two parameters

    {
      "g": "lam",
      "v": {
        "params": [
          "x",
          "y"
        ],
        "body": {
          "g": "app",
          "v": {
            "fn": {
              "g": "ref",
              "v": "*"
            },
            "args": {
              "g": "vec",
              "v": [
                {
                  "g": "ref",
                  "v": "x"
                },
                {
                  "g": "ref",
                  "v": "y"
                }
              ]
            }
          }
        }
      }
    }

    Structure Breakdown:

      Fibonacci Sequence

      Complete recursive Fibonacci implementation with pattern matching

      {
        "g": "fix",
        "v": {
          "g": "lam",
          "v": {
            "params": [
              "fib"
            ],
            "body": {
              "g": "lam",
              "v": {
                "params": [
                  "n"
                ],
                "body": {
                  "g": "match",
                  "v": {
                    "expr": {
                      "g": "app",
                      "v": {
                        "fn": {
                          "g": "ref",
                          "v": "<="
                        },
                        "args": {
                          "g": "vec",
                          "v": [
                            {
                              "g": "ref",
                              "v": "n"
                            },
                            {
                              "g": "lit",
                              "v": 1
                            }
                          ]
                        }
                      }
                    },
                    "branches": [
                      {
                        "pattern": {
                          "lit_pattern": true
                        },
                        "result": {
                          "g": "ref",
                          "v": "n"
                        }
                      },
                      {
                        "pattern": "else_pattern",
                        "result": {
                          "g": "app",
                          "v": {
                            "fn": {
                              "g": "ref",
                              "v": "+"
                            },
                            "args": {
                              "g": "vec",
                              "v": [
                                {
                                  "g": "app",
                                  "v": {
                                    "fn": {
                                      "g": "ref",
                                      "v": "fib"
                                    },
                                    "args": {
                                      "g": "app",
                                      "v": {
                                        "fn": {
                                          "g": "ref",
                                          "v": "-"
                                        },
                                        "args": {
                                          "g": "vec",
                                          "v": [
                                            {
                                              "g": "ref",
                                              "v": "n"
                                            },
                                            {
                                              "g": "lit",
                                              "v": 1
                                            }
                                          ]
                                        }
                                      }
                                    }
                                  }
                                },
                                {
                                  "g": "app",
                                  "v": {
                                    "fn": {
                                      "g": "ref",
                                      "v": "fib"
                                    },
                                    "args": {
                                      "g": "app",
                                      "v": {
                                        "fn": {
                                          "g": "ref",
                                          "v": "-"
                                        },
                                        "args": {
                                          "g": "vec",
                                          "v": [
                                            {
                                              "g": "ref",
                                              "v": "n"
                                            },
                                            {
                                              "g": "lit",
                                              "v": 2
                                            }
                                          ]
                                        }
                                      }
                                    }
                                  }
                                }
                              ]
                            }
                          }
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }

      Structure Breakdown:

        Three Implementations, One Idea

        🧬 G-Expressions (Elixir)

        Educational prototype exploring minimal foundations

        v0.1.0

        🌿 G-Lisp (Clojure)

        Most mature: DSL factory with runtime extension

        v1.1

        🎨 Melas (Phoenix)

        Interactive web playground for exploration

        v0.1

        See detailed project comparison β†’

        Current State (Honest Assessment)

        βœ“ What Works

        • Core evaluation and bootstrap systems
        • Interactive CLIs and web interfaces
        • JavaScript cross-compilation
        • AI-friendly JSON format
        • Runtime language extension (sugar-lang)
        • Pattern matching and expansion

        βš™ In Progress

        • Test coverage (22% β†’ 80% target)
        • Performance benchmarking
        • Package ecosystems
        • Error recovery systems
        • Documentation completeness

        🎯 Planned

        • Multi-target compilation (Python, Rust)
        • Production-grade tooling
        • Formal verification framework
        • Collaborative development features
        • Real-world case studies

        These are research prototypes, not production-ready systems. Suitable for learning, experimentation, and exploring ideasβ€”not for critical applications.

        Explore the Ideas

        G-Expressions are an experiment in rethinking how we represent computation. Whether the ideas prove valuable at scale remains to be seen, but the explorations so far have been intriguing.