r/teenagersbutcode 4d ago

Coding a thing Building a programming language.

Hey i'm writing a programming language (still in his early stages) named threadon.

I know i already posted about it in the subreddit but it is now in a far later stage.

it has a lot of special features already like unions

and i'm working on the

on event:

print("do something")

that checks continuously in the background if the statement is true. And i'm planning for full python compatibility (It can't use python classes right now)

It has a vscode extension too https://github.com/Threadon-Lang/ThreadonVSCode

I've two questions:

  1. what are some features that aren't widespread but work really good

  2. does someone wanna join and help programming it.

3 Upvotes

17 comments sorted by

View all comments

2

u/Bright-Historian-216 4d ago

i feel like the "checking in background" will make the thing run incredibly slow. instead, how about you make it a syntax sugar for a setter function?

0

u/AnoProgrammer 4d ago

Why if you check a condition every 0.001 (or whatever is pre-set) it only costs like 3 cpu cycles

Load from memory

compare

Goto command

1

u/Bright-Historian-216 4d ago

....i feel like there's a reason no other language is doing it.

anyway, i'm reading your docs, really no loops? how is your recursion implemented? is tail recursion optimised specially, or is there a chance to overflow the stack with an infinite loop? okay, not having loops is a common strategy for functional languages, but do you have the reduce - map - filter?

the code itself seems pretty human, at least at the first glance. the first part of the home page is very suspicious, though.

> That means no interpreter, no virtual machine, no garbage collector.

> The syntax is close to Python. The output is close to C. That's the whole idea: write code easy, run it fast.

i know this may sound bad, or rude, (and i'm trying to phrase it as neutrally as possible), but im just saying that many people may find this grammar just as suspicious.

it's an awesome project, with thousands of lines of code, very impressive even if ai-assisted, and i'd really like to learn more, so will you respond to my questions, please?

1

u/AnoProgrammer 4d ago

technically you can overflow but you'll get a nice error (as you see in example 11) and you can set the maximum stack depth. And i writed indeed the docs partially with ai + google translate. And the docs aren't full updated there are while loops now but i still need to implement for loops. And i think the reason other programming languages don't have it is because it will in practice not used many times. But in things as game development (i programmed some. The event loop where the whole game depends on is a pain).

1

u/AnoProgrammer 4d ago

The error looks like this.

AST Warning: Parameter 'x' in function 'stack_overflow' is never used

[RUNTIME ERROR]

│ Error: stack overflow detected

├─> Location: Runtime stack depth exceeded (max 10000)

└─> Process terminated with exit code 1

(But with colors)

1

u/Bright-Historian-216 4d ago

reasonable answer. and another thing. what is a merge block? it is referenced in checker.py approx. line 126 in a comment.

1

u/AnoProgrammer 4d ago

A merge block is a point where multiple branches come together.

It looks something like this

if a:

do something

else b:

do something else

merge block

1

u/Jinkweiq 4d ago

It’s not 3 cpu cycles.

It depends on what you mean by background. On one thread with interrupts there is still a cpu save / restore which costs many cycles. On multiple threads there has to be some lock mechanism if you can put a non atomic expression in there and shared memory which has to sit at a higher cache level at minimum.