Making a Programming Language & Interpreter in under 10 minutes!

Поділитися
Вставка
  • Опубліковано 17 жов 2024

КОМЕНТАРІ • 80

  • @bvdlio
    @bvdlio  Рік тому +8

    Making the compiler: ua-cam.com/video/GsCWivTeFpY/v-deo.html

  • @darqed
    @darqed 11 місяців тому +8

    This video is so underrated, really cool!

    • @bvdlio
      @bvdlio  11 місяців тому

      Thank you

  • @Garfield_Minecraft
    @Garfield_Minecraft 8 місяців тому +5

    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  8 місяців тому

      Thats great to hear!

  • @lyou__y_t
    @lyou__y_t 3 місяці тому +3

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

  • @eboatwright_
    @eboatwright_ 9 місяців тому +4

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

    • @bvdlio
      @bvdlio  9 місяців тому +2

      Great to hear!

  • @tidy5156
    @tidy5156 Рік тому +7

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

  • @Tigerseye
    @Tigerseye 6 місяців тому +1

    This is a well made tutorial, thanks!

  • @HansBezemer
    @HansBezemer 26 днів тому

    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.

  • @pieshu
    @pieshu 8 місяців тому +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  8 місяців тому

      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.

  • @Nylspider
    @Nylspider 2 місяці тому

    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  2 місяці тому

      Never too late, I appreciate it :)

  • @anon_y_mousse
    @anon_y_mousse Рік тому +24

    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: ua-cam.com/play/PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y.html
      Highly recommend.

    • @lolcat69
      @lolcat69 8 місяців тому +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 8 місяців тому +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 6 місяців тому +1

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

    • @infernoslayer5393
      @infernoslayer5393 4 місяці тому +1

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

  • @FuneFox
    @FuneFox 8 місяців тому +1

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

  • @ItsSpaceManPlays
    @ItsSpaceManPlays 4 місяці тому +9

    This video is criminally underrated

    • @bvdlio
      @bvdlio  4 місяці тому

      I appreciate that!

  • @PixelLabsX
    @PixelLabsX 5 місяців тому +2

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

    • @bvdlio
      @bvdlio  5 місяців тому

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

    • @PixelLabsX
      @PixelLabsX 5 місяців тому

      @@bvdlio Cool! Thanks for the vid man!

  • @abaga2242
    @abaga2242 3 місяці тому

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

    • @bvdlio
      @bvdlio  3 місяці тому

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

  • @dk4kja8
    @dk4kja8 22 дні тому

    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.

  • @hatchy4439
    @hatchy4439 9 місяців тому +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  9 місяців тому +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

  • @gmma
    @gmma 4 місяці тому

    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 3 місяці тому

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

  • @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: ua-cam.com/video/GsCWivTeFpY/v-deo.html

  • @Rgotto2
    @Rgotto2 11 місяців тому +1

    That was great, nice job

    • @bvdlio
      @bvdlio  11 місяців тому

      Thank you! Cheers!

  • @Sayori251
    @Sayori251 11 місяців тому +2

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

    • @bvdlio
      @bvdlio  11 місяців тому +1

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

    • @Sayori251
      @Sayori251 11 місяців тому +1

      ​@@bvdliour a legend mate

    • @bvdlio
      @bvdlio  11 місяців тому

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

  • @dharma.vibrates
    @dharma.vibrates 8 місяців тому

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

    • @bvdlio
      @bvdlio  5 місяців тому

      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 5 місяців тому

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

    • @bvdlio
      @bvdlio  5 місяців тому

      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.

  • @DiamondWolfX
    @DiamondWolfX 6 місяців тому

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

    • @coding_pepper
      @coding_pepper 5 місяців тому

      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 5 місяців тому

      @@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 5 місяців тому

      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?

  • @YNGSprkzy
    @YNGSprkzy Місяць тому

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

  • @bvdlio
    @bvdlio  11 місяців тому +4

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

    • @chris0617
      @chris0617 10 місяців тому +1

      New sub:)

  • @YNGSprkzy
    @YNGSprkzy Місяць тому

    legendary

  • @littleslaughters8037
    @littleslaughters8037 5 місяців тому

    What vs code color theme do you use?

    • @bvdlio
      @bvdlio  5 місяців тому

      Jellyfish

  • @Axtriel
    @Axtriel 11 місяців тому

    i have a question, how can i declare variables?

    • @bvdlio
      @bvdlio  11 місяців тому +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 4 місяці тому

    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

  • @kingtrigon
    @kingtrigon Місяць тому

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

  • @cyanuranus6456
    @cyanuranus6456 Рік тому +2

    Nah I Want an Official Language. Not a Little Language

    • @bvdlio
      @bvdlio  Рік тому +1

      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  11 місяців тому

      Also, here you can find everything about how to lex, parse, etc more complex languages:
      Learning Resources:
      - @TsodingDaily Porth Series: ua-cam.com/play/PLpM-Dvs8t0VbMZA7wW9aR3EtBqe2kinu4.html
      - SonicTK ASM_Tutorial (@YiLiangSiew) sonictk.github.io/asm_tutorial/
      - @ImmoLandwerth Compiler Playlist: ua-cam.com/play/PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y.html

    • @bvdlio
      @bvdlio  11 місяців тому +2

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

    • @sagarkakkar4150
      @sagarkakkar4150 10 місяців тому

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

    • @bvdlio
      @bvdlio  10 місяців тому +1

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

  • @OrangeDied
    @OrangeDied 6 місяців тому

    no way its the langue d'oïl

  • @eggs-yt
    @eggs-yt 10 місяців тому +1

    i smell dutch

    • @bvdlio
      @bvdlio  10 місяців тому

      You have a fine sense of smell 😉

    • @eggs-yt
      @eggs-yt 10 місяців тому +1

      @@bvdlio :)

  • @aryzen2781
    @aryzen2781 3 місяці тому

    now code a little OS with your little language =]

    • @bvdlio
      @bvdlio  3 місяці тому

      Great idea 😂