← Stephen Molyneaux

Shimlang Embeddable Scripting Language

There’s a niche of programming languages that I’m looking to fill. This is the first part of what will (hopefully) be a series of the journey of the development of my little scripting language called shimlang.

The Niche

I want a language with:

There’s more to this design, of course, and I’ll expand on this in future posts. The design has changed a decent amount since the first draft of this post, but I’ll leave this post intact to serve as a quaint relic of the past.

Rust-Like Syntax

“Rust-like syntax” is a wide and not very specific statement, especially when considering the monumental differences between a dynamic language like Shim and a compiled language with a great amount of static analysis like Rust. I’ll write out a few key things to start to form a picture of what it’s like:

fn print_fizzbuzz(n: int) {
    for i in 1..n {
        let out = if i % 15 == 0 {
            "fizzbuzz"
        } else if i % 3 == 0 {
            "fizz"
        } else if i % 5 == 0 {
            "buzz"
        } else {
            i
        };

        print(out);
    }
}

print_fizzbuzz(100);

More explicitly:

Python Semantics

Embeddability

Why not use language X?

There many languages that inspire Shim. Facets of those languages inspire the features that Shim provides.

Groovy

A JVM-based scripting language. It’s a decent language, but the influence of Java and the heavyweight JVM make it unreasonable to package Groovy scripts. It’s my own personal hangups that make me avoid the JVM. I can’t stand seeing the JVM gobble up gigs when it should be using far less, and the OOP-only approach to development is a huge turn-off for most of the sorts of things I write.

Rust

Rust is great and has an obvious influence on the synatax of the language. It’s flaw is that it’s compiled, and won’t work where scripts are needed instead.

Mun

Mun: the scripting language that looks like Rust. It’s neat, and it’s meant to be embedded, but it enforces static typing and the size of standalone binaries is too high since it depends on llvm. My ideal scripting language is gradually typed. That let’s me write quick scripts that need to be robust without sacrificing the ability to be robust when needed.

Swift

While I’ve never used Swift, I often reference it for design inspiration. Code written in Swift looks nice.

Python

Python is easy to read and write, and has many well-designed standard library packages. However, it’s difficult to embed, it’s not small, it’s oriented around statements, and you’re at this whims of the users' environment as to whether your script will work or not. I’ve also had trouble packaging Python as a standalone executable.

Lua

Lua is small, portable, and easily embedded in other systems. However, the syntax and semantics of the language are atypical. It uses base-1 indexing, arrays are sparse, it uses prototypical inheritance, and blocks are denoted with words (if, then, for, do, end, etc.). Prototypical inheritance isn’t bad per se, but always requires some sort of library to wrap it, which yields many separate OOP libraries. The proliferation of libraries to learn isn’t great for picking up a language.

Various Lisp Dialects

The Lisp way of thinking is neat. Code is data, data is code, things are expression-oriented. You can essentially build the language you want to use to solve your problem within lisp itself. However, I don’t want to solve big problems with a DSL. I want to solve little problems.

The syntax of Lisp dialects are also a turn-off for some people. I’m not trying to push a philosophy. I just want to have a language that’s acceptable for the majority of people to read and write.

The Name

The name shimlang comes from my own name: Stephen H. Molyneaux > SHM > shim. It’s also a reflection of how I want to use the language. I see it as a way to fill a gap and to create a interface to a larger work.