How To Make A True Coding Language: Part 1
h
CSharpIsGud (924)

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

You are viewing a single comment. View All
AmazingMech2418 (1040)

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.

CSharpIsGud (924)

@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

AmazingMech2418 (1040)

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

CSharpIsGud (924)

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

CSharpIsGud (924)

@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

AmazingMech2418 (1040)

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

[deleted]

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

AmazingMech2418 (1040)

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

xxpertHacker (864)

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

xxpertHacker (864)

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

CSharpIsGud (924)

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

xxpertHacker (864)

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

xxpertHacker (864)

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

xxpertHacker (864)

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

JaydenLiu1 (35)

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

CSharpIsGud (924)

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

JaydenLiu1 (35)

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

JaydenLiu1 (35)

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

CSharpIsGud (924)

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

LoganSpong (55)

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