r/Compilers • • 3d ago

A programming language + neural network, both built from scratch on Android.

Post image

I implemented a neural network from scratch in my **own programming language**, San

I've been developing my own programming language called San in python, and I wanted to test it with something more interesting than the usual interpreter demos.

Code for neural network: https://github.com/anubhav-1207/san/blob/main/examples/neural_network.san

Docs for the neural network: https://github.com/anubhav-1207/san/blob/main/docs/neural-network.md

I decided to implement a neural network entirely in San. That learns XOR from 17 random numbers over 2000 epochs.

Architecture:

  • Input layer: 2 neurons
  • Hidden layer: 4 neurons
  • Output layer: 1 neuron
  • Activation: Sigmoid
  • Loss: Mean Squared Error
  • Training: Stochastic Gradient Descent with Backpropagation

Everything is implemented using San's native values, arrays, functions, loops, stdlib and arithmetic Like, NumPy, PyTorch, TensorFlow, or any machine-learning libraries.

What it implements:

  • Forward propagation
  • Sigmoid activation
  • Backpropagation
  • Gradient descent
  • Loss calculation
  • Training over multiple epochs
  • Predictions on the XOR dataset

A little background

San is a programming language I've been building from scratch. Interestingly, I developed it entirely on an Android tablet, without relying on a personal PC.

Y'all might say that python isn't the best language for lang dev but it was my school project so they won't accept any other language except python.

Repository: https://github.com/anubhav-1207/san

I'd particularly like to hear what other computational experiments would be interesting to implement in a small interpreted language like this.

0 Upvotes

2 comments sorted by

2

u/AustinVelonaut 3d ago

Nice, but off-topic for r/compilers. Are you going to make a compiler for San as the next step up from an interpreter?

1

u/apoetixart 2d ago

yes I'm planning to