Making the compiler: kzbin.info/www/bejne/faSmiJysicp5prs
@darqed Жыл бұрын
This video is so underrated, really cool!
@bvdlio Жыл бұрын
Thank you
@Garfield_Minecraft Жыл бұрын
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
@bvdlio Жыл бұрын
Thats great to hear!
@eboatwright_ Жыл бұрын
This is great! Little programming languages are one of my favorite things to code
@bvdlio Жыл бұрын
Great to hear!
@lyou__y_t7 ай бұрын
This video was so great! I want to see another videos!
@tidy5156 Жыл бұрын
This is a very good explanation thank you!! Keep up the good work
@Tigerseye9 ай бұрын
This is a well made tutorial, thanks!
@FuneFox11 ай бұрын
That reminds me of assembly, you should write an assembler. I wrote a poorly made assembler in C as one of my first projects.
@anon_y_mousse Жыл бұрын
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.
@bvdlio Жыл бұрын
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: kzbin.info/aero/PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y Highly recommend.
@lolcat69 Жыл бұрын
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
@anon_y_mousse Жыл бұрын
@@lolcat69 I've never heard a definition that makes random access a requirement for Turing completeness. Do you have a reference that supports that?
@OrangeDied10 ай бұрын
@@anon_y_mousse @lolcat69 stack-based programming languages are turing complete, cause FORTH is turing complete
@infernoslayer53937 ай бұрын
Literally made a by interpreted earlier today in C bc I was bored
@ItsSpaceManPlays7 ай бұрын
This video is criminally underrated
@bvdlio7 ай бұрын
I appreciate that!
@Nylspider6 ай бұрын
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
@bvdlio6 ай бұрын
Never too late, I appreciate it :)
@AlexTsaava5 күн бұрын
I'm gonna be honest, really underated I understood everything and made my own language that has a parser for quotes so if the line is "Hello world" itll count as 1 token and print "hello world" Will count as 2 tokens
@bvdlio4 күн бұрын
That's great to hear!
@AlexTsaava4 күн бұрын
Also added a stack for strings not only floats and even added variables for both types
@dk4kja84 ай бұрын
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.
@Rgotto2 Жыл бұрын
That was great, nice job
@bvdlio Жыл бұрын
Thank you! Cheers!
@HansBezemer4 ай бұрын
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.
@johnyeldryАй бұрын
the guy coding an in terpereter in the language we made: interpereters go brrrrrrrrrrrrrrrrr
@dokumencik6493Ай бұрын
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
@Sayori251 Жыл бұрын
can i get the code i have something wrong and i cant find it
@bvdlio Жыл бұрын
Yes, i'll make a quick repo and add it to the description and as reply to you :) ~5 minutes
@Sayori251 Жыл бұрын
@@bvdliour a legend mate
@bvdlio Жыл бұрын
@@Sayori251 github.com/basvdl97/OLL-Interpreter
@MRAN_XYZАй бұрын
But how to avoid chiken egg problem in bootstaping
@bvdlioАй бұрын
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 🎅
@YNGSprkzy5 ай бұрын
Im making a programming language without the need of a lexer, but only a parser and a interpreter
@doublescoopovanilla58352 ай бұрын
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
@hatchy4439 Жыл бұрын
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
@bvdlio Жыл бұрын
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
@Axtriel20 күн бұрын
i didnt understand what does JUMP.EQ.0 and JUMP.GT.0
@bvdlio20 күн бұрын
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.
@PixelLabsX9 ай бұрын
Super cool. So is it like I can execute custom functions and native Python ones?
@bvdlio8 ай бұрын
You can make it do what ever you want, especially python stuff, since thats the language of the interpreter.
@PixelLabsX8 ай бұрын
@@bvdlio Cool! Thanks for the vid man!
@pieshu Жыл бұрын
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?
@bvdlio Жыл бұрын
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.
@abaga22426 ай бұрын
How would you handle IF and LOOP instructions ? Very good video !
@bvdlio6 ай бұрын
@@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.
@mohithguptakorangi1766 Жыл бұрын
Isn't it more of a function/class rather than an "INTERPRETER" && "PROGRAMMING LANGUAGE" or is this how the languages are actually written???? Interesting...
@bvdlio Жыл бұрын
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.
@mohithguptakorangi1766 Жыл бұрын
@@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)
@bvdlio Жыл бұрын
@@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
@mohithguptakorangi1766 Жыл бұрын
@@bvdlio Thanks man, that solves my confusion actually. Will check that IJVM as well. Peace✌
@bvdlio Жыл бұрын
If you are interested, I have a video coming out explaining how to make a compiler for this language: kzbin.info/www/bejne/faSmiJysicp5prs
@bvdlio Жыл бұрын
Work on the "Not a Little Language" interpreter has started 🤙
@chris0617 Жыл бұрын
New sub:)
@yodyyoderson2 ай бұрын
Pls tell me when its done
@SilverSuperGamer9 ай бұрын
can't you just use modulus if you're checking if a number is odd or even?
@bvdlio9 ай бұрын
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.
@gmma7 ай бұрын
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?
@havenselph7 ай бұрын
Then popping would be have to decrement before returning a value which is odder imo
@dharma.vibrates11 ай бұрын
Can we rewrite compiler like beam or there are right reserved to beam compiler ? I am newbie here . Thanks
@bvdlio8 ай бұрын
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.
@YNGSprkzy5 ай бұрын
legendary
@DiamondWolfX9 ай бұрын
Isn't python bytecode-compiled (similar to Java) though? It just throws out the compiled code except for imported modules
@coding_pepper8 ай бұрын
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
@DiamondWolfX8 ай бұрын
@@coding_pepper Aside from the applicable VM and language, what's the difference between a Python pyc file and a Java class file?
@coding_pepper8 ай бұрын
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?
@littleslaughters80379 ай бұрын
What vs code color theme do you use?
@bvdlio8 ай бұрын
Jellyfish
@Axtriel Жыл бұрын
i have a question, how can i declare variables?
@bvdlio Жыл бұрын
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.
@hamzacasdasdasd7 ай бұрын
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
@kingtrigon5 ай бұрын
its every thing i rizzed about its every thing i fanumed about brain rot language that i can abuse the words
@BinaryCodeYT2 ай бұрын
6:38
@code_with_raushan2 ай бұрын
i am from India a 16 years old boy trying to make a programming language using sanskrit language
@OrangeDied10 ай бұрын
no way its the langue d'oïl
@aryzen27817 ай бұрын
now code a little OS with your little language =]
@bvdlio7 ай бұрын
Great idea 😂
@eggs-yt Жыл бұрын
i smell dutch
@bvdlio Жыл бұрын
You have a fine sense of smell 😉
@eggs-yt Жыл бұрын
@@bvdlio :)
@cyancaelus6456 Жыл бұрын
Nah I Want an Official Language. Not a Little Language
@bvdlio Жыл бұрын
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 :)
@bvdlio Жыл бұрын
Also, here you can find everything about how to lex, parse, etc more complex languages: Learning Resources: - @TsodingDaily Porth Series: kzbin.info/aero/PLpM-Dvs8t0VbMZA7wW9aR3EtBqe2kinu4 - SonicTK ASM_Tutorial (@YiLiangSiew) sonictk.github.io/asm_tutorial/ - @ImmoLandwerth Compiler Playlist: kzbin.info/aero/PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y
@bvdlio Жыл бұрын
Work on the "Not a Little Language" interpreter has started 🤙
@sagarkakkar4150 Жыл бұрын
I am very excited about this When can I expect it to release
@bvdlio Жыл бұрын
@@sagarkakkar4150Awesome! I am hoping 1-2 weeks from now :)