JMPL Devlog #6

New Character Unlocked

August 10th 2025

Tags:

C

JMPL

Programming Language


What's changed?

First of all, bug fixes. After a long battle, with many minor victories along the way, I have finally defeated the garbage collector bugs that plagued JMPL since the introduction of sets. Before the fix, the garbage collector was freeing sets too early, causing invalid read errors. It took a long time to diagnose, but I realised it was because objects were being taken from the stack to be used in operation causing them to be perceived as unnecessary by the garbage collector. If a garbage collection happened in between taking an object from the stack and the creation of a new object during an operation, it would free the object prematurely. Anyway, thanks to some inspiration from tung's clox, which uses a temporary stack for objects being used in operations, all that is fixed!

Next, I added some helpful new native functions. These are type() and input().

The type() function takes in any value and returns a string containing the type of that value. For example,

let S = {1, 2, 3, 4, 5}

let a = 1.5

println(type(S)) // SET

println(type(a)) // NUMBER

The types that can be returned are: BOOL, NULL, NUMBER, FUNCTION, NATIVE, SET, TUPLE, STRING, and CHAR.

The input() finally allows users to input data through the console. So far only text can be inputted as no parsing methods are available right now, but this will change in the near future.

print("Enter your name: ")

let name = input()

println("Your name is " + name)

Finally, I added a new character data type! Characters can be created using single quotes ('') and can store any Unicode value! In terms of code points, that's U+0000 - U+10FFFF.

let a = 'a' // U+0061

let pound = '£' // U+00A3

let biohazard = '☣' // U+2623

let byel = '볠' // U+BCE0

What's next?

With the addition of characters came a few realisations. Up until now, I had been storing strings as essentially byte arrays, which is fine for ASCII, but not for Unicode. As files are encoded using UTF-8, many characters will use multiple bytes, meaning this approach causes problems with string operations such as getting the string's length or a character at an index. Fortunately, Python has solved this problem with its Unicode Objects idea, which stores a variable-sized code point array as well as a UTF-8 encoded byte array. To fix my problem I will be implementing something similar to JMPL, so expect updates on string refactors in the coming weeks!

© 2025 Joel Luckett. All rights reserved.