Hey, if you liked this video, I'd really appreciate if you liked the video. You can also subscribe because I'm thinking of doing stuff similar to this in more videos, and you'll see them when they come out.
Check out Lisp (or lisp like languages). Racket was a language we used in school to create our own programming language as a class project. Functional programming is great for building your parser/interpreter (just like how you did with Python). It also opens the door of the functional programming paradigm, which is a rabbit hole in and of itself. What is a monad? And how could you use it to maintain state? ;)
Keep making videos like this and this will eventually make you go viral! I tried doing this sort of thing one time but I gave up after dealing with a lot of bugs.. I find this kind of stuff really intresting and its great to see somebody make a video about this process
The crafting interpreters book is really good and writing your own simple interpeter is actually not that hard. So if you haven't I would definitely recommend following along that part of the book (and all the others as well ;). I am currently reading it and implementing my own little scripting language in rust. Im especially excited about the bytecode representation and I hope that you can successfully continue to work on your little language. 😁
Man this is an old comment but I am reading and learning from this book rn 😂. It is amazing and helped me so much more than online tutorials/explanations to lay out the groundwork. Currently making a small scripting language to run on a microcontroller to be able to have portable apps that I can load on an sdcard and interface with my firmware (I know micropython exists but this has to be a custom solution for my connected peripherals and custom stack)
Well done. The amount of research you did for this is awesome. A project always seems simple from an outside point of view, but most of starting any project is a learning process.
I wrote an interpreter called R-code which ran under PCDOS/MSDOS back in the 80s. The language controlled on-screen robots that would battle in a maze, and it would run up to 5 programs simultaneously. Then in 2012, I designed a language called LIM (Limited Instruction Model or "Less Is More") Which is a Turing complete, robust general-purpose language which has only 24 reserved words. None of that was easy, so I applaud you for sticking with it. All good wishes.
I had to do this recently for a project, me and two guys were building a cryptocurrency on Blockchain from scratch for a class project. We said we would include smart contracts but the professor didn't think we could get the whole project done in time, so we had to prove him wrong. We implemented simple smart contracts by designing a custom programming language used to verify transactions - it was imperative that the language was not Turing complete so that programs were guaranteed to halt. We didn't have gas fees, so if a program didn't halt then nodes would get stuck verifying the transaction and the Blockchain would never progress.
I recently created my own custom interpreted programming language just for a my game I’m making. It’s used to create custom game files for my game, so users don’t have to know any other programming languages to get things working. My situation was different though, There’s only about 14 or so commands with super simple syntax, just a tag system somewhat similar to HTML. I wrote the interpreter in C#, my main programming language. Mainly because I’m too lazy to learn anything else just for a simple project like this lol
Nice work! You've taken the first step into madness. Lift the other and join us in the abyss. >:) Here's a little story about my last venture into it. I understand the pain of writing a language in itself. My last language is an interpreted Lisp. The standard library is written ~95% in itself. Getting it to parse itself would not be a huge problem until the "AST" is generated. This makes me want to define all the base types (various numbers, strings, lists, vectors, symbols, keywords, maps, delays; Most pre-defined in Ruby) as new types inside my lisp. I know how to define them in a moderatly efficient way, but it sounds like a nightmare to get them into the bootstrap module itself. code -> tokens -> reader -> eval In lisp, most structures are created when the reader is running, NOT when it's evaluated. This means, that I can't easily remake vectors during evaluation and then time-travel back to get their definition into the reader. This could be solved by just setting up another layer of runtimes but them I have double the overhead. code -> tokens -> reader -> (eval to set up bootstrap modules -> tokens -> reader -> eval code with new system) Also, if I asked the system "hey, is this variable a vector or a list?", should it look for the Ruby-definition or for the new one? I could try to implement a bytecode-format, which would be easier to parse, to analyse and to run. Nah, the next version will just transpile to Ruby or D. I've done like 3 transpilers before my first interpreter. Should be easier than melting my brain further. I've been at this for a year by now but made no process because seeing the terrible performance (as bad as one would expect from an interpreter written in Ruby) is already demotivating enough. Maybe write a bytecode-format and then transpile that to D? Maybe I should finish the core-language first? Nah. However, it could be fun to write a syntax-analyser in my lisp for itself. The code itself is just a recursive structure afterall. Thanks for reading. :-)
not to mention all the games made with it, world of warcraft is one, fuck someone even made an entire fantasy console that uses lua (pico8) so even if roblox didn't exist, it would still be pretty popular
Bro thats a really good Video and I appreciate the effort you put into making this language. But I think it would've been quite nice to see something from the code with you talking about what you did there and how you came to the solution. Not only talking about "I had lot of bugs" but instead telling us which bugs you've encountered and how you got around them. Appreciate your work. Cheers
running AS another language is totally fine, and there's plenty of other languages that do it, e.g. Haxe and Nim are the ones I can think of off the top of my head
and neither of those are hobby languages or anything, either, btw, although they aren't that popular outside some niches (e.g. haxe is popular with the folks who used to make flash games and such, but not so much for other people, despite being very capable)
I've a programming language in développement as well It parses definitely very differently than normal because I can't comprehend those from actual tutorials and didn't realise I could exploit stacks by version 0.9 so yea I do need some more skills but I'm now 530 builds (version 1.2) in lmao and so far so good
Watching this as I am building my own language as well, and using a similar method of parsing code to another compiler. I definitely agree, comments were much harder than expected! First thing I did after I got the parser to output properly and make sure code was working, was printing text. Next was variables. Then IF statements, then loops, then graphics, and so on
Nice job! You certainly have a lot of dedication to your learning, I'm impressed. I look forward to your upcoming projects :) you've got a sub from me mate. Keep up the good work.
@@user-dh8oi2mk4f typescript added types to javascript, which use a format which is not used by C#, and the rest of his language is very similar to javascript, so your point doesn't stand.
@@ramongonzalezfernandez8904 they were designed by the same person. Maybe it wasn't right to say that one was based off the other, but they are definitely very similar
i love this! ive been trying to make my own language too. right now i know i can make a lexer, but not a good one. it would only just be a load of "if, else..." statements which is slow and not great. so i found a solution, something like this: temp = '' result = [] while i < range(len(program_in_one_string)): char = program_in_one_string[i] if char in [list of unicode space characters]: # ignore basically i += 1 # if we hit a character like "(", "}", ":", etc process it accordingly elif char in [list of your programs delimiters]: result.append(temp) result.append(char) temp = '' i += 1 # essentially if your temp value is in the list of tokens your program uses, append it to the results elif char in [list of all of your langs tokens]: result.append(temp) i += len(temp) temp = '' # otherwise, append the character to temp. else: temp += char i += 1 im extremely happy with my code to be honest and even in python is relatively fast. but its dumb. since a lexer is just a tokenizer but it also adds some helpful values, (like token start and end, type of token sometimes, etc) the code above is more like a tokenizer. the idea is to save time with the lexer, since all you need is to do is to simply get whatever is written on the text file chopped up, and you can determine whether or not its syntactically correct or whatever in the parser or something idk. youd have to likely heavily modify my code above, especially because im on my phone and likely made a typo or something but you get the idea. i found it to be very VERY useful for quick processing times
your issue with bootstrapping is that what you created is not a compiled language. For example, Python is interpreted so if you looked at the source code for Python right now it would be in Cpp or C or whatever it is written in. If you want to make it actually compiled there is a nifty python library called LLVMlite which basically allows you to emit LLVM IR code from python. This way LLVM can handle all the crazy compiler optimizations and stuff while all you have to do is focus on generating the IR code with python. Then you can take the LLVM executable file you generated from the python compiler and use that to bootstrap the language, since its a separate executable that is not relying on another programming language run anymore at this point. LLVM is what Rust, Swift, Julia, Zig and a lot of other big languages use so you don't have to worry about it not being a good tool or whatever.
I made for fun "programming language", that was just fully translating to c++ and then running g++ from command line to create executable from the cpp file by itself. So syntax like python, speed like c++ and fully compatible with all c++ libraries. It just shortened c++, instead of #include , you just used import , instead of std::cout
What did You Use for Making a Computer Programming Language? Visual Studio? Blank Black Computer Screen and Write Small Codings Then Turn Them into Complex Codings and Larger Codings? Or Computer Core Nucleus in a Form of Green Colored Number 0’s and 1’s Called The Computer Binary Code?
I didn't watch much of the video, but I looked at the code and it doesn't look like a real programming language but instead just a thing that converts your syntax to Python code. It's more of an extension of Python with your own syntax, is that right?
Some years ago I was trying to create a scripting language that is almost like C but at the end of a line is the end of your statement If you want to have multiple statements on one line then you would use the semicolon.
Parsing is a solved problem. Use something like flex, gnu bison, or my personal favorite antlr. You can then generate bytecode, or write an interpreter by building an AST from the generated lexer and parsers, parse tree
Languages typically aren't bootstrapped. They're written initially in another language then reimplemented in themselves which is called dogfooding or self-hosting. Not all programming languages dogfood. Most these days use C & C++, often leveraging the LLVM project and easy support for system and 3rd party libraries these languages offer. Many never move away from this, particularly the slower interpreted languages. This includes Javascript & Python. Implementing Javascript or Python in their own languages would have profound negative performance implications, however other choices might be faster, look at the Bun project that boosted the performance of Javascript by implementing it in Zig. It's also unavoidable that an interpreted language running in a VM / interpreter at some point needs to run on the physical hardware. It can't simply be turtles all the way down, so how would you dog food a VM implementation when there is no underlying compiler to native code? If it was written in interpreted code at least something under the hood must be compiled. If you contemplate this you might realize that when compiling a compiler, or even bootstrapping one you rely on archival code in the compiled compiler and that might contain hidden bugs or even malicious code that is not present in the codebase but compiled into the compiler binary. Quite scary and mind bending when you first realize this.
Everyone I have talked to refers to this as bootstrapping. But yes this is an interesting discussion that I had to leave out of the video to save on time.
@@Chadderbox You might be right, when I hear bootstrapping I envision it's starting from nothing or very little and bringing up from almost no features to full functionality. In practice though these tend to be reimplementations after a very functional compiler is already in place and successful using another language, at which point someone considers it worth dogfooding. It is vastly easier to reimplement a language in itself when you have a fully functional compiler before you start.
I am currently making my own programming language in c#, this involves basically creating concepts as to how you can recreate a function that is triggered by code for that language, which sometimes involves practically reconstructing the entire way things work. And even though your language is meant to be simpler and easier to make, what I’ve made and am aiming to make seems so much simpler than what you’re explaining. 😐lol
@@samochreno C# is a pretty good language for writing compilers. It has a very, very good text library, obviously built on .NET Core so portability is guranteed, there are tons of lexer/parser generator libraries (if you don't want to write your own). There are bindings for clanglib and llvm for the backend side of the compiler. The language is well suited for the job.
@@dimitar.bogdanov I was stupid indeed, I think C# is a great language for building a compiler, I don't know why I made that comment, I think maybe because C# is not very good for memory management if he's making an interpreter
What's funny is that there's an entire programming language called english that's not a joke look it up. I have yet to see somebody do something interesting with it
For Pyinstaller, did you bother recompiling the module? It seems like using it directly causes antivirus to flag them (it sure does for me last time I used it).
Yeah, no matter what I do I can't stop your computer registering it as an unknown program. You'll notice most things you make with C/C++ and compile as well will be flagged when you compile them too. Either that or I'm really stupid.
Hey man, I have not looked at your code so idk if u did it this way but to fix the bracket and indentation problem. I would have stored a global variable called x or something and every time it comes across a "{" it increases by 1 and then decreases by 1 at a "}" and then just add 4spaces*x at in front of the character in the indentation so something like this: x = 0 script = """ if (1 == 1) { if (2 == 2) { print("Hello World"); } } """ pythonScript = "" token = ""; for i in script: if token == "print": indents = "" for i in range(0,4*x): indents+=" " pythonScript += indents+"print" token = "" else: if i == "{": x+=1 elif i == "}": x-=1 else: token+=i; Sorry for messy code as I am mainly a c++ developer and I wrote it in the comments and did not try it out also I obviously did not add any detection for function value so it will not detect what you want to print.
@@Chadderbox x = 0 script = """ if (1 == 1) { if (2 == 2) { print("Hello World"); } } """ pythonScript = "" inString = False inComment = False token = ""; for i in script: if token == "print": indents = "" for i in range(0,4*x): indents+=" " pythonScript += indents+"print" token = "" else: if inString == False and inComment == False: if i == "'" or i == '"': inString = True elif i == "#": inComment = True elif i == "{": x+=1 elif i == "}": x-=1 else: token+=i; else: if i == "'" or i == '"' and inComment == False and inString == True: inString = False elif i == "#" and inString == false and inComment == true: inComment = False So something like that?
I think that next time you should do it right way. If you analise comments when converting to tokkens, most problems that you were facing go away. Aond once you have full tree of user pgoram, you can have options to save it in many different formats, or execute it.
Wasn’t Perl the previous king of the spot Python now fills? Autotools is written in it, and most Unix systems come with it preinstalled (so, anything but Windows).
While it’s not anywhere near it’s heyday, a few nuts like me still find it nice (I personally enjoy Raku, but Perl5 works for portability). That said, it’s not always looked at as the best and it can be easily misused (like the C preprocessor, in a way).
I am very impressed at this! is there anything like for loops or while loops or anything else of note? i would love to see this expanded upon but i would (im not forcing you) like to see you to make a game in Java without a game engine. you can do it without any external tools or graphics librarys
oh and i tried running the .exe file but whenever i do it just crashes without me pressing anything... can you please tell me how to propperly (i dont know how to spell dont judge me >:( ) run it thank you!
I'm working more on the language. Loops are fully supported because they are part of python. I might do something in Java eventually, but I don't really see a point considering I've already done it in C#, which is just better Java.
Learn Computer Binary Codes of 0's and 1's in Hexadecimals or Translation. You'll Make a Programming Language. Making a Programming Language is Not Using a Compiler or Lexer in Another Programming Language. You Can Just Learn it from wikiHow I Saw from the Browser. You Should Make a Programming Language by Learning Computer Binary Codes in a Form of 0's and 1's
You should actually make your own programming language, your language right now is just like how typescript is to javascript, your language is to python
This just makes me wonder how computers read binary, and better yet who made binary and how, and how did that person think of making binary and how the system for their pc can read binary and what binary was made in if text editors didn't exist and how the people making binary even knew what they where doing 😳
this is called: microcode. basically, primitive instructions are called in binary. They are read by the hardware. Instead of ones and zeros, 5v and 2v. and some crazy people created "binary libraries", and then some initial text in screen, and then a really simple compiler, and this simple compiler was used to create a better compiler, and a better compi... this comment threw an exception: com.youtube.StackOverflowException: "Stop with recursive comments"
@@Chadderbox and if you could get a custom OS what coding languages will you like and do you want a Mac look or windows look or play with settings and figure out what looks best for you :) I will make you a custom OS
Well, TypeScript is just a transpiler that converts your code to pure JS and people call it a programming language, so yeah, you can assume you made a new language
quite hard to watch the video with all of these bright colours and text for the whole screen not the entirety of the video needs to look like a misterbeast thumbnail
I think I would probably make my own programming language. For one, I don't like semicolons at the end of the line. Because if you accidentally leave out one in your code, your whole program won't compile and you have to go to that one line and add one in. Second, I was writing some C++ one day and I was curious what a program actually looked like in assembly. So I wrote it down and fed it to a decompiler and as it turns out, C++ (when using a library) calls everything and leaves in the rest that won't be used. Kinda like buying a swiss army knife only to use it for opening wine bottles. Also third, while I was watching programming videos, I notice that most programming language look pretty simular to each other and one programming language to the next will mostly have the same stuff from the other.
i disagree. for a free-form language, semicolons are sometimes crucial for parsing, and having them can make things look a bit clearer. relying on context to determine the end of a statement is not a good thing. that's why i hate python because i feel like i cannot write my programs in my style. i cannot seperate a long statement or a function call with . feels like the semicolon-related complains often comes from inexperienced programmers not related but python uses words like 'and', 'or', 'not' as logical operators in contrast to the symbols used in most popular languages. i feel dumber using python, like a toddler
Hey, if you liked this video, I'd really appreciate if you liked the video.
You can also subscribe because I'm thinking of doing stuff similar to this in more videos, and you'll see them when they come out.
Check out Lisp (or lisp like languages). Racket was a language we used in school to create our own programming language as a class project. Functional programming is great for building your parser/interpreter (just like how you did with Python). It also opens the door of the functional programming paradigm, which is a rabbit hole in and of itself.
What is a monad? And how could you use it to maintain state? ;)
Came for programming, stayed for history of the computer 😤
So true, hey quirky question but are you a lizard
@@mrmoist bro you also think he's a lizard. It just makes sense doesn't it?
@@Stondonk you guys are barji-lizardites as well?
Because that's how you extend the video
I timestamped everything, you can skip the 'filler' if you want :)
Keep making videos like this and this will eventually make you go viral! I tried doing this sort of thing one time but I gave up after dealing with a lot of bugs.. I find this kind of stuff really intresting and its great to see somebody make a video about this process
So you’ve made Python, just with semicolons instead of whitespace… I dig it! :)
it looks more like Java...
agree
more like java
infinite reply loop
infinite reply loop
The amount of things which you've achieved in a this short period of time is shocking, well done!
It's like typescript but in python
The crafting interpreters book is really good and writing your own simple interpeter is actually not that hard. So if you haven't I would definitely recommend following along that part of the book (and all the others as well ;). I am currently reading it and implementing my own little scripting language in rust. Im especially excited about the bytecode representation and I hope that you can successfully continue to work on your little language. 😁
Man this is an old comment but I am reading and learning from this book rn 😂. It is amazing and helped me so much more than online tutorials/explanations to lay out the groundwork. Currently making a small scripting language to run on a microcontroller to be able to have portable apps that I can load on an sdcard and interface with my firmware (I know micropython exists but this has to be a custom solution for my connected peripherals and custom stack)
@@dawsonpate7385 Cool! Do you have github/gitlab account where I could look at this?
Well done. The amount of research you did for this is awesome. A project always seems simple from an outside point of view, but most of starting any project is a learning process.
Well said!
Really interesting how you approached it, it seems so clean and efficient.
I wrote an interpreter called R-code which ran under PCDOS/MSDOS back in the 80s. The language controlled on-screen robots that would battle in a maze, and it would run up to 5 programs simultaneously. Then in 2012, I designed a language called LIM (Limited Instruction Model or "Less Is More") Which is a Turing complete, robust general-purpose language which has only 24 reserved words. None of that was easy, so I applaud you for sticking with it. All good wishes.
Your projects sound a lot more impressive than mine. Well done, that is awesome!
You are mad, absolutely amazing though, very cool to make your own language, never realised Python could do so much
I had to do this recently for a project, me and two guys were building a cryptocurrency on Blockchain from scratch for a class project. We said we would include smart contracts but the professor didn't think we could get the whole project done in time, so we had to prove him wrong. We implemented simple smart contracts by designing a custom programming language used to verify transactions - it was imperative that the language was not Turing complete so that programs were guaranteed to halt. We didn't have gas fees, so if a program didn't halt then nodes would get stuck verifying the transaction and the Blockchain would never progress.
For bootstrapping, don't just write the compiler in itself, write each library/module in a different source language. For extra pain:)
I recently created my own custom interpreted programming language just for a my game I’m making. It’s used to create custom game files for my game, so users don’t have to know any other programming languages to get things working. My situation was different though, There’s only about 14 or so commands with super simple syntax, just a tag system somewhat similar to HTML. I wrote the interpreter in C#, my main programming language. Mainly because I’m too lazy to learn anything else just for a simple project like this lol
Nice work! You've taken the first step into madness. Lift the other and join us in the abyss. >:)
Here's a little story about my last venture into it.
I understand the pain of writing a language in itself. My last language is an interpreted Lisp. The standard library is written ~95% in itself. Getting it to parse itself would not be a huge problem until the "AST" is generated. This makes me want to define all the base types (various numbers, strings, lists, vectors, symbols, keywords, maps, delays; Most pre-defined in Ruby) as new types inside my lisp. I know how to define them in a moderatly efficient way, but it sounds like a nightmare to get them into the bootstrap module itself.
code -> tokens -> reader -> eval
In lisp, most structures are created when the reader is running, NOT when it's evaluated. This means, that I can't easily remake vectors during evaluation and then time-travel back to get their definition into the reader. This could be solved by just setting up another layer of runtimes but them I have double the overhead.
code -> tokens -> reader -> (eval to set up bootstrap modules -> tokens -> reader -> eval code with new system)
Also, if I asked the system "hey, is this variable a vector or a list?", should it look for the Ruby-definition or for the new one?
I could try to implement a bytecode-format, which would be easier to parse, to analyse and to run.
Nah, the next version will just transpile to Ruby or D. I've done like 3 transpilers before my first interpreter. Should be easier than melting my brain further.
I've been at this for a year by now but made no process because seeing the terrible performance (as bad as one would expect from an interpreter written in Ruby) is already demotivating enough.
Maybe write a bytecode-format and then transpile that to D? Maybe I should finish the core-language first? Nah.
However, it could be fun to write a syntax-analyser in my lisp for itself. The code itself is just a recursive structure afterall.
Thanks for reading. :-)
even though I didnt understand much I GET THAT YOU PUT A LOT OF WORK IN THIS its just amazing... !!
1:52 Lua is used to program Roblox games, and there are over 20 Million of those, so I wouldn't say Lua died off.
not to mention all the games made with it, world of warcraft is one, fuck someone even made an entire fantasy console that uses lua (pico8) so even if roblox didn't exist, it would still be pretty popular
🤓👆uhm actually roblox uses luau, a fork of lua
Bro thats a really good Video and I appreciate the effort you put into making this language. But I think it would've been quite nice to see something from the code with you talking about what you did there and how you came to the solution. Not only talking about "I had lot of bugs" but instead telling us which bugs you've encountered and how you got around them.
Appreciate your work. Cheers
That's fair. I will remember this for future videos. The code linked in the description if you are curious.
running AS another language is totally fine, and there's plenty of other languages that do it, e.g. Haxe and Nim are the ones I can think of off the top of my head
and neither of those are hobby languages or anything, either, btw, although they aren't that popular outside some niches (e.g. haxe is popular with the folks who used to make flash games and such, but not so much for other people, despite being very capable)
I like Haxe, I don't see much point in Nim though.
you can call it P#
i love how you make your videos look so simple and easy :D Thumbs up!
he didn't even make a real coding language, he made just a python extension
I've a programming language in développement as well
It parses definitely very differently than normal because I can't comprehend those from actual tutorials and didn't realise I could exploit stacks by version 0.9 so yea I do need some more skills but I'm now 530 builds (version 1.2) in lmao and so far so good
0:18 me too, it's pretty hard. I like it, it's pretty fun. Good job bro. (btw my language is not finished yet so yeah)
Good work, I hope your language ends up better than mine!
@@Chadderbox thanks. But your language is 10x better than mine so far XD
@@Twingamerdudesdid u finish it now
@@MuhammadAamir94 yea, it’s called tire, and it’s also rlly rlly buggy but it’s cool
@@Twingamerdudes wow instant reply after 2 years and send the GitHub link of it pls
Watching this as I am building my own language as well, and using a similar method of parsing code to another compiler.
I definitely agree, comments were much harder than expected!
First thing I did after I got the parser to output properly and make sure code was working,
was printing text. Next was variables. Then IF statements, then loops, then graphics, and so on
Thanks for the video
I am also trying to make something similar, but way worse
The subprocess method worked really well
Nice job! You certainly have a lot of dedication to your learning, I'm impressed. I look forward to your upcoming projects :) you've got a sub from me mate. Keep up the good work.
So basically you turned python into javascript
What an awesome channel subbed and keep at it love your presentations.
Thanks :)
snakecase
your:
Okay did
Otheres:
ERROR, why no snake_case
Lol! I wanted to make a programming language, and I did the same thing you did, and it was also in python! Although I gave up because it was too hard.
I cannot love Python either.
Thanks. Very good job. 👏
3:51 that seems closer to typescript than c#
Typescript was based off c#
@@user-dh8oi2mk4f typescript added types to javascript, which use a format which is not used by C#, and the rest of his language is very similar to javascript, so your point doesn't stand.
@@ramongonzalezfernandez8904 they were designed by the same person. Maybe it wasn't right to say that one was based off the other, but they are definitely very similar
I love seeing letters and numbers on my screen 😀
(the most productive thing i’ve ever done)
Pretty cool!
This is awesome!
i love this! ive been trying to make my own language too. right now i know i can make a lexer, but not a good one. it would only just be a load of "if, else..." statements which is slow and not great. so i found a solution, something like this:
temp = ''
result = []
while i < range(len(program_in_one_string)):
char = program_in_one_string[i]
if char in [list of unicode space characters]:
# ignore basically
i += 1
# if we hit a character like "(", "}", ":", etc process it accordingly
elif char in [list of your programs delimiters]:
result.append(temp)
result.append(char)
temp = ''
i += 1
# essentially if your temp value is in the list of tokens your program uses, append it to the results
elif char in [list of all of your langs tokens]:
result.append(temp)
i += len(temp)
temp = ''
# otherwise, append the character to temp.
else:
temp += char
i += 1
im extremely happy with my code to be honest and even in python is relatively fast. but its dumb. since a lexer is just a tokenizer but it also adds some helpful values, (like token start and end, type of token sometimes, etc) the code above is more like a tokenizer. the idea is to save time with the lexer, since all you need is to do is to simply get whatever is written on the text file chopped up, and you can determine whether or not its syntactically correct or whatever in the parser or something idk.
youd have to likely heavily modify my code above, especially because im on my phone and likely made a typo or something but you get the idea. i found it to be very VERY useful for quick processing times
Wow, that was pretty cool
You forgot to mention that Grace Harper also invinted COBOL, which was much more popular than A-ZERO.
This video was really entertaining, can you show an indepth tutorial
The GitHub repo is in the description, I'd recommend looking through that.
your issue with bootstrapping is that what you created is not a compiled language. For example, Python is interpreted so if you looked at the source code for Python right now it would be in Cpp or C or whatever it is written in. If you want to make it actually compiled there is a nifty python library called LLVMlite which basically allows you to emit LLVM IR code from python. This way LLVM can handle all the crazy compiler optimizations and stuff while all you have to do is focus on generating the IR code with python. Then you can take the LLVM executable file you generated from the python compiler and use that to bootstrap the language, since its a separate executable that is not relying on another programming language run anymore at this point. LLVM is what Rust, Swift, Julia, Zig and a lot of other big languages use so you don't have to worry about it not being a good tool or whatever.
I created an interpreter that does not convert the code to python code instead it runs it using a executer I wrote
I made for fun "programming language", that was just fully translating to c++ and then running g++ from command line to create executable from the cpp file by itself. So syntax like python, speed like c++ and fully compatible with all c++ libraries. It just shortened c++, instead of #include , you just used import , instead of std::cout
What did You Use for Making a Computer Programming Language? Visual Studio? Blank Black Computer Screen and Write Small Codings Then Turn Them into Complex Codings and Larger Codings? Or Computer Core Nucleus in a Form of Green Colored Number 0’s and 1’s Called The Computer Binary Code?
You shouldve started with an AST that you get after parsing and then implement a way to convert it to python
I didn't watch much of the video, but I looked at the code and it doesn't look like a real programming language but instead just a thing that converts your syntax to Python code.
It's more of an extension of Python with your own syntax, is that right?
Some years ago I was trying to create a scripting language that is almost like C but at the end of a line is the end of your statement
If you want to have multiple statements on one line then you would use the semicolon.
Very interesting!
So, what's next?
Are you planning to create your own vm for the language or something like that?
I've got no clue, to be honest.
Parsing is a solved problem. Use something like flex, gnu bison, or my personal favorite antlr. You can then generate bytecode, or write an interpreter by building an AST from the generated lexer and parsers, parse tree
I Also Want to Make a Programming Language Just like Bjarne Stroustrup and Guido Van Rossum. They're The Ones Who Made C++ and Python. Robert Made Lua
i wanna do this and i need help cuz ive not gone anywhere
yo, I am also wanting to make a programming language based off python if you could give me some resources to look at that would be sick.
The GitHub repo for the language is in the description, I didn't really use any other resources though.
Did you forget to make a new linux distro because that always comes first
The most impressive part of this video is that you managed to successfully get useful information off of stack overflow
Languages typically aren't bootstrapped. They're written initially in another language then reimplemented in themselves which is called dogfooding or self-hosting. Not all programming languages dogfood. Most these days use C & C++, often leveraging the LLVM project and easy support for system and 3rd party libraries these languages offer. Many never move away from this, particularly the slower interpreted languages. This includes Javascript & Python. Implementing Javascript or Python in their own languages would have profound negative performance implications, however other choices might be faster, look at the Bun project that boosted the performance of Javascript by implementing it in Zig. It's also unavoidable that an interpreted language running in a VM / interpreter at some point needs to run on the physical hardware. It can't simply be turtles all the way down, so how would you dog food a VM implementation when there is no underlying compiler to native code? If it was written in interpreted code at least something under the hood must be compiled. If you contemplate this you might realize that when compiling a compiler, or even bootstrapping one you rely on archival code in the compiled compiler and that might contain hidden bugs or even malicious code that is not present in the codebase but compiled into the compiler binary. Quite scary and mind bending when you first realize this.
Everyone I have talked to refers to this as bootstrapping. But yes this is an interesting discussion that I had to leave out of the video to save on time.
@@Chadderbox You might be right, when I hear bootstrapping I envision it's starting from nothing or very little and bringing up from almost no features to full functionality. In practice though these tend to be reimplementations after a very functional compiler is already in place and successful using another language, at which point someone considers it worth dogfooding. It is vastly easier to reimplement a language in itself when you have a fully functional compiler before you start.
2:08
The 437 lbs mountain gorilla watching this video on the eastern congo basin:
Seeing lua in the trash can in the thumbnail 😢😢
Easily the worst programming language :)
I am currently making my own programming language in c#, this involves basically creating concepts as to how you can recreate a function that is triggered by code for that language, which sometimes involves practically reconstructing the entire way things work. And even though your language is meant to be simpler and easier to make, what I’ve made and am aiming to make seems so much simpler than what you’re explaining. 😐lol
I dont think c# is a good idea for this
@@samochreno its going well so far and its better than java so i think im fine
@@idiotflextech4273 well, good luck
@@samochreno C# is a pretty good language for writing compilers. It has a very, very good text library, obviously built on .NET Core so portability is guranteed, there are tons of lexer/parser generator libraries (if you don't want to write your own). There are bindings for clanglib and llvm for the backend side of the compiler. The language is well suited for the job.
@@dimitar.bogdanov I was stupid indeed, I think C# is a great language for building a compiler, I don't know why I made that comment, I think maybe because C# is not very good for memory management if he's making an interpreter
Impressive. Now make an English compiler.
No u
What's funny is that there's an entire programming language called english that's not a joke look it up. I have yet to see somebody do something interesting with it
@@gachastorys5129 I have heard of it actually but I think I forgor 💀
For Pyinstaller, did you bother recompiling the module? It seems like using it directly causes antivirus to flag them (it sure does for me last time I used it).
Yeah, no matter what I do I can't stop your computer registering it as an unknown program. You'll notice most things you make with C/C++ and compile as well will be flagged when you compile them too. Either that or I'm really stupid.
Using LLVM is cool
Hey man, I have not looked at your code so idk if u did it this way but to fix the bracket and indentation problem. I would have stored a global variable called x or something and every time it comes across a "{" it increases by 1 and then decreases by 1 at a "}" and then just add 4spaces*x at in front of the character in the indentation so something like this:
x = 0
script = """
if (1 == 1) {
if (2 == 2) {
print("Hello World");
}
}
"""
pythonScript = ""
token = "";
for i in script:
if token == "print":
indents = ""
for i in range(0,4*x):
indents+=" "
pythonScript += indents+"print"
token = ""
else:
if i == "{":
x+=1
elif i == "}":
x-=1
else:
token+=i;
Sorry for messy code as I am mainly a c++ developer and I wrote it in the comments and did not try it out also I obviously did not add any detection for function value so it will not detect what you want to print.
It gets more complicated than this when considering comments and strings
@@Chadderbox
x = 0
script = """
if (1 == 1) {
if (2 == 2) {
print("Hello World");
}
}
"""
pythonScript = ""
inString = False
inComment = False
token = "";
for i in script:
if token == "print":
indents = ""
for i in range(0,4*x):
indents+=" "
pythonScript += indents+"print"
token = ""
else:
if inString == False and inComment == False:
if i == "'" or i == '"':
inString = True
elif i == "#":
inComment = True
elif i == "{":
x+=1
elif i == "}":
x-=1
else:
token+=i;
else:
if i == "'" or i == '"' and inComment == False and inString == True:
inString = False
elif i == "#" and inString == false and inComment == true:
inComment = False
So something like that?
I think that next time you should do it right way.
If you analise comments when converting to tokkens, most problems that you were facing go away.
Aond once you have full tree of user pgoram, you can have options to save it in many different formats, or execute it.
You didn't mention FORTRAN
Ok
Wasn’t Perl the previous king of the spot Python now fills? Autotools is written in it, and most Unix systems come with it preinstalled (so, anything but Windows).
Yeah perl was used for a lot of things but people don't really like it from what I can tell.
While it’s not anywhere near it’s heyday, a few nuts like me still find it nice (I personally enjoy Raku, but Perl5 works for portability). That said, it’s not always looked at as the best and it can be easily misused (like the C preprocessor, in a way).
it's an dsl (domain specific language)
Assalomu alaykum bro, Can you realease SFML 2.6 tutorial? Thanks for response in advance
What about Fortran I never heard of A zero much less it being the first high level language
I am very impressed at this! is there anything like for loops or while loops or anything else of note? i would love to see this expanded upon but i would (im not forcing you) like to see you to make a game in Java without a game engine. you can do it without any external tools or graphics librarys
oh and i tried running the .exe file but whenever i do it just crashes without me pressing anything... can you please tell me how to propperly (i dont know how to spell dont judge me >:( ) run it thank you!
I'm working more on the language. Loops are fully supported because they are part of python. I might do something in Java eventually, but I don't really see a point considering I've already done it in C#, which is just better Java.
Look at the readme, it is a command line utility
@@Chadderbox microsoft java*
I hear Lua is very underrated
yea
Learn Computer Binary Codes of 0's and 1's in Hexadecimals or Translation. You'll Make a Programming Language. Making a Programming Language is Not Using a Compiler or Lexer in Another Programming Language. You Can Just Learn it from wikiHow I Saw from the Browser. You Should Make a Programming Language by Learning Computer Binary Codes in a Form of 0's and 1's
Is this comment AI generated?
@@Chadderbox Is That Even an Excuse?
Well, if you can do it then I'd love to see a video of you doing it. If you can do it within the next 3 years I'll be even more impressed.
You should actually make your own programming language, your language right now is just like how typescript is to javascript, your language is to python
If it weren't for this video, I may have never learned that Python supports semicolons. Thank you for enlightening me!
i have a really good(at least for me) programming language idea but im way too stupid to make it
Do not question Legoman69
This just makes me wonder how computers read binary, and better yet who made binary and how, and how did that person think of making binary and how the system for their pc can read binary and what binary was made in if text editors didn't exist and how the people making binary even knew what they where doing 😳
It's pretty nuts.
this is called: microcode.
basically, primitive instructions are called in binary. They are read by the hardware. Instead of ones and zeros, 5v and 2v.
and some crazy people created "binary libraries", and then some initial text in screen, and then a really simple compiler, and this simple compiler was used to create a better compiler, and a better compi...
this comment threw an exception: com.youtube.StackOverflowException: "Stop with recursive comments"
I really don't get why anyone would want to have a line with a single character.
So I Wanted to Do The Same. By Learning Computer Binary Codes of 0's and 1's. So I Can Make a Programming Language
Pov Craig n Dave just taught you about lexemes 😌
Only UK Computer Science students will understand the pain :(
you just made a python preprocessor, but if it makes it better it is good+
“But I want to force you to have semi colons”
Already better than python gg
Hey bro I can help you add really useful stuff like a built in compilers and a decompiler
Do what you want, it's open source.
@@Chadderbox how good are you in coding?
@@Chadderbox and if you could get a custom OS what coding languages will you like and do you want a Mac look or windows look or play with settings and figure out what looks best for you :) I will make you a custom OS
Not very
3:26 to make it extra slow💀
5:22 you parse the comment, well duh, if you'll want to put // in a string, just escape it with \
In the thumb nail: I love how Javascript is still on the podium even if it is in the trash!🤣
One of the best at being the worst!
Well, TypeScript is just a transpiler that converts your code to pure JS and people call it a programming language, so yeah, you can assume you made a new language
Came for the Declan Mckenna brazil riff, stayed for the Scarily accurate Boris Johnson impression.
It's only hard to make a compiled language. Interpreters are EASY.
Wow this is what I was looking to make lol
Interesting
How hard is it?
That sounds wrong😳😳😳
Admit it guys you wanted to make a game engine since the existing ones are too complicated
python is inefficient enough, and youre gonna make it more slow by making an interpreted language in it!
quite hard to watch the video with all of these bright colours and text for the whole screen
not the entirety of the video needs to look like a misterbeast thumbnail
Instead of Making Your Programming Language Using Python. You Can Just Learn Computer Binary Codes in a Form of 0's and 1's
Sounds simmilar to python but also different. Programming accent? 😂
I think I would probably make my own programming language.
For one, I don't like semicolons at the end of the line. Because if you accidentally leave out one in your code, your whole program won't compile and you have to go to that one line and add one in.
Second, I was writing some C++ one day and I was curious what a program actually looked like in assembly. So I wrote it down and fed it to a decompiler and as it turns out, C++ (when using a library) calls everything and leaves in the rest that won't be used. Kinda like buying a swiss army knife only to use it for opening wine bottles.
Also third, while I was watching programming videos, I notice that most programming language look pretty simular to each other and one programming language to the next will mostly have the same stuff from the other.
i disagree. for a free-form language, semicolons are sometimes crucial for parsing, and having them can make things look a bit clearer. relying on context to determine the end of a statement is not a good thing. that's why i hate python because i feel like i cannot write my programs in my style. i cannot seperate a long statement or a function call with
. feels like the semicolon-related complains often comes from inexperienced programmers
not related but python uses words like 'and', 'or', 'not' as logical operators in contrast to the symbols used in most popular languages. i feel dumber using python, like a toddler
Ofc c++ leaves out stuff that isn’t used, the linker isn’t gonna add code that isn’t run.
6:06 no
Dont talk about lua like that :(
Perhaps what you made was a programming dialect
can this language solve, where tf is my dad
No, it returns a NullReferenceException.
@@Chadderbox oh god
What happened? You stopped Uploading!
Unfortunately, I had to get a life 😞- I think my community page has more info.