Making a Programming Language & Interpreter in under 10 minutes!

  Рет қаралды 46,338

bvdl․io

bvdl․io

Күн бұрын

Пікірлер: 84
@bvdlio
@bvdlio Жыл бұрын
Making the compiler: kzbin.info/www/bejne/faSmiJysicp5prs
@Garfield_Minecraft
@Garfield_Minecraft 9 ай бұрын
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
@bvdlio 9 ай бұрын
Thats great to hear!
@darqed
@darqed Жыл бұрын
This video is so underrated, really cool!
@bvdlio
@bvdlio Жыл бұрын
Thank you
@tidy5156
@tidy5156 Жыл бұрын
This is a very good explanation thank you!! Keep up the good work
@eboatwright_
@eboatwright_ 10 ай бұрын
This is great! Little programming languages are one of my favorite things to code
@bvdlio
@bvdlio 10 ай бұрын
Great to hear!
@FuneFox
@FuneFox 9 ай бұрын
That reminds me of assembly, you should write an assembler. I wrote a poorly made assembler in C as one of my first projects.
@Tigerseye
@Tigerseye 7 ай бұрын
This is a well made tutorial, thanks!
@lyou__y_t
@lyou__y_t 4 ай бұрын
This video was so great! I want to see another videos!
@HansBezemer
@HansBezemer 2 ай бұрын
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.
@ItsSpaceManPlays
@ItsSpaceManPlays 5 ай бұрын
This video is criminally underrated
@bvdlio
@bvdlio 5 ай бұрын
I appreciate that!
@anon_y_mousse
@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
@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
@lolcat69 9 ай бұрын
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
@anon_y_mousse 9 ай бұрын
@@lolcat69 I've never heard a definition that makes random access a requirement for Turing completeness. Do you have a reference that supports that?
@OrangeDied
@OrangeDied 8 ай бұрын
@@anon_y_mousse @lolcat69 stack-based programming languages are turing complete, cause FORTH is turing complete
@infernoslayer5393
@infernoslayer5393 5 ай бұрын
Literally made a by interpreted earlier today in C bc I was bored
@dk4kja8
@dk4kja8 Ай бұрын
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.
@Nylspider
@Nylspider 3 ай бұрын
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
@bvdlio
@bvdlio 3 ай бұрын
Never too late, I appreciate it :)
@YNGSprkzy
@YNGSprkzy 2 ай бұрын
Im making a programming language without the need of a lexer, but only a parser and a interpreter
@pieshu
@pieshu 10 ай бұрын
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
@bvdlio 10 ай бұрын
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.
@hatchy4439
@hatchy4439 10 ай бұрын
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
@bvdlio 10 ай бұрын
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
@PixelLabsX
@PixelLabsX 7 ай бұрын
Super cool. So is it like I can execute custom functions and native Python ones?
@bvdlio
@bvdlio 6 ай бұрын
You can make it do what ever you want, especially python stuff, since thats the language of the interpreter.
@PixelLabsX
@PixelLabsX 6 ай бұрын
@@bvdlio Cool! Thanks for the vid man!
@doublescoopovanilla5835
@doublescoopovanilla5835 23 күн бұрын
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
@abaga2242
@abaga2242 4 ай бұрын
How would you handle IF and LOOP instructions ? Very good video !
@bvdlio
@bvdlio 4 ай бұрын
@@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.
@code_with_raushan
@code_with_raushan 21 күн бұрын
i am from India a 16 years old boy trying to make a programming language using sanskrit language
@bvdlio
@bvdlio Жыл бұрын
Work on the "Not a Little Language" interpreter has started 🤙
@chris0617
@chris0617 Жыл бұрын
New sub:)
@yodyyoderson
@yodyyoderson 14 күн бұрын
Pls tell me when its done
@Rgotto2
@Rgotto2 Жыл бұрын
That was great, nice job
@bvdlio
@bvdlio Жыл бұрын
Thank you! Cheers!
@gmma
@gmma 5 ай бұрын
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?
@havenselph
@havenselph 4 ай бұрын
Then popping would be have to decrement before returning a value which is odder imo
@DiamondWolfX
@DiamondWolfX 7 ай бұрын
Isn't python bytecode-compiled (similar to Java) though? It just throws out the compiled code except for imported modules
@coding_pepper
@coding_pepper 6 ай бұрын
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
@DiamondWolfX
@DiamondWolfX 6 ай бұрын
@@coding_pepper Aside from the applicable VM and language, what's the difference between a Python pyc file and a Java class file?
@coding_pepper
@coding_pepper 6 ай бұрын
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?
@Sayori251
@Sayori251 Жыл бұрын
can i get the code i have something wrong and i cant find it
@bvdlio
@bvdlio Жыл бұрын
Yes, i'll make a quick repo and add it to the description and as reply to you :) ~5 minutes
@Sayori251
@Sayori251 Жыл бұрын
​@@bvdliour a legend mate
@bvdlio
@bvdlio Жыл бұрын
@@Sayori251 github.com/basvdl97/OLL-Interpreter
@dharma.vibrates
@dharma.vibrates 9 ай бұрын
Can we rewrite compiler like beam or there are right reserved to beam compiler ? I am newbie here . Thanks
@bvdlio
@bvdlio 6 ай бұрын
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.
@SilverSuperGamer
@SilverSuperGamer 7 ай бұрын
can't you just use modulus if you're checking if a number is odd or even?
@bvdlio
@bvdlio 7 ай бұрын
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.
@YNGSprkzy
@YNGSprkzy 2 ай бұрын
legendary
@mohithguptakorangi1766
@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
@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
@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
@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
@mohithguptakorangi1766 Жыл бұрын
@@bvdlio Thanks man, that solves my confusion actually. Will check that IJVM as well. Peace✌
@bvdlio
@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
@kingtrigon
@kingtrigon 2 ай бұрын
its every thing i rizzed about its every thing i fanumed about brain rot language that i can abuse the words
@littleslaughters8037
@littleslaughters8037 6 ай бұрын
What vs code color theme do you use?
@bvdlio
@bvdlio 6 ай бұрын
Jellyfish
@hamzacasdasdasd
@hamzacasdasdasd 5 ай бұрын
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
@Axtriel
@Axtriel Жыл бұрын
i have a question, how can i declare variables?
@bvdlio
@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.
@OrangeDied
@OrangeDied 8 ай бұрын
no way its the langue d'oïl
@aryzen2781
@aryzen2781 5 ай бұрын
now code a little OS with your little language =]
@bvdlio
@bvdlio 5 ай бұрын
Great idea 😂
@eggs-yt
@eggs-yt Жыл бұрын
i smell dutch
@bvdlio
@bvdlio Жыл бұрын
You have a fine sense of smell 😉
@eggs-yt
@eggs-yt Жыл бұрын
@@bvdlio :)
@BinaryCodeYT
@BinaryCodeYT 15 күн бұрын
6:38
@cyanuranus6456
@cyanuranus6456 Жыл бұрын
Nah I Want an Official Language. Not a Little Language
@bvdlio
@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
@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
@bvdlio Жыл бұрын
Work on the "Not a Little Language" interpreter has started 🤙
@sagarkakkar4150
@sagarkakkar4150 11 ай бұрын
I am very excited about this When can I expect it to release
@bvdlio
@bvdlio 11 ай бұрын
@@sagarkakkar4150Awesome! I am hoping 1-2 weeks from now :)
A Compiler For Our Own Programming Language // Full Guide
18:54
Creating Your Own Programming Language - Computerphile
21:15
Computerphile
Рет қаралды 105 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 134 МЛН
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 134 МЛН
Making My Own Programming Language and Coding a Game in It
10:19
AstroSam
Рет қаралды 1,3 МЛН
I Made My Own Programming Language
10:20
CodeNoodles
Рет қаралды 97 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 345 М.
I made my own Code Editor
12:02
FaceDev
Рет қаралды 328 М.
Compilers, How They Work, And Writing Them From Scratch
23:53
Adam McDaniel (kiwi)
Рет қаралды 221 М.
The Ultimate Tier Programming Tier List | Prime Reacts
26:57
ThePrimeTime
Рет қаралды 477 М.
Writing My Own Database From Scratch
42:00
Tony Saro
Рет қаралды 256 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 134 МЛН