Skip to content
← Back to Community
how do you create a coding language?
Profile icon
hanbot

im very confused can some one tell me?

Voters
Profile icon
hanbot
Comments
hotnewtop
Profile icon
marryjonathan

f you are trying to build your muscles, you are going to lift weights on a daily basis. The same goes for writing. The more writing you do, the better you will get. When you are lifting weights to build muscle, you are going to pay attention to pemburyschoolhousenursery.com technique. The same goes for writing. Since essay writing is a very different style that fiction writing or poetry writing, you will want to practice essay writing techniques.

Profile icon
MocaCDeveloper

A programming language includes multiple steps. There are 2 different types of languages you can make: Dynamic and compiled.

I would suggest using C since C supports memory allocation and is usually the language used when it comes to writing programming languages

A dynamic language is what is called an "interpreted" language. A specific set of instruction repeat for each line of code, which is why interpreted languages are a bit slower than compiled.
A compiled language breaks down the code into binary and then executes that binary.

For interpreted languages, there are 4 main steps:
Lexing,
Parsing,
Syntax Tree,
Runtime

The lexer goes through the file, character by character, and look for any type of punctuation, example '{' or '(', or any keyword, lets say 'function', then tokenizes it.
Tokenizing something means we assign the value of a punctuation or keyword to a specific keyword. So, if we were to write a language in C, we would assign a "token" to a value stored in an enum.
We "tokenize" punctuation and keywords so that it is easier and more relevant in the back-end of the language when it comes to needing to work with the punctuation and keywords

The lexer will feed straight into the parser. The parser is purely your imagination. The parser is where you setup the syntax for your language. The parser is where you use these tokens.

Next, the syntax tree. The syntax tree basically just stores all information, such as variable names, values, function names, functions args etc. The syntax tree is key to the runtime.

The runtime basically just checks over everything, and since it's the last step, I guess you can conclude that this is where the "magic" happens, such as having a variable a that has the value of 10 and you want to print it.
The runtime is by far the most important part of the interpreter due to the fact that it's the prime step of the language where everything actually starts to work. The lexer just tokenizes, the parser just sets up the language, then it's the runtime! The step that enables us to use function calls, print things, use if statements etc!

A compiled language has the first 3 steps of an interpreted language. A compiled language doesn't need a runtime primarily due to the fact that it doesn't need it. All of the instructions picked up by the parser that is being stored in the Syntax Tree is then executed into assembly then compiled down to binary, which is why a compiled language is much much faster.

So yeah, it is quite hectic reading about how to create a programming language, but it is not quite as hard when it comes down to the actual development of the language!

Profile icon
SUHASTADIPARTH1

You can create a programming language using C, C++, or even python.

this is one resource for creating a language in python:
https://www.geeksforgeeks.org/how-to-create-a-programming-language-using-python/

Please mark this answer if it helps.
Thank you.

Profile icon
Kookiez

well, you can create a programming language in other languages, like js, python, and c++. here is a tutorial from the repl.it community:

https://repl.it/talk/learn/Making-your-own-programming-language-with-Python/45767

Profile icon
MocaCDeveloper

@Kookiez

DO NOT USE PYTHON
Python is an interpreted language and is by far extremely slow!

I don't know how to stress this enough, a programming language written in Python is not a programming language, it is literally just text that the Python interpreter interprets and then executes it as Python code.

When you use Python, you are literally just telling the Python interpreter to look for a keyword, and once it finds that keyword do more Python code.
I suggest using Python if you want to see the outlook of your languages syntax. But if you want a fully functional programming, DO NOT use Python. Use C/C++. Python is too high-level and dynamic to create a fully functional programming language. As I have stated, it literally just interprets your "language" as Python code, meanwhile writing a language in C/C++ means you give actual meaning/functionality to each and every ideal featured in the language

Profile icon
Kookiez

@MocaCDeveloper lol yeah i know but if this person wants to write it in python, it's their choice. i personally would recommend the c family if you want a lang.

Profile icon
MocaCDeveloper

@Kookiez

I had to learn C because of the fact I wanted a programming language lmao it kinda sucked but it was a fun experience!

Profile icon
RYANTADIPARTHI

You create a coding language by putting it in the computer, and telling it what to do. So if you want variables, you have to put a new type, like maybe x = int 7, or something. So to make it, the computer has to know about this.

Profile icon
MocaCDeveloper

@RYANTADIPARTHI
Lmao I love the details you used to explain how you do it though