alpha (programming language)

alpha is a programming language I made, in order to give myself an excuse to delay studying compilers.alpha

My goal was to create a programming language that would require the absolute minimum effort to be implemented. A friend (Bad Sector) suggested that I looked into Forth, which is about as minimal as they get.

So “alpha” is very similar to forth. And it is very lightweight indeed. I first made a version that just worked and then, little by little I removed functionality from the compiler and put it in a “library” file written in alpha itself.

alpha has a logo produced by the following alpha program:

VARIABLE W
VARIABLE H
VARIABLE Radius
VARIABLE RingWidth
VARIABLE I
VARIABLE J

128 W SET
128 H SET

W GET 3 / Radius SET
W GET H GET * 22 / RingWidth SET

“P3\n” …
W GET . ‘\t’ .. H GET . ‘\t’ .. CR
“255\n\n” …

( I,J — B,G,R )
: Color
DUP2 I SET J SET
I GET H GET 2 / – DUP *
J GET W GET 2 / – DUP * +
Radius GET DUP * – ABS RingWidth GET <
I GET W GET 4 / < OR
J GET H GET 2 / – ABS H GET 4 * 11 / < AND
I GET W GET 1 * 10 / > AND

IF J GET 255 * H GET / 3 * 4 / 20 80 ELSE I GET 255 * W GET / 16 / DUP DUP FI
;

H GET DO
W GET DO
Color 3 DO >R    . ‘\t’ .. <R 1 – OD
1 – OD
CR
1 – OD

You can grab the source code on GitHub

In order to create executables, GoAsm is required. I preferred to use this assembler as it simply consists of a couple exe files (GoAsm/GoLink) and does not require any further setup.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s