The L Programming Language
theangryepicbanana (1623)

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.

About J

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.

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 Docs.pdf).

Examples

Factorial

num: 5
{* (1..num)

Filter numbers between (min, max]

range: 1..10
min: 2
max: 8
range ?> min ?<= max

Prime number checker

num: 17
#(num / (2..num-1) % 1 ?= 0) = 0

Future thoughts

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 are viewing a single comment. View All
theangryepicbanana (1623)

@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 :)