Locuri de la munte, prin Banat sau aiurea

← Projects

Churing

An AI-native functional programming language · github.com/petrucristescu/churing

Churing is a small programming language I am building, named after Alonzo Church, who invented the lambda calculus, and Alan Turing, who defined the universal machine. It started as an exercise in how programming languages work: a parser, a type checker that works out types by itself (Hindley-Milner), and an interpreter, all written in OCaml.

Today it is an experiment with a specific question: what would a programming language look like if calls to AI models were part of the language, rather than a library bolted on?

The idea

Code that uses large language models is unusual. The same question can get a different answer each time, an answer can be malformed or a refusal, every call costs time and money, and the only way to know whether it works is to measure it against examples. Most AI code today handles all of this by hand, in Python.

Churing tries to make these properties part of the language:

What it looks like

A function and a result. There is no main and no print: a program reduces to a value.

~fib n (match n
    | 0 -> 0
    | 1 -> 1
    | x -> fib (x - 1) + fib (x - 2))

fib 10        # the last expression is the result: 55

Asking a model. The answer is a result that is either ok or err:

@review "Great product, but shipping took three weeks."

@answer (ask (str ["Is this review positive or negative? ", review]))

(matchResult answer
  (|>text. str ["The model says: ", text])
  (|>e. str ["No answer: ", e]))

Recording and replaying model answers, so tests run offline and give the same result every time:

# Record the answers once, against a real model
CHURING_ASK_CACHE=answers.json CHURING_ASK_MODE=record churing reviews.ch

# Replay them later: offline, free, and the same every time
CHURING_ASK_CACHE=answers.json CHURING_ASK_MODE=replay churing reviews.ch

Where it is going

The next steps are typed answers and built-in evaluation. The goal is a program like this one (not working yet):

type Sentiment = Positive | Negative | Mixed

@s (askAs Sentiment "Classify: {review}")   # a typed value, validated and retried

evaluate classify examples
expect (gte accuracy 0.9)

The plan is deliberately small: build one realistic example, a support-ticket classifier, and compare it side by side with the same program in Python. If the Churing version is not clearly better, the idea gets rethought before anything else is built. The roadmap and progress are tracked in the project's issues on GitHub.

Status