Making a Programming Language & Interpreter in under 10 minutes!

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ม.ค. 2025

ความคิดเห็น • 90

  • @bvdlio
    @bvdlio  ปีที่แล้ว +10

    Making the compiler: th-cam.com/video/GsCWivTeFpY/w-d-xo.html

  • @darqed
    @darqed ปีที่แล้ว +19

    This video is so underrated, really cool!

    • @bvdlio
      @bvdlio  ปีที่แล้ว +1

      Thank you

  • @Garfield_Minecraft
    @Garfield_Minecraft 11 หลายเดือนก่อน +13

    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  11 หลายเดือนก่อน +3

      Thats great to hear!

  • @eboatwright_
    @eboatwright_ ปีที่แล้ว +7

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

    • @bvdlio
      @bvdlio  ปีที่แล้ว +3

      Great to hear!

  • @lyou__y_t
    @lyou__y_t 6 หลายเดือนก่อน +3

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

  • @FuneFox
    @FuneFox 11 หลายเดือนก่อน +3

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

  • @tidy5156
    @tidy5156 ปีที่แล้ว +7

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

  • @Tigerseye
    @Tigerseye 9 หลายเดือนก่อน +1

    This is a well made tutorial, thanks!

  • @anon_y_mousse
    @anon_y_mousse ปีที่แล้ว +31

    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  ปีที่แล้ว +7

      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.

    • @lolcat69
      @lolcat69 11 หลายเดือนก่อน +1

      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 11 หลายเดือนก่อน +1

      @@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 9 หลายเดือนก่อน +1

      @@anon_y_mousse @lolcat69 stack-based programming languages are turing complete, cause FORTH is turing complete

    • @infernoslayer5393
      @infernoslayer5393 7 หลายเดือนก่อน +1

      Literally made a by interpreted earlier today in C bc I was bored

  • @ItsSpaceManPlays
    @ItsSpaceManPlays 7 หลายเดือนก่อน +10

    This video is criminally underrated

    • @bvdlio
      @bvdlio  7 หลายเดือนก่อน

      I appreciate that!

  • @johnyeldry
    @johnyeldry 25 วันที่ผ่านมา

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

  • @Nylspider
    @Nylspider 5 หลายเดือนก่อน

    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  5 หลายเดือนก่อน

      Never too late, I appreciate it :)

  • @Rgotto2
    @Rgotto2 ปีที่แล้ว +1

    That was great, nice job

    • @bvdlio
      @bvdlio  ปีที่แล้ว

      Thank you! Cheers!

  • @dokumencik6493
    @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

  • @PixelLabsX
    @PixelLabsX 8 หลายเดือนก่อน +2

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

    • @bvdlio
      @bvdlio  8 หลายเดือนก่อน +1

      You can make it do what ever you want, especially python stuff, since thats the language of the interpreter.

    • @PixelLabsX
      @PixelLabsX 8 หลายเดือนก่อน

      @@bvdlio Cool! Thanks for the vid man!

  • @Sayori251
    @Sayori251 ปีที่แล้ว +2

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

    • @bvdlio
      @bvdlio  ปีที่แล้ว +1

      Yes, i'll make a quick repo and add it to the description and as reply to you :)
      ~5 minutes

    • @Sayori251
      @Sayori251 ปีที่แล้ว +1

      ​@@bvdliour a legend mate

    • @bvdlio
      @bvdlio  ปีที่แล้ว

      @@Sayori251 github.com/basvdl97/OLL-Interpreter

  • @pieshu
    @pieshu 11 หลายเดือนก่อน +1

    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  11 หลายเดือนก่อน

      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
    @abaga2242 6 หลายเดือนก่อน

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

    • @bvdlio
      @bvdlio  6 หลายเดือนก่อน

      @@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.

  • @YNGSprkzy
    @YNGSprkzy 4 หลายเดือนก่อน

    legendary

  • @bvdlio
    @bvdlio  ปีที่แล้ว +4

    Work on the "Not a Little Language" interpreter has started 🤙

    • @chris0617
      @chris0617 ปีที่แล้ว +1

      New sub:)

    • @yodyyoderson
      @yodyyoderson 2 หลายเดือนก่อน

      Pls tell me when its done

  • @YNGSprkzy
    @YNGSprkzy 4 หลายเดือนก่อน

    Im making a programming language without the need of a lexer, but only a parser and a interpreter

  • @dk4kja8
    @dk4kja8 3 หลายเดือนก่อน

    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.

  • @MRAN_XYZ
    @MRAN_XYZ 20 วันที่ผ่านมา

    But how to avoid chiken egg problem in bootstaping

    • @bvdlio
      @bvdlio  20 วันที่ผ่านมา

      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 🎅

  • @hatchy4439
    @hatchy4439 ปีที่แล้ว +1

    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  ปีที่แล้ว +1

      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

  • @HansBezemer
    @HansBezemer 3 หลายเดือนก่อน

    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.

  • @doublescoopovanilla5835
    @doublescoopovanilla5835 2 หลายเดือนก่อน

    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

  • @Axtriel
    @Axtriel 8 วันที่ผ่านมา

    i didnt understand what does JUMP.EQ.0 and JUMP.GT.0

    • @bvdlio
      @bvdlio  7 วันที่ผ่านมา

      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.

  • @littleslaughters8037
    @littleslaughters8037 8 หลายเดือนก่อน

    What vs code color theme do you use?

    • @bvdlio
      @bvdlio  8 หลายเดือนก่อน

      Jellyfish

  • @mohithguptakorangi1766
    @mohithguptakorangi1766 ปีที่แล้ว +5

    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  ปีที่แล้ว +5

      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  ปีที่แล้ว +1

      @@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 ปีที่แล้ว +1

      @@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: th-cam.com/video/GsCWivTeFpY/w-d-xo.html

  • @gmma
    @gmma 7 หลายเดือนก่อน

    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 6 หลายเดือนก่อน

      Then popping would be have to decrement before returning a value which is odder imo

  • @dharma.vibrates
    @dharma.vibrates 11 หลายเดือนก่อน

    Can we rewrite compiler like beam or there are right reserved to beam compiler ? I am newbie here . Thanks

    • @bvdlio
      @bvdlio  8 หลายเดือนก่อน

      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.

  • @DiamondWolfX
    @DiamondWolfX 9 หลายเดือนก่อน

    Isn't python bytecode-compiled (similar to Java) though? It just throws out the compiled code except for imported modules

    • @coding_pepper
      @coding_pepper 8 หลายเดือนก่อน

      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 8 หลายเดือนก่อน

      @@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 7 หลายเดือนก่อน

      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?

  • @SilverSuperGamer
    @SilverSuperGamer 8 หลายเดือนก่อน

    can't you just use modulus if you're checking if a number is odd or even?

    • @bvdlio
      @bvdlio  8 หลายเดือนก่อน

      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.

  • @BinaryCodeYT
    @BinaryCodeYT 2 หลายเดือนก่อน

    6:38

  • @kingtrigon
    @kingtrigon 4 หลายเดือนก่อน

    its every thing i rizzed about its every thing i fanumed about brain rot language that i can abuse the words

  • @Axtriel
    @Axtriel ปีที่แล้ว

    i have a question, how can i declare variables?

    • @bvdlio
      @bvdlio  ปีที่แล้ว +1

      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.

  • @hamzacasdasdasd
    @hamzacasdasdasd 6 หลายเดือนก่อน

    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

  • @OrangeDied
    @OrangeDied 9 หลายเดือนก่อน

    no way its the langue d'oïl

  • @aryzen2781
    @aryzen2781 6 หลายเดือนก่อน

    now code a little OS with your little language =]

    • @bvdlio
      @bvdlio  6 หลายเดือนก่อน

      Great idea 😂

  • @eggs-yt
    @eggs-yt ปีที่แล้ว +1

    i smell dutch

    • @bvdlio
      @bvdlio  ปีที่แล้ว

      You have a fine sense of smell 😉

    • @eggs-yt
      @eggs-yt ปีที่แล้ว +1

      @@bvdlio :)

  • @code_with_raushan
    @code_with_raushan 2 หลายเดือนก่อน +1

    i am from India a 16 years old boy trying to make a programming language using sanskrit language

  • @cyancaelus6456
    @cyancaelus6456 ปีที่แล้ว +2

    Nah I Want an Official Language. Not a Little Language

    • @bvdlio
      @bvdlio  ปีที่แล้ว +2

      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  ปีที่แล้ว +1

      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

    • @bvdlio
      @bvdlio  ปีที่แล้ว +2

      Work on the "Not a Little Language" interpreter has started 🤙

    • @sagarkakkar4150
      @sagarkakkar4150 ปีที่แล้ว

      I am very excited about this
      When can I expect it to release

    • @bvdlio
      @bvdlio  ปีที่แล้ว +1

      @@sagarkakkar4150Awesome!
      I am hoping 1-2 weeks from now :)