⬅️ Main page

The Rattlesnake programming language

Rattlesnake is an experimental programming language that explores topics like object capabilities, capture checking, verification, and mutability control. It is compiled to JVM bytecode and the compiler is written in Scala. It is primarily an imperative language, but it also includes ideas from other paradigms (e.g. object-oriented).
I started developing Rattlesnake in 2022, initially as a personal project to learn about compilers and programming language design. I later used it in several academic projects, including a prototype implementation of gradual object capabilities (as part of my master's thesis), and a program verifier (as a course project, together with my project teammates).

🐍 My master's thesis: [thesis] [code] [example program] [language documentation]
🐍 Program verifier: [code] [report] [slides]

An example code snippet in Grattlesnake (the version with gradual object capabilities):


 datatype IntList
 struct IntCons : IntList { head: Int, tail: IntList }
 struct Nil : IntList

 module Stringifier(sep: String, #package Logger, device console, device fs) {
 
     fn printList(ls: IntList) {
         if ls is IntCons {
             console.print(ls.head as String);
             if ls.tail is IntCons {
                 console.print(me.sep);
             };
             printList!(ls.tail);
         } else {
             enclosed {fs} {
                 Logger.log("printed a list");
             }
         }
     }
 
 }