I'm making a programming language: Lithe
pronounced "liTH"
Lithe is a programming language written in Python currently in early Alpha. Lithe is a interpreted, curly braced, dynamically typed, high level programming language. My way of thinking about it is Python meets C# meets JavaScript. It has the easy syntax of Python, but with multiple features Python is lacking, such as the "++" operator, "let" function, and integer/float indexing. It also doesn't force you into boilerplate code or OOP like C#, C++, C, or Java.
A semi-unique thing about Lithe is that you don't have to indent your code at all. As long as your code is on different lines, the interpreter doesn't notice if you indent blocks or not. Just to be clear you still have to use curly brackets around your code blocks, but apart from that you have flexibility in formatting. As an example of what I mean, here's some valid Lithe code:
Lithe also has support for memory management, and doesn't have a garbage collector. To manually delete a variable use the "free" function and pass in the variable name. You also can chose between 4 different integer sizes, 8 bit, 16 bit, 32 bit, and 64 bit when declaring a integer variable. I recommend only using this on constants though, as any change done to the variable will convert it to a 64 bit variable. But just using the keyword speeds up the program.
Lithe has support for 4 types: integers, floats, strings, and booleans. All types are mutable, and can change under circumstances not made obvious to the user. Such as if you declare a variable 'x' and then give it a value of 2.5. If you now add 2.5 to that variable, the variable converts to a integer. The same thing goes when adding a float to a integer, a float is always returned.
let x = 2.5 # defining x as a float x += 2.5 # adding a float to a float can return a integer print(x) OUTPUT: 3
The while loop will work identical Python's while loop, only brackets are required around the statement and it uses curly braces like the if statement.
let int8 x = 0 # defining x as 0 and a 8 bit integer while (x < 1000) { # will loop back to here until x is equal to 1000 print(x) x += 1 # add 1 to x } # returns back to line 2
The for loop is more close to C# or JavaScript's for loop. When I was first learning programming, the keyword "for" always confused me. I don't understand why this type of loop is called 'for' when it should just be called "loop". So in Lithe, the for loop is now called "loop". The first parameter of the loop is the variable name. The 2nd parameter is what the starting value of the variable should be, the 3rd parameter is how much x should change after every loop around (put in a negative to make it decrease), and the final parameter is what the variable should stop at.
loop (x, 0, 2, 10) { # creates a variable named x, sets its value to 0, and makes it change by 2 until it reaches 10 print(x) }
This program is meant to take in 2 integers from the user, add them together and then print to the screen
print("Welcome to add program!") while (True) { let integer1 = convert.int(input("First number:")) let integer2 = convert.int(input("Second number:")) print("your result is " + convert.str(integer1 + integer2) + "!") } OUTPUT: Welcome to add program! First number:4 Second number:9 your result is 13! First number:
I'm open to here any advice about how I could make this language better, many of the features I have mentioned are not set in stone, and there are many more I haven't mentioned at all such as lists, indexing, OOP, tuples, functions, and the usage of other scripts within a script.
ETA: Late September to November
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.