Sila Dev Log: New Beginning in Haskell
Posted on 20th of September 2024 | 533 wordsPlug: Follow the Sila development here. |
Behind the scenes, I’ve been steadily working on Sila, but some of the early design decisions – or rather, lack of design – are starting to show their limitations. So, I’ve decided to take a step back and revisit the foundation of the project. This time, though, I’m tackling it with a familiar but long-unseen tool: Haskell.
When I initially began building this compiler, I chose Common Lisp out of a personal fondness for the language. That hasn’t changed – I still love working with Lisp. However, as the project evolved, I found myself rethinking certain aspects of its structure and approach. This reflection led me to consider moving the project over to Haskell, a language I once worked with extensively but haven’t used in years.
Why the switch? Part of the motivation is purely practical, but another part is personal. Returning to Haskell after such a long break feels like dusting off an old tool that’s been sitting on the shelf for far too long. I’m eager to revisit its expressive power, and I believe Haskell’s strengths align well with the challenges and design goals I now face with this project.
While Common Lisp is wonderfully dynamic and flexible – especially when working solo – Haskell offers something I now find particularly valuable: a strong, statically-typed foundation. Haskell’s type system provides guarantees that can help me avoid some of the design pitfalls I encountered with the original Lisp implementation. Its purely functional approach also lends itself well to the sort of transformations and abstractions that compiler development requires.
Haskell’s concise and declarative nature is another major draw. Returning to the language after so many years has been a refreshing experience – its functional paradigm allows for more elegant handling of complexity, especially in areas like data structures and state management. Compared to Common Lisp’s more imperative, mutable style, Haskell’s immutability forces me to approach problems from a different angle, often leading to cleaner, more maintainable solutions.
Starting over is never easy, but it’s sometimes necessary for long-term progress. Moving to Haskell allows me to address the shortcomings of the original design in a more structured and rigorous way. With its strong type system and focus on immutability, Haskell offers a fresh perspective that I believe will result in a more robust and maintainable codebase.
Rewriting the compiler in Haskell also gives me the opportunity to dive back into a language that I’ve always admired but haven’t used in a while. This journey back to Haskell has been both challenging and exciting. As I rediscover its features, I’m reminded of why I enjoyed working with it in the first place—and why it’s the right choice for this project moving forward.
Though it may seem like a significant shift from the dynamic world of Common Lisp to the more statically-typed, functional domain of Haskell, I believe this change will ultimately lead to a better-designed compiler. With Haskell at the core, I’m confident the project will be able to grow and scale in ways that weren’t possible with the original implementation.
In the end, it feels good to dust off Haskell, and I’m excited to see how far it will take me in modernizing Sila.
NB: If you want to read earlier posts of this dev log, head over here. |