Discuss Scratch

Greg8128
Scratcher
500+ posts

Writing your own programming language

Writing a programming language is a fun and very interesting project! You can learn about how computers understand programming languages, and try adding different features to your programming language to figure out what you like.

Here is a tutorial that I like: http://buildyourownlisp.com/ It will teach you how to write a simple Lisp-like programming language from scratch. From there, you can experiment with adding your own features to the language, such as user-defined types. It does use C, but it explains what it uses.

Feel free to share other tutorials, including your own!

My best projects:

Vaibhs11
Scratcher
1000+ posts

Writing your own programming language

Making languages using C is very efficient. Some other languages like python or JavaScript is also easy. In C, strings are entirely considered arrays. But in python, there is the
string[0]
method.
The easiest language you can create/recreate using C is something with one character functions, like bf. Normal languages can take alot more space, there, use other easy languages instead like python. There are some tips I recommend using C to create a programming language:
1) Convert the character to ASCII before comparing it to avoid warnings. Helped me alot.
2) Use string.h, it's obvious and will help you add many features.
3) Add variable types. If it's too complicated, go to JavaScript

gosoccerboy5
Scratcher
1000+ posts

Writing your own programming language

Greg8128 wrote:

http://buildyourownlisp.com/!
Looks cool! I will do that when I have the time!
(why are all the cool websites http )

mybearworld
Scratcher
1000+ posts

Writing your own programming language

I did try to make one once - but within Python, so I guess it isn't a “real” programming language

Signatures are the only place where assets links still work.
Greg8128
Scratcher
500+ posts

Writing your own programming language

Vaibhs11 wrote:

Making languages using C is very efficient. Some other languages like python or JavaScript is also easy. In C, strings are entirely considered arrays. But in python, there is the
string[0]
method.
The easiest language you can create/recreate using C is something with one character functions, like bf. Normal languages can take alot more space, there, use other easy languages instead like python. There are some tips I recommend using C to create a programming language:
1) Convert the character to ASCII before comparing it to avoid warnings. Helped me alot.
2) Use string.h, it's obvious and will help you add many features.
3) Add variable types. If it's too complicated, go to JavaScript
Good advice! That being said, something like bf is easy to make, but hard to use. A different experience, but an interesting one still

mybearworld wrote:

I did try to make one once - but within Python, so I guess it isn't a “real” programming language
Nothing wrong with making it in Python. You can always port the runtime to C or Rust if you need better performance.

My best projects:

ScratchCatHELLO
Scratcher
1000+ posts

Writing your own programming language

any tips on making a language in python? (eg useful modules and how to use them)





ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust



Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
linearlemur
Scratcher
500+ posts

Writing your own programming language

ScratchCatHELLO wrote:

any tips on making a language in python? (eg useful modules and how to use them)

Sly is a good library for writing lexers and parsers: https://sly.readthedocs.io/en/latest/sly.html

I found out how to put letters in cloud variables! https://turbowarp.org/526557379 (I really didn't feel like sharing the project, lol)
gosoccerboy5
Scratcher
1000+ posts

Writing your own programming language

linearlemur wrote:

ScratchCatHELLO wrote:

any tips on making a language in python? (eg useful modules and how to use them)
Sly is a good library for writing lexers and parsers: https://sly.readthedocs.io/en/latest/sly.html
I think ScratchCatHELLO has looked into that before.. (why do I remember that) (thanks ocular search)

Greg8128
Scratcher
500+ posts

Writing your own programming language

ScratchCatHELLO wrote:

any tips on making a language in python? (eg useful modules and how to use them)
You don't really need much. A parsing library might help but you can use a handwritten lexer and parser for simpler languages.

My best projects:

ScratchCatHELLO
Scratcher
1000+ posts

Writing your own programming language

linearlemur wrote:

ScratchCatHELLO wrote:

any tips on making a language in python? (eg useful modules and how to use them)

Sly is a good library for writing lexers and parsers: https://sly.readthedocs.io/en/latest/sly.html

The docs aren’t very detailed from what I remember (and there isn’t really much community documentation) and I couldn’t figure out how to get anything other than statements to actually work right





ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust



Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
linearlemur
Scratcher
500+ posts

Writing your own programming language

ScratchCatHELLO wrote:

