JMPL Devlog #2
Setting a Precedent
July 6th 2025
Tags:
C
JMPL
Programming Language
For the past week, I have been working on the first of many planned features that aim to make JMPL a set theoretic language. From what I've found, this is novel ground in modern language design. The first (and only notable) set theoretic language is the obscure SETL, made in the late 1960s. Although almost every modern language today has set capabilities, very little work has been done on making a newer, purely set-theoretical language. This is my goal for JMPl. However, we are a long way off. I'm still working on the what a purely set-theoretical language looks like so for now I will just be extending my interpreter little by little.
So, what have I been working on? Finite sets of course! More specifically finite sets, tuples and the basic set operations. Sidenote: I know in set theory (specifically ZF) tuples are sets, so tuple notation should just be syntactic sugar for a set. However, it is easier for the interpreter to abstract them as a similar but separate concept as I work on improving the set 'purity' of the language.
What's changed?
Sets are a new structure that is used to store a finite collection of unique, unordered elements. They are immutable and unindexed. Elements of a set can be any value. Current values are numbers, booleans, nulls, strings, functions, sets and tuples. Sets are constructed with curly braces and values are delimited by commas.
let S = {1, 2, 3, 4, 5}
let T = {1, "hi", 3, {3, 4}, 5}
out S // {1, 2, 3, 4, 5}
Tuples (more accurately n-tuples) are a new structure that is used to store a finite collection of ordered elements. They are immutable but can be indexed. Elements of a tuple can also be any value. Tuples are constructed with parentheses and values are delimited by commas. Tuples can be indexed using square brackets (C-style subscript notation). Note: there is currently no singleton tuple as it is indistinguishable from an expression surrounded by parentheses.
let a = (5, 8, 0)
let b = (0, "a")
out b // (0, "a")
out a[0] // 5
Sets come with many operators (keyword or symbol can be used interchangeably):
- intersect or ∩ - returns the intersection of two sets
- union or ∪ - returns the union of two sets
- \ - returns the relative complement of two sets
- subset or ⊂ - returns true if a set is a proper subset of a set
- subseteq or ⊆ - returns true if a set is a subset of a set
- in or ∈ - returns true if a value is a member of a set
Examples:
let S = {1, 3, 4, 5}
let T = {4, 5, 7, 9}
out S ∪ T // {1, 3, 4, 5, 7, 9 }
out S ∩ T // {4, 5}
out S \ T // {1, 3}
out 1 ∈ S // true
out {1, 6} ⊂ S // false
out {1, 3, 4, 5} ⊆ S // true
out #S // 4
out #(1, 2) // 2
out #(-3) // 3
Now JMPL can be used for simple maths problems! Heres a small example of a program:
let S = {}
let i = 0
while i < 10 do
S := S ∪ {i}
i := i + 1
out S // {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
What's next?
Although many of the elementary set operations are covered, there is an important missing feature. Currentlty, I'm working on a way of looping through the elements of a set without order or indexing them.
Other set-related features I'm planning are set-builder notation, sets for primitive data types (ℝ, ℤ, ℕ, 𝔹), and infinite sets, so stick around!