Julians, heard you like new languages. Want this?
This was a language I conceptualized. The idea is to make an easy language. The language is supposed to be easy to implement, easy to use, and fast.
The language concept is simple, the preprocessor is itself a programming language, and the compiler is the interpreter for it. The output is the LLVM IR.
The programming language has basic numbers, lambda expressions, goto, eval, and dictionaries. If the function is followed by the {} braces, the code inside becomes another function argument.
So, the function
function("add","a","b"){
return a+b
}
the function “function” is itself a function, and the result would be.
add = ["call":(self,a,b)->a+b]
#add(3,4) == 7
Now, the cool part about the syntax that the code behind braces become a function input is that we can now do…
main(){
for("i",1,10,1){
print(i)
}
}
And the entire code itself would be a function call. When interpreted, this will (if the language actually exists) produce LLVM IR which prints out 1 to 10.
In most languages, you can define functions, but the act of defining how to define a function itself is hardcoded. Here, you have the freedom to do whatever you want. Loop is also just a function that takes in another set of source code.
With the structure of the language itself being malleable, libraries can put in the crazy optimizations they want.
Now, when it comes to memory management? The default behavior is to disallow pointer-to-pointer. This allows escape analysis to be sufficient in cleaning up memory automatically. Memory pools work around this by maintaining an internal array. Each memory pool can have its own internal rule on memory management. Some may require manual cleanup. Others may do an internal GC. Some others might use a borrow checker.
IDK… something like this? It would nonetheless be a correct syntax. Maybe lazy type inference on element type could be done.
main(){
class("some_class","a"){} #class some_class with attribute a
somememorypool(){
for("i",1,10,1){
x = new_int32(10) #10 slots of int_32.
y = new_class(some_class, 15)
z = new(12)
z[0] = 0 #Lazy type inference: Now z is an array of integers.
}
}
}
Then you could abstract more and more on top of it… if the language is real, that is.
What do you think of such a language?