linearlemur wrote:

ScratchCatHELLO wrote:

any tips on making a language in python? (eg useful modules and how to use them)

Sly is a good library for writing lexers and parsers: https://sly.readthedocs.io/en/latest/sly.html

The docs aren’t very detailed from what I remember (and there isn’t really much community documentation) and I couldn’t figure out how to get anything other than statements to actually work right

Ply: https://www.dabeaz.com/ply/ply.html

I found out how to put letters in cloud variables! https://turbowarp.org/526557379 (I really didn't feel like sharing the project, lol)
jvvg
Scratcher
1000+ posts

Writing your own programming language

I built a programming language in Java once. The language is called Arrow, and the syntax basically uses text arrows to indicate control flow.

Check it out on GitHub.

The main control structures are:

If statement:
/--< condition //skip the body if this is true
| //body
\-->

Loop:
/-->
| //body
\--< continuation condition

Function:
/--> returntype function(type1 arg1, type2 arg2)
| //body
^ return value


Professional web developer and lead engineer on the Scratch Wiki
Maybe the Scratch Team isn't so badWhy the April Fools' Day forum didn't work last year
Greg8128
Scratcher
500+ posts

Writing your own programming language

jvvg wrote:

I built a programming language in Java once. The language is called Arrow, and the syntax basically uses text arrows to indicate control flow.

Check it out on GitHub.

The main control structures are:

If statement:
/--< condition //skip the body if this is true
| //body
\-->

Loop:
/-->
| //body
\--< continuation condition

Function:
/--> returntype function(type1 arg1, type2 arg2)
| //body
^ return value
Interesting!

My best projects:

Jonathan50
Scratcher
1000+ posts

Writing your own programming language

See chapters 4 & 5 of Structure and Interpretation of Computer Programs. (Why haven't I read through SICP in its entirety and done all the exercises?)

There's a lot of very cool material there, like a logic programming system (like Prolog) which I copied in Snap!.

Not yet a Knight of the Mu Calculus.
Greg8128
Scratcher
500+ posts

Writing your own programming language

Jonathan50 wrote:

See chapters 4 & 5 of Structure and Interpretation of Computer Programs. (Why haven't I read through SICP in its entirety and done all the exercises?)

There's a lot of very cool material there, like a logic programming system (like Prolog) which I copied in Snap!.
Wow, that book is free! Guess I don't have an excuse to not read it then cool!

Last edited by Greg8128 (June 12, 2021 02:15:00)


My best projects:

ScratchCatHELLO
Scratcher
1000+ posts

Writing your own programming language

i had a language idea for a language that has no if statement, loops, functions, etc but only GOTO and GOBACK but it's probably already been done

here's a cool language idea I found: Z (not by me)
instead of writing params horizontally
somefunction a b c
you write them vertically
somefunction a
b
c

there's a bunch of other cool stuff too and I hope this becomes more well-known because it's really interesting





ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust



Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
skymover1239
Scratcher
500+ posts

Writing your own programming language

I have already written a programming language. However, it doesn't feel like a true programming language https://scratch.mit.edu/projects/432421352/
Is there anything I'm doing wrong?



John 3:16 wrote:

For God so loved the world that he gave his one and only Son that whoever believes in him shall not perish but have eternal life
First time a moderator got ninjaed??
500 Posts
Current Mainline projects
AquaCSS - A CSS framework.
Ink - An editor that does, lots of things.
Greg8128
Scratcher
500+ posts

Writing your own programming language

skymover1239 wrote:

I have already written a programming language. However, it doesn't feel like a true programming language https://scratch.mit.edu/projects/432421352/
Is there anything I'm doing wrong?
Having goto statements is OK but it's a good idea to provide more generic control structures (such as loops) that the programmer can use.

My best projects:

gdpr5b78aa4361827f5c2a08d700
Scratcher
1000+ posts

Writing your own programming language

interesting, i really want to learn rust to become an epic gamer and fiddle with things like this.
mybearworld
Scratcher
1000+ posts

Writing your own programming language

I do want to write one (that's actually good), but I kind of stopped and failed after 10 lines. I have another idea how to make it though, let's see when I'll stop working on that one!

Signatures are the only place where assets links still work.

Powered by DjangoBB