Building an ML Language from Scratch: Introducing Charl
dev.to·2h·
Discuss: DEV
Flag this post

I spent the last year building Charl - a programming language designed specifically for machine learning. Not a library on top of Python, but a language where tensors and autograd are native features.

Why?

PyTorch and TensorFlow are excellent, but they’re libraries bolted onto general-purpose languages. I wanted to explore: what’s possible when ML is built into the language itself?

What Works Today

  • Native tensor operations
  • Automatic differentiation (dynamic graphs)
  • Neural network training (validated on MNIST)
  • 22x faster than PyTorch CPU
  • GPU support via wgpu
  • Type-safe (static typing with inference)

Example: Training a Neural Network

// Network: 2 -> 4 -> 1
let w1 = tensor_randn([2, 4])
let w2 = tensor_randn([4, 1])

while epoch < 1000 {
// Forward
le...

Similar Posts

Loading similar posts...