Making a Programming Language & Interpreter in under 10 minutes!

preview_player
Показать описание
Creating a programming language is a dream for many programmers. In this video I go over how you can create a simple programming language and in interpreter for that language so you can run programs written in your own programming language. This will help you get started creating and understanding how make your own (more complex) programming language.

Make sure to let me know in the comments if you want to see this language being expanded. For the ability to do things such as assign variable or call functions.

Disclaimer:
The language (Our Little Language (.oll)) is by far not a complete language, and the interpreter only expects perfectly written code. Don't use this for production purposes, and only use it for the educational purpose of learning about creating and interpreting programming languages.

The Instruction in Our Little Language (.oll) are:
PUSH
POP
ADD
SUB
PRINT
READ
JUMP.EQ.0
JUMP.GT.0

_____________
_____________
READ
READ
SUB
JUMP.EQ.0 L1
PRINT "not equal"
HALT

L1:
PRINT "equal"
HALT
_____________

_____________
_____________
READ
JUMP.EQ.0 L1

LOOP:
PUSH 2
SUB
JUMP.EQ.0 L1
JUMP.GT.0 LOOP
PRINT "odd"
HALT

L1:
PRINT "even"
HALT
_____________

- Music -

- Time Codes -
0:00 - Intro
0:04 - What is an interpreter
0:37 - Stack based languages
1:31 - Our Language Instructions
2:58 - Example .oll programs
4:16 - Writing two .oll programs
4:26 - Creating interpreter - parsing
6:40 - Creating interpreter - stack
7:28 - Creating interpreter - execution
9:22 - Running our programming language
10:10 - Outro

- Hashtags -
#programming
#coding
#interpreter
#programminglanguage
#python
#compiler

- Search Terms -
making a programming language
making my own programming language
programming language interpreter
write a program
computer program
python tutorial for beginners
Рекомендации по теме
Комментарии
Автор

This video is so underrated, really cool!

darqed
Автор

this video is very easy to follow
i never code a new programming langauge before
i watch the video to see what the thinking process was like
great video
i made my own now
it doesn't use stack it supports variables and can tell error
now it can only showing message and variable

Garfield_Minecraft
Автор

This is great! Little programming languages are one of my favorite things to code

eboatwright_
Автор

This video was so great! I want to see another videos!

lyou__y_t
Автор

This is a very good explanation thank you!! Keep up the good work

tidy
Автор

That reminds me of assembly, you should write an assembler. I wrote a poorly made assembler in C as one of my first projects.

FuneFox
Автор

This is a well made tutorial, thanks!

Tigerseye
Автор

I usually like to start people off with an easier to parse language, like BF, the real name of which will probably be censored, and it too has only 8 instructions but they're each a single character which is easier to parse for a language like C, which is what I usually push people into. Because it's a tape driven language instead of stack, it also lends itself reasonably well to teaching optimization and it's still easy to translate into something like assembly. Have you ever watched Tsoding and seen any of his videos on the language he came up with? He calls it Porth. It's stack based and he implemented the bootstrap in Python.

anon_y_mousse
Автор

I know I'm extremely late for this but this video is so cool and I love it so much; I honestly am tempted to make an interpreter for your language (using something other than python, of course) just because of how much fun this looked :3

Nylspider
Автор

I downloaded ur github repo, but whn i run it nothing happens. added a print statement at the start of the interpreter and it does print it but no errors tho

dokumencik
Автор

You've actually created some bytecode compiler, which is later interpreted - it's IMHO not a pure interpreter. That continuously scans the source code. In a sense you made some Forth compiler. A few remarks:
1. You could have converted the token to an integer. It (normally) makes a quicker compare than a full string compare;
2. You don't need JUMP.GT.0 - an unconditional jump is all you need - although you'd need a word like *SIGN* to compensate, agreed;
3. Your language lacks stack operators. That significantly diminishes it's usefulness. *PICK <number>*, *ROLL <number>* and *DROP* are the bare minimum;
4. It probably has to do with Python's parser, but why should you need double quotes after PRINT? You just print anything following it - since you can't print numbers it seems.

HansBezemer
Автор

Hello i have a question, i followed the tutorial step by step and checked it multiple times but the L1 is still causing errors could you indicate me where i need to check, thank you

hatchy
Автор

the guy coding an in terpereter in the language we made:
interpereters go

johnyeldry
Автор

can i get the code i have something wrong and i cant find it

Sayori
Автор

Super cool. So is it like I can execute custom functions and native Python ones?

PixelLabsX
Автор

Hey! I really appreciate the hard work you put into this video. It was really educational for me. One question, can i make a web based environment for this interpreter (similar to many online IDEs), and call the interpreter in backend using Api endpoints?

pieshu
Автор

Edit: Watching this video, this is the easiest thing to implement as a compiler... x86_64 may seem scary but with these basic instructions it really isnt hard
Edit 2: I just saw the video upload date, the JIT compiler was not known about at this point, but I still believe it's important to know about now.
Edit 3: This is not a stack based language. This is a heap based language with a simulated stack as Python functions mainly on the heap

Python actually has a compiler.

1. Bytecode compiler. Python uses its own intermediate language which is similar to assembly. It then uses the Python VM to run the code.
2. JIT Compiler. Python 3.13 has a JIT Compiler which uses its intermediate language for some of the code, while fully compiling the rest to machine code. This is fully experimental and can only be enabled if you build Python from its source.

dkkja
Автор

Brother I can save you the time, there's already an i terpreter in you computer for this, it's called the cpu. Kidding, really cool video, it is funny to basically make an interpretter for assembly tho

doublescoopovanilla
Автор

But how to avoid chiken egg problem in bootstaping

MRAN_XYZ
Автор

How would you handle IF and LOOP instructions ? Very good video !

abaga