The L Programming Language
The L Programming Language
This is a programming language that I made as my final project for my CS class this past year (for those of you who are curious, I got a 98% on it). It ended up turning out much better than I had expected, so I thought it'd be cool to share it here on Repl Talk.
What is L?
L is an array-oriented programming language made for performing complex operations on large sets of data. It is inspired by languages of the same category such as R, Julia, and J (which was my main inspiration).
While it appears to be an abstract mess of symbols at first, the conciseness of using symbolic operators as opposed to named functions allows you to do more by doing less.
J was my main inspiration for L. I had found J a few months ago after doing some stuff for the APL language mode here on repl.it, mainly because J is highly influenced by APL (minus its Unicode character set).
The core concept in both languages is that you can create new functions by composing existing functions, all of which can either be a unary operator (monadic; takes one value) or a binary operator (dyadic; takes 2 values). While L does not allow you to compose functions (that would have taken way more work and I didn’t have time for that anyways), it does have the monadic and dyad operator features.
Another core concept is that when you perform operations on an array of values, the operation is performed on each value of the array. For example, doing
1 2 3 + 1 will give you
2 3 4 as a result. If you perform a binary operation on 2 arrays of the same length, it will perform the operation on each element of the arrays in parallel. For example, doing
1 2 3 + 4 5 6 will give you
5 7 9.
If I had more time…
If I had more time to work on this, I would have added things like:
- More mathematical operators (log, trig, etc).
- More statistical operators (min, max, average, etc).
- More operators in general.
- “Boxed” sets (that don’t perform operations on every value it has).
- “Flat” sets (opposite of above but one level deeper (if that makes sense)).
- User-defined functions/operators.
- “Lazy” expressions that can be assigned to variables and aren’t evaluated until they’re referenced/used.
- Better documentation.
Because the original documentation for my project is super long (too long for a Repl Talk post), I've included it in the repl files as a PDF (file name is
Filter numbers between (min, max]
Prime number checker
Might try adding more features to this in the future like user-defined functions or something. Also might try rewriting this in Rust since it'd have less boilerplate than doing it like this in C++
You had to create your own programming language for CS class? Damn...
Wait, does your CS class teach C++?
Sense your a moderator, I have a question for you.
Can you report someone for copying someone elses code and then posting it saying they coded it?
@theangryepicbanana hi, i have been longing to talk to a mod ever since I got a moderator warn for something I didn't do :(. So basically, this guy created a bunch of posts on multiple boards with a very inappropriate title and very inappropriate content. I mentioned a moderator to get it removed fast because the report function took forever. I actually mentioned the moderators on all the posts this guy made. But the thing is, the notifications made it look like I made the post and since I mentioned them on posts with the same name, it looked like I was spamming them. Then, because it looked like the post was mine, it looked like I was swearing. And guess what happened? I got warned for swearing and spamming. :/
@ChezCoder Thanks for bringing this to my attention. Have you communicated with the moderators on the Repl.it Discord server about this yet? I wasn't aware of this when it happened, so I can't really determine what did/didn't happen, but the other moderators on the server will probably be more helpful than I can be right now.
I'm currently thinking about making a pi approximator in your programming language, but it seems like this repl only contains a REPL for L, not a full interpreter/compiler. So, how would I read a program from a file and run it in L? Do you have a file reading system somewhere in this repl or another repl or would I have to create my own?
@AmazingMech2418 L had meant to be more of an interactive language, so I didn't really think about running files. You could probably (for now, as I don't have time right now to add this myself) pipe input into the running program (using whatever language you want) so that you can put multiple lines in at a time (I'll also note that you can have multiple expressions on 1 line). If you were to give me a bit, I could probably make a solution myself.
@theangryepicbanana Looking at the docs, it doesn't seem like L natively supports either loops or functions. How could I possibly add loops and possibly functions to L? The only thing I can think of is creating a secondary compiler with loop unrolling that compiles into L and then runs with the unrolled loops, but I don't know if Repl.it could support that (the pi approximation algorithm needs 150,000 iterations).
I've been wanting to make a programming language for a long time now, but could never seem to be able to find any good tutorials. Can you teach me?
@rupinYAY While I am experienced in implementing languages, I cannot go through the design process of your language for you. I also have my own languages that I'd like to work on, so I'd recommend you look at some online tutorials for making languages like craftinginterpreters or MAL if you want some more resources on how to make a language :)
Dude you go to tell me how to make my own language. I can not figure out how to do it. My language that I am making up it is called Crystal!
I would die trying to write 337 lines of code. I barely can do 200.
Here lie Crcoli7307. Cause of death: Writing too much code.
I can't imagine what the poor kids at Microsoft had do go trough, writing 50 million lines of code.
After thoroughly looking at this, I barely remembered that C++ switch cases only allow numbers. That sucks.
Might I suggest using C++'s
<valarray> to have done the same thing and save you some time?
@StudentFires Re: templates, yes we could use them, but we could only use type templates (so we couldn't use literals or constraints in the template parameters). Re: compiler, we were forced to use VS2019 for everything in the course. Re:
.hpp, VS didn't seem to have an option to use
.hpp for headers