Skip to main content

CWG — a Git-based programming language interpreter

Project description

CWG banner

Coding With Git

PyPI Python versions License: GPL v3

Language Reference · Installation · Contributing · License

Work in progress. This project is in early draft stage. Syntax and semantics are subject to change.

CWG is a programming language where the source code is the git history. Commit messages are statements, branches are control flow blocks, and merges close those blocks. The interpreter walks the commit DAG and executes it as a program.

The goal is to use git as a genuine programming medium. Readable syntax, real execution, built entirely on top of version control primitives.


Concept

Git construct Language construct
git commit -m "..." Statement / instruction
Branch Conditional block or loop
Merge Close a block, return to parent scope
Tag Function definition
cherry-pick Function call
revert Exception handler / undo
git stash Push to memory stack
git stash pop Pop from memory stack

Installation

CWG is published on PyPI. You need Python 3.10+ and Git installed, then:

pip install cwg

This installs the cwg command on your PATH and pulls in the runtime dependency (GitPython). No need to clone the repository to use the language.

Want to work on CWG itself? See CONTRIBUTING.md for the from-source / editable-install workflow.


Quick Start

Write your first program — a git history that prints hello world:

mkdir hello && cd hello
git init
git commit --allow-empty -m "message = 'hello world'"
git commit --allow-empty -m "print(message)"
cwg run .
# output: hello world

cwg run accepts a .cwg script, a local git repo path, or a remote URL (https://…, git@…, ssh://…).


Language Reference

The full syntax and semantics — control flow, scoping, the execution model, functions, exception handling, and more — live in the Language Reference.

A taste of what CWG looks like — a countdown loop, where a branch is the loop body:

git commit -m "i = 10"
git branch while/countdown
  git commit -m "while i > 0:"
  git commit -m "    print(i)"
  git commit -m "    i = i - 1"
git checkout main
git merge while/countdown
git commit -m "print('blastoff')"
# output: 10 9 8 7 6 5 4 3 2 1 blastoff

Status

This project is a work in progress. See CONTRIBUTING.md for how to get involved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cwg-0.2.0.tar.gz (39.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cwg-0.2.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file cwg-0.2.0.tar.gz.

File metadata

  • Download URL: cwg-0.2.0.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for cwg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8259164412e5f503841279bf8fbc8786f44cff9a0b70159d922b52aee796e833
MD5 5c01e118f5d0a434b9d8b9f87d8f33dc
BLAKE2b-256 f4d6648e2fc0fd2cdfcce5cdc3316460280a4d49ae712c23716f5ad0da03c200

See more details on using hashes here.

File details

Details for the file cwg-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cwg-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for cwg-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc79371fc983d29336cdfae617ec97fb99df067ed5c2bc9f6894c0cf50abe578
MD5 8bdf8233ca756ee18989622ab0b30059
BLAKE2b-256 fee4db9f1fe3b5d5b91572289b24c9f6a9d7a5f4602a457b072e68b0b6f7a8f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page