How do I build my own programming language

Hey there How do I build my own programming language?
I know C,C++ and learning python.I cant spend for books, so where can I learn how to make my programming language?

I think before trying to make a new programming language, you should ask yourself why? There are a lot of great programming languages already invented, and - not to sound negative, but - chances are stacked completely against any language you invent being better than what’s already been created. Why do you want to create another?

Just for fun AND it’ll help me to understand the concepts, blah blah!:yum:

Well for start i would use an existing language (python is written in C) but here is a real simple example.

1 Like

If you go with the interpreted route then what you’ll be creating is a virtual machine that executes the code. Most interpreted languages parse the code into something more machine-readable before execution (byte code)

A compiler suggests outputting machine code, this will be specific to a processor architecture and it’s probably not what you want to do. “Compiling” is a rather loose term though, what’s much more reasonable is to compile it into C and then let gcc take care of optimization and architecture details.

I suggest doing something lisp-like (s-expressions) to keep the complexity of your language under control. As I understand it, lisp also happens to be particularly well suited for implementing a language!


1 Like

Thanks but from where can I start?


(I prefer DuckDuckGo myself, but the message stays the same)

If you were making a house, would you be drawing blueprints or building from one? Both? For the blueprint, are you designing how it looks or doing the engineering to make sure it doesn’t fall over? Is it a lego house or the world tallest building? Longest building? Prettiest? Deepest under water?
You’re gonna have to look at a whole bunch of houses and how they are built to make up your mind about what it is you want to do.

Me, I wouldn’t begin by deciding to build a house, I have no idea if that’s something I would enjoy. I’d watch some documentaries to get the general idea of what is involved. Perhaps after having that general idea I’d want to dig deeper into something, but even if I don’t, lying down on a coach isn’t exactly a heavy investment yet I get quite a bit out of it by picking out documentaries in the area I’m interested in that give a decent overview, a road map.


I took a programming logic course a while back. What you need to grasp first is that all code shares the same logic. We used a free program called Raptor. I would recommend that you experiment with this route. You will quickly understand that all languages are inherently the same. Raptor teaches that if your logic is broken your program will not work. Give it a try.

I also had this crazy idea about building a new programming language just for fun few moons ago :slight_smile:

Here are some pointers.

  1. Define the grammar of the language which is essentially the keywords of the language.
  2. Define relationships between keywords
  3. Define program execution flow i.e. is it sequential or concurrent. If sequential, is there support for jumping around the code like labels
  4. Figure out a very good tokenizing algorithm that can help with defining context
  5. How to execute your language script? Would it be a binary file or parsed by an interpreter like in java & python?
  6. Write the compiler (and interpreter, if any)

Following the above steps should get you started with a single file based interpreted language. You can use any programming language to create another one provided it is not for production use as a lot of other factors come into play like memory utilization, concurrency, resource allocation, profiling etc.

Good luck with your project. It might be frustrating at times but do not give up. Let me know how it goes!


What programming language do you prefer?

I would try Golang from Google. The number of keywords are very less compared to other languages and it has a rich library for modern day programming. The downside is, it requires a new way of programming compared to the OO mindset. Keep us posted on how it goes…