Skip to content
Sign upLog in
← Back to Community

How To Make A True Coding Language: Part 1

Profile icon
CSharpIsGud

Im making this tutorial series because almost every language i've seen posted to repl talk doesn't use parsing algorithms and I think it would be nice to see some that do. There are a couple flavors of these languages, typically they come in 2 forms
1) They use string splitting and regular expressions

Technically you can call this "parsing" or a language of some sort.
But you will very quickly discover you run into syntax limitations like having to have a separator for a lot of things.
Example:
set:var,Hello World;print:var

2) They do nothing at all but define some classes or variables

I don't know how people get away with this and then tell you to calm down when someone calmly separates what it is from what it isn't. Even when put in the best possible words as to not directly attack the repl itself.

Which is why I have decided to create a tutorial on making a programming language in hopes people start making ones that don't have the above flaws.

This tutorial is going to go bottom to top using no dependencies at all and will show creation of a lexer all the way up to the hand made recursive-descent parser!

The Lexer (or scanner, tokenizer, whatever you wish to call it)

Located in lexer.py

The other components will get their own files as they are created.

Next: https://repl.it/talk/learn/How-To-Make-A-Language-Parsing/39832

Voters
Profile icon
JosefRuzicka
Profile icon
mahekmak101
Profile icon
elburg
Profile icon
glitchish
Profile icon
z80
Profile icon
frissyn
Profile icon
Whippingdot
Profile icon
fuzzyastrocat
Profile icon
Theboys619
Profile icon
programmeruser
Comments
hotnewtop
Profile icon
AmazingMech2418

You do know that there is more than one way to make a programming language, right? Your type one not programming languages are actually programming languages, just without as many powerful functions. For example, you could create a LOLCODE interpreter using split functions and regular expressions and LOLCODE is a programming language. It's not the most useful, but still a language. Same with Forth which is even easier to create an interpreter for. Then, the type two "not programming languages" really aren't programming languages and just created dialects for known languages. However, Clojure is a dialect of Lisp and is considered a separate language, so why couldn't some of what you call "not programming languages" actually be programming languages? For example, the in-development THAIL programming language is really a dialect of Adapt (my programming language which is also in development). Also, please stop arguing with everyone about the things you call "fake". There is still hard work put into it, just maybe not as much as a real OS or full interpreted/compiled programming language.

Profile icon
CSharpIsGud

@AmazingMech2418
Ok yeah, I guess you could consider something like deflang an actual language. But at least deflang does some kind of parsing, tell me how you can make a dialect of a language without any form of parsing at all

Profile icon
AmazingMech2418

@CSharpIsGud
Do you consider Dart a language although it normally just transpiles into JavaScript? Also, a dialect could technically just be a "language" with the same syntax and different function names.

Profile icon
CSharpIsGud

@AmazingMech2418
dart actually compiles, they didn't just rename javascript

Profile icon
CSharpIsGud

@AmazingMech2418
Also he technically didn't make a compiler in 3 lines, he just used the existing one which compiles into python bytecode, so roylat keeps his life savings

Profile icon
AmazingMech2418

@CSharpIsGud
Yes, Dart actually compiles and he didn't make a compiler, but he still renamed the functions which qualifies as a dialect in my opinion.

Profile icon
[deleted]

@CSharpIsGud
jokes on you I dont have any so either way I dont lose anything

Profile icon
AmazingMech2418

@roylatgnail
Honestly, all of my languages use full interpreters. Well, besides Link and XPL which really just use JSON and XML syntax respectively and evaluate the functions to allow you to do something other than store data in JSON and XML.

Profile icon
xxpertHacker

@AmazingMech2418
T.H.A.I.L. never even happened, thus your entire point is invalid.

Profile icon
xxpertHacker

@AmazingMech2418
Dart is it's own language, a whole VM was made just for Dart, it has it's own parser, tokenizer, everything. Dart is normally just transpiled. There are browsers that support Dart natively with improved performance over JavaScript.

Now can we Consider TypeScript a language? No, it's clearly a dialect of JavaScript.

Profile icon
CSharpIsGud

@StudentFires
I mean, typescript has its own parser. its a dialect of javascript in that it inherits most of its syntax and compiles to it, but typescript adds major things javascript just doesn't have, like static typing.

Profile icon
xxpertHacker

@CSharpIsGud
That's it, it ends there. Interfaces are for type checking, types are for type checking, what it calls "function overloading" is the stupidest implementation of function overloading I've ever seen, is just for type checking, templates are just for type checking.

All it is, is JS with types.

Dart has types too, and a whole different syntax, but there's more that syntax and types that make a language unique. Until TS really branches off from JS, it's still just a dialect. It doesn't add anything new.

Whereas, like I said before, Dart has a whole browser dedicated to running it, parsing it, etc. Look at TypeScript, Deno, one of the only TypeScript run-times that I've heard of, barely came out a few months ago.

Profile icon
CSharpIsGud

@StudentFires
true that

Profile icon
xxpertHacker

@CSharpIsGud
It's comparable to using the Python type checking extension, is it still Python? Of course!

Profile icon
xxpertHacker

@CSharpIsGud
TypeScript has room for improvement, let's look at it's function overloading, it just sets up a pattern of types that a function can accept.
Yet, if it's compiled, can't the TS compiler rename the functions before compiling and separate them? I'm sure it could! I can, and I'm sure you can too, so why can't Mircosoft? It wouldn't matter to the developer, since it should all become minified anyways.

Profile icon
JaydenLiu1

@AmazingMech2418
Finally, one nice comment. All of the others are very RUDE!

Profile icon
CSharpIsGud

@JaydenLiu1
Also did you know a python interpreter got 80 upvotes on replit once, can you guess how long it took to make?

Even if you consider renaming a function creating a whole new dialect every time you make a program, I make thousands every day then.

Profile icon
JaydenLiu1

@CSharpIsGud
IDK HOW LONG?!

Profile icon
JaydenLiu1

@AmazingMech2418
I agree about this.
@CSharpisGud
thinks that his way is right and that his way is the way to make a "real" coding language. There are plenty of ways to do something. It's common sense,
@CSharpIsGud
, that people have different beliefs and stuff! Right now you,
@CSharpIsGud
is just being a legit party pooper.

Profile icon
JaydenLiu1

@CSharpIsGud
Not all "real" coding languages have interpreters. Besides, you are being a complete party pooper. Stop. It's common sense, that many people have different beliefs.

Profile icon
CSharpIsGud

@JaydenLiu1
Look, I'm done replying to ignorance. I never said my way is the right way, I said that they should use an actual algorithm instead of faking it with if statements.

There are plenty of parsing algorithms you can use that aren't what I use.
You can act like a chain of if statements is a language all you want, I don't really care(but it still makes me cringe, and I'm being literal with that statement).
Do you know why none of these if statement languages made it into the pl jam? Yeah, I think you do.

It's straight up useless trying to explain to how doing a bunch of if statements or classes in python isn't a language to people that make them because they are always ignorant and grasp at every straw they can to defend their "project" that took them 5 minutes and takes less time for people to get bored of it and not look back.
From calling anything that opposes them "hate" to blindly praising everyone who shares the same narrow mindset.

Profile icon
LoganSpong

@CSharpIsGud
I changed when I read this. Thumbs up. Legit.

Profile icon
CodeSalvageON

im pretty tired of seeing fake langs on talk. they're worse than fake os's

Profile icon
CodeLongAndPros

@CodeSalvageON
I don't think of them as OSes, more of shells.

Profile icon
DynamicSquid

@CodeSalvageON
I think fake OS are worse

std::cout << "Booting up system. Please wait a while\n"; for (int a = 0; a < infinity; ++a) std::cout << a << "% loading...\n";

@CodeLongAndPros
empty shells

Profile icon
KobeFF

@DynamicSquid
LOL

Profile icon
JaydenLiu1

@CodeSalvageON
Are you saying that my coding language, S-SPENSE, is fake? https://repl.it/talk/share/S-SPENSE-11/59234

Profile icon
CSharpIsGud

@JaydenLiu1
Also yes, that's pretty much exactly what he was saying.
programmeruser was being nice when he said it was more of a shell than a language, because that's basically what it is.

if (PORTin == "pythn"): Python = input ("") if (Python == "print"): Print = input ("") print (Print)

I mean come on, look at it. This is basically all it is.

Profile icon
JaydenLiu1

@CSharpIsGud
What do you mean

Profile icon
CSharpIsGud

@JaydenLiu1
Python and basically every other language use parsing algorithms, not a thousand line long chain of if statements.

Why do you think people call them fake in the first place?

Profile icon
JaydenLiu1

@CSharpIsGud
What if the creator never said it was a "real" coding language, huh? Have you thought about THAT?

Profile icon
JaydenLiu1

@CodeSalvageON
That's kinda mean and rude at the same time...

Profile icon
JaydenLiu1

@CSharpIsGud
I neither ever said it was real nor fake. I just said it was a coding language I developed.

Profile icon
CSharpIsGud

@JaydenLiu1
Its either a coding language or it isn't, there is no such thing as a fake one, because it wouldn't be a language any more.

Profile icon
CSharpIsGud

@JaydenLiu1
Exactly, you said it was, but it isn't.
What's ironic is all of the "hate" begins as a simple statement that it isn't what they said it was, the creators and people that make them are the ones that immediately get super defensive.

Profile icon
JaydenLiu1

@CSharpIsGud
I DIDN'T SAY S-SPENSE IS A REAL CODING LANGUAGE! CAN YOU GIVE ME SOME PROOF?

Profile icon
JaydenLiu1

@CSharpIsGud
HOW MANY TIMES DO I HAVE TO SAY THIS TO MAKE YOU LISTEN? I NEVER SAID IT WAS A CODING LANGUAGE!!!

Profile icon
CSharpIsGud

@JaydenLiu1
DUDE SEARCH FOR PEOPLE WHO ACTUALLY MADE A LANGUAGE WITH A PARSER

READ THE CODE

a bunch of if statements isn't a language

Profile icon
CSharpIsGud

@JaydenLiu1
S-SPENSE is a coding language I developed

Profile icon
CSharpIsGud

@JaydenLiu1
By the way, the python interpreter that got 80 upvotes, was done in probably less than 30 seconds if they typed fast.

print(eval(input()))
The people that defended the above cycle farm are people like you who simply don't understand that you can't just make a bunch of if statements and call it a language.

Profile icon
JaydenLiu1

@CSharpIsGud
Dude! Stop quoting me!

Profile icon
JaydenLiu1

@CSharpIsGud
"How to make a REAL Coding Language"

Profile icon
JaydenLiu1

@CSharpIsGud
"Fake coding languages"

Profile icon
JaydenLiu1

@CSharpIsGud
"Just a bunch of if statements isn't a REAL language"

Profile icon
JaydenLiu1

@CSharpIsGud
So what? You're just being a party pooper! If it got 80 upvotes then it gets 80 upvotes!

Profile icon
CSharpIsGud

@JaydenLiu1
Now stop filling my notifications with cringe. It's not worth trying to explain how print(eval(input())) is not something that should get 80 upvotes to someone who will just use every excuse possible to say how it took lots of effort and hard work to type one line of python.

Profile icon
JaydenLiu1

@CSharpIsGud
"Cringe"

Profile icon
CSharpIsGud

@JaydenLiu1
You know what, just to make you stop filling my notifications, I will make a replica of your "language" in 30 minutes or less.

Profile icon
JaydenLiu1

@CSharpIsGud
Okay fine you are just gonna copy code from S-SPENSE and paste it onto your project

Profile icon
CSharpIsGud

@JaydenLiu1
Nope, completely from scratch. its just a bunch of if statements. I might even have time to spare to add in some extra things too because it isn't that difficult.

Profile icon
JaydenLiu1

@CSharpIsGud
Is this what you mean by "Interpreter"? https://repl.it/@JaydenLiu1/CodingLanguageInterpreterThingy#main.py

Profile icon
CSharpIsGud

@JaydenLiu1
Far from it

Profile icon
JaydenLiu1

@CSharpIsGud
What's wrong with it?

Profile icon
CSharpIsGud

@JaydenLiu1
It's just if say in command, its not like you can do math equations or anything like that without pythons help.

Even basic bash(echo "Hello World!") does more parsing than that.

Profile icon
CSharpIsGud

@JaydenLiu1
https://repl.it/@CSharpIsGud/S-SPENSE Done.
Removed a lot of redundant code, added an if statement to add two numbers and still could do more with 6 minutes to spare.

Profile icon
JaydenLiu1

@CSharpIsGud
Can't I just create a function that does that? Wait, that won't help.

Profile icon
JaydenLiu1

@CodeSalvageON
"im pretty tired of seeing fake langs on talk. they're worse than fake os's"

Profile icon
CodeSalvageON

@JaydenLiu1
yes, they are. Fake languages suck, and they really suckkkkkkkk