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
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.
Yea, I've seen his videos (on Porth), they are great :) The rule 110 he showed for Turing completeness was interesting, and the idea of implementing the Porth compiler in Porth is also hilarious. I really got excited a while ago by Immo Landwerth's playlist about building compilers: th-cam.com/play/PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y.html Highly recommend.
Alao brainfuck is actually turing complete and a stack based lang like this one isn't, cuz to be turing complete you need to have Random Access Memory, and a stack doesn't provide Random Access to it's content
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
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
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?
Thanks :) Feel free to do what ever you want with the interpreter and language :) PS: If the question is, if I think its possible to make a web based interpreter for this language, the answer is also yes.
@@abaga2242 You can make dedicated IF and LOOP instructions, but they can be made using a combination of existing instructions from the video. In the video we i showcase a problem where we check if a number is even or odd. In python that would: If nr % 2 == 0: print('even') else: print('odd') To do so in the example we achieve the if using the two jump instructions. The same problem we also have an example of a loop, since we use the jump instructions to repeat part of the program to continuously subtract one, to determine our answers. Effectively calculating the remainder, just like in python. Sorry for typos, wrote this on my phone.
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.
1. First you write a compiler in a pre-existing language (c, Java, etc). 2. Then, you write a compiler for your own language in your own language and compile it using the (c, Java) compiler. (Making it an executable) 3. Then you write any program in your own language and compile it using the compiler from step 2. Merry Christmas 🎅
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
Yes ofcourse, but you need to tell me what error you got, and if possible share a repo with your code. Also, here is the code from the video: github.com/basvdl97/OLL-Interpreter
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 * , *ROLL * 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.
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
So. By default we go through all the instructions in a program 1 by 1 to run it. What jump lets je do, is "jump" back or forward to something else then the next instruction based on a condition. JUMP.EQ.0 "jumps" to a new instruction if the top of the stack is 0. JUMP.GT.0 "jumps" to an instruction if the top of the stack is greater than 0. Hope that helps.
Isn't it more of a function/class rather than an "INTERPRETER" && "PROGRAMMING LANGUAGE" or is this how the languages are actually written???? Interesting...
This is a very basic example of how interpreters and languages are actually made. The way something is made, in python, c, with classes, without classes, does not dictate what it is. In this case we created a very simple 120 line interpreter for a very simple 8 instruction stack based language. Interpreters for languages like python are far more complex partly due to the functionality of python and thus having to abstract and book keep a lot. Compilers are also on another level because they require knowledge of an IR (intermediate representation) for an eventual architecture specific build. Hope you enjoyed the video though :) It's meant to be a starting point for people who want to create their own language. Hopefully reducing the barrier to entry by making it seem easy.
@@bvdlio "The way something is made, in python, c, with classes, without classes, does not dictate what it is." A bit more explanation on this? Do you mean that something that's made with classes/functions need not be a class/function? It's actually interesting to see that everyone can create such things these days (at least the basics of it)
@@mohithguptakorangi1766 Yes of course. You say: "Isn't it more of a function/class rather than an "INTERPRETER" && "PROGRAMMING LANGUAGE". Thus saying that something that is a class or a function can not be an interpreter. But instead, functions and classes are used to make programs, whether that be an interpreter or a video game, doesn't matter. It also doesn't matter if there is no functions, one function, no classes or one class. The code can still define the functionality of an interpreter or any other program. So the code that we wrote, even though short, and only one class, is still an interpreter. I can write any program using the instructions we created for Our Little Language (.oll) and our interpreter will run the Our Little Language correctly. Just like the python interpreter runs the code in a main.py file. Yea, its really nice. Writing anything in python usually helps. Originally I wrote the interpreter in C, and then you also have to keep track of the types of the things you put on the stack with your new language, etc. If you want to look at a great example of another stack based language for which you can find interpreters online. Check out the IJVM language and interpreters. If you want to go to the deepest depths of creating a language and a compiler, look into: LLVM
You can use the code for what ever you want. If possible it would be nice if you add my credits somewhere ☺️ But for hobby projects, do what ever you want.
The way bytecode is generated, in python the process is hidden in runtime making it longer and in java you generate bytecode and then use the vm to run it as a sepparate proces. You with me?
In this video we design a simple programming language that has the following instructions: PUSH POP ADD SUB PRINT READ JUMP.EQ.0 JUMP.GT.0 There is no modules (or MOD) instruction, so we can't just do modulus. This makes it a fun task to try and calculate the modulus using the instructions that we do have (above). The solution we created (without that MOD instruction) is effectively the same as one with, since we reduce the number to either 0 or 1, and check if its either or the other to determine if its even or odd. It would be very simple to add a MOD instruction, and use the python % to perform the modulo, but just like (most) other stack based or assembly like languages, we chose not to add it.
It's a very simple stack based language, that doesn't support variables. Just pushing and popping from a stack, and operations on things on the stack. In the near future there will be a video on how to create an interpreter for higher level language. With variables, ifs, loops, etc.
if you really want a make an usefull languange just rewrite your languange in that languange if you can do that means that languange is advanced enough to create something
Perhaps in the future :) The method is essentially the same, so after watching the video you should have a good idea of how to do so for any programming language :)
Also, here you can find everything about how to lex, parse, etc more complex languages: Learning Resources: - @TsodingDaily Porth Series: th-cam.com/play/PLpM-Dvs8t0VbMZA7wW9aR3EtBqe2kinu4.html - SonicTK ASM_Tutorial (@YiLiangSiew) sonictk.github.io/asm_tutorial/ - @ImmoLandwerth Compiler Playlist: th-cam.com/play/PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y.html
Making the compiler: th-cam.com/video/GsCWivTeFpY/w-d-xo.html
This video is so underrated, really cool!
Thank you
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
Thats great to hear!
This is great! Little programming languages are one of my favorite things to code
Great to hear!
This video was so great! I want to see another videos!
That reminds me of assembly, you should write an assembler. I wrote a poorly made assembler in C as one of my first projects.
This is a very good explanation thank you!! Keep up the good work
This is a well made tutorial, thanks!
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.
Yea, I've seen his videos (on Porth), they are great :) The rule 110 he showed for Turing completeness was interesting, and the idea of implementing the Porth compiler in Porth is also hilarious.
I really got excited a while ago by Immo Landwerth's playlist about building compilers: th-cam.com/play/PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y.html
Highly recommend.
Alao brainfuck is actually turing complete and a stack based lang like this one isn't, cuz to be turing complete you need to have Random Access Memory, and a stack doesn't provide Random Access to it's content
@@lolcat69 I've never heard a definition that makes random access a requirement for Turing completeness. Do you have a reference that supports that?
@@anon_y_mousse @lolcat69 stack-based programming languages are turing complete, cause FORTH is turing complete
Literally made a by interpreted earlier today in C bc I was bored
This video is criminally underrated
I appreciate that!
the guy coding an in terpereter in the language we made:
interpereters go brrrrrrrrrrrrrrrrr
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
Never too late, I appreciate it :)
That was great, nice job
Thank you! Cheers!
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
Super cool. So is it like I can execute custom functions and native Python ones?
You can make it do what ever you want, especially python stuff, since thats the language of the interpreter.
@@bvdlio Cool! Thanks for the vid man!
can i get the code i have something wrong and i cant find it
Yes, i'll make a quick repo and add it to the description and as reply to you :)
~5 minutes
@@bvdliour a legend mate
@@Sayori251 github.com/basvdl97/OLL-Interpreter
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?
Thanks :)
Feel free to do what ever you want with the interpreter and language :)
PS: If the question is, if I think its possible to make a web based interpreter for this language, the answer is also yes.
How would you handle IF and LOOP instructions ? Very good video !
@@abaga2242 You can make dedicated IF and LOOP instructions, but they can be made using a combination of existing instructions from the video.
In the video we i showcase a problem where we check if a number is even or odd.
In python that would:
If nr % 2 == 0:
print('even')
else:
print('odd')
To do so in the example we achieve the if using the two jump instructions.
The same problem we also have an example of a loop, since we use the jump instructions to repeat part of the program to continuously subtract one, to determine our answers. Effectively calculating the remainder, just like in python.
Sorry for typos, wrote this on my phone.
legendary
Work on the "Not a Little Language" interpreter has started 🤙
New sub:)
Pls tell me when its done
Im making a programming language without the need of a lexer, but only a parser and a interpreter
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.
But how to avoid chiken egg problem in bootstaping
1. First you write a compiler in a pre-existing language (c, Java, etc).
2. Then, you write a compiler for your own language in your own language and compile it using the (c, Java) compiler. (Making it an executable)
3. Then you write any program in your own language and compile it using the compiler from step 2.
Merry Christmas 🎅
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
Yes ofcourse, but you need to tell me what error you got, and if possible share a repo with your code.
Also, here is the code from the video: github.com/basvdl97/OLL-Interpreter
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 * , *ROLL * 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.
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
i didnt understand what does JUMP.EQ.0 and JUMP.GT.0
So. By default we go through all the instructions in a program 1 by 1 to run it.
What jump lets je do, is "jump" back or forward to something else then the next instruction based on a condition.
JUMP.EQ.0 "jumps" to a new instruction if the top of the stack is 0.
JUMP.GT.0 "jumps" to an instruction if the top of the stack is greater than 0.
Hope that helps.
What vs code color theme do you use?
Jellyfish
Isn't it more of a function/class rather than an "INTERPRETER" && "PROGRAMMING LANGUAGE" or is this how the languages are actually written???? Interesting...
This is a very basic example of how interpreters and languages are actually made.
The way something is made, in python, c, with classes, without classes, does not dictate what it is.
In this case we created a very simple 120 line interpreter for a very simple 8 instruction stack based language.
Interpreters for languages like python are far more complex partly due to the functionality of python and thus having to abstract and book keep a lot.
Compilers are also on another level because they require knowledge of an IR (intermediate representation) for an eventual architecture specific build.
Hope you enjoyed the video though :)
It's meant to be a starting point for people who want to create their own language. Hopefully reducing the barrier to entry by making it seem easy.
@@bvdlio "The way something is made, in python, c, with classes, without classes, does not dictate what it is." A bit more explanation on this? Do you mean that something that's made with classes/functions need not be a class/function?
It's actually interesting to see that everyone can create such things these days (at least the basics of it)
@@mohithguptakorangi1766 Yes of course. You say: "Isn't it more of a function/class rather than an "INTERPRETER" && "PROGRAMMING LANGUAGE". Thus saying that something that is a class or a function can not be an interpreter. But instead, functions and classes are used to make programs, whether that be an interpreter or a video game, doesn't matter. It also doesn't matter if there is no functions, one function, no classes or one class. The code can still define the functionality of an interpreter or any other program.
So the code that we wrote, even though short, and only one class, is still an interpreter. I can write any program using the instructions we created for Our Little Language (.oll) and our interpreter will run the Our Little Language correctly. Just like the python interpreter runs the code in a main.py file.
Yea, its really nice. Writing anything in python usually helps. Originally I wrote the interpreter in C, and then you also have to keep track of the types of the things you put on the stack with your new language, etc.
If you want to look at a great example of another stack based language for which you can find interpreters online. Check out the IJVM language and interpreters.
If you want to go to the deepest depths of creating a language and a compiler, look into: LLVM
@@bvdlio Thanks man, that solves my confusion actually. Will check that IJVM as well. Peace✌
If you are interested, I have a video coming out explaining how to make a compiler for this language: th-cam.com/video/GsCWivTeFpY/w-d-xo.html
correct me if I'm wrong, doesn't a stack input the value at the location of the stack pointer and then increment the stack pointer?
Then popping would be have to decrement before returning a value which is odder imo
Can we rewrite compiler like beam or there are right reserved to beam compiler ? I am newbie here . Thanks
You can use the code for what ever you want. If possible it would be nice if you add my credits somewhere ☺️
But for hobby projects, do what ever you want.
Isn't python bytecode-compiled (similar to Java) though? It just throws out the compiled code except for imported modules
Noooo, python parser creates bytecode for the interpreter to run. If you use python with larger scripts you can see .pyc which is the bytecode
@@coding_pepper Aside from the applicable VM and language, what's the difference between a Python pyc file and a Java class file?
The way bytecode is generated, in python the process is hidden in runtime making it longer and in java you generate bytecode and then use the vm to run it as a sepparate proces. You with me?
can't you just use modulus if you're checking if a number is odd or even?
In this video we design a simple programming language that has the following instructions:
PUSH
POP
ADD
SUB
PRINT
READ
JUMP.EQ.0
JUMP.GT.0
There is no modules (or MOD) instruction, so we can't just do modulus. This makes it a fun task to try and calculate the modulus using the instructions that we do have (above). The solution we created (without that MOD instruction) is effectively the same as one with, since we reduce the number to either 0 or 1, and check if its either or the other to determine if its even or odd.
It would be very simple to add a MOD instruction, and use the python % to perform the modulo, but just like (most) other stack based or assembly like languages, we chose not to add it.
6:38
its every thing i rizzed about its every thing i fanumed about brain rot language that i can abuse the words
i have a question, how can i declare variables?
It's a very simple stack based language, that doesn't support variables. Just pushing and popping from a stack, and operations on things on the stack.
In the near future there will be a video on how to create an interpreter for higher level language. With variables, ifs, loops, etc.
if you really want a make an usefull languange just rewrite your languange in that languange if you can do that means that languange is advanced enough to create something
no way its the langue d'oïl
now code a little OS with your little language =]
Great idea 😂
i smell dutch
You have a fine sense of smell 😉
@@bvdlio :)
i am from India a 16 years old boy trying to make a programming language using sanskrit language
Nah I Want an Official Language. Not a Little Language
Perhaps in the future :) The method is essentially the same, so after watching the video you should have a good idea of how to do so for any programming language :)
Also, here you can find everything about how to lex, parse, etc more complex languages:
Learning Resources:
- @TsodingDaily Porth Series: th-cam.com/play/PLpM-Dvs8t0VbMZA7wW9aR3EtBqe2kinu4.html
- SonicTK ASM_Tutorial (@YiLiangSiew) sonictk.github.io/asm_tutorial/
- @ImmoLandwerth Compiler Playlist: th-cam.com/play/PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y.html
Work on the "Not a Little Language" interpreter has started 🤙
I am very excited about this
When can I expect it to release
@@sagarkakkar4150Awesome!
I am hoping 1-2 weeks from now :)