Discover more from Derw
All branches will diverge from the stem: from Elm to Derw
Forgive the fancy title, but I felt it fit this month’s Derw improvements well. Originally, Derw was intended to be an Elm with better support for TypeScript. As more TypeScript support is added, Derw deviates further from Elm.
To write good, modern TypeScript code, you need to be able to handle async/await properly. No callback hell. To do so in an Elm-like language, the obvious path to follow was do-notation from other ML languages. So, do-notation was added to Derw.
When you’re building string parsers, such as flags from a command line, it’s useful to be able to use untagged unions composed of all possible flags. The Derw compiler, written in TypeScript, uses these in a couple of places: for example, when parsing target output for the compile (ts/js/derw/english/elm). So this feature was pretty nice to have, especially during a rewrite of the compiler that is currently underway (currently at 42% Derw, 58% TypeScript).
With each of these decisions, we stray further from Elm’s design. With each of these decisions, Derw establishes itself as its own thing.
My research at university initially focused on complexity theory: the study of complex systems typically composed of people and organizations. At some point I realized that all the other programming stuff I was doing was more interesting to me, particularly my passion for Elm, type systems and functional programming. So instead, my research switched to an analysis of Elm: how functional programming was shaping the world of frontend development, and how might Elm be used in other places like on the server-side. As part of it I also implemented the first language written entirely in Elm, the first Elm in Elm compiler, and just for fun, a Whitespace compiler.
Complexity theory wasn’t wasted on me, and some of the concepts have helped me at work. But lately I’ve been thinking about how it applies to open source: all the different interactions that users, developers and organizations have when it comes to utilisation and consumption of open source projects. There are many many blog posts that discuss the topic, so I’m not going to dive into it here. The main takeaways I’ve had have been about how to foster a community, my main role in the Elm world. Up until now, there has not been a forum for discussing Derw. People either reach out to me on Twitter, email, or Github issues. Derw is perfectly usable these days, and is in use in many of my work and side-projects. But before I want to foster the community, I want to have in place good rhythms and rituals: a workflow that is accessible to others. Derw is the result of my vision of where Elm could have gone, and it will be my magnum opus. So ensuring the language is consistent, cohesive and comprehensive is important. Every commit takes us closer to the goal, but when the Derw compiler is fully rewritten in Derw, I will release 1.0.0, and open some forums.
Type arguments passed to deeply nested types are kept when generated as TypeScript
Top-level promises keep their type argument
The test runner bach can now run in batches to work around low memory devices like Chromebooks
Untagged unions exist (type People = “me” | “you”)
Add mod operator (%)
Operator parsing is faster, speeding up the overall compiler
The compiler will catch when a case..of is missing a possible branch in top-level functions (i.e all branches must be accounted for)
I’ve been reading The New Turing Omnibus lately, after wishing a while for a return to the theoretical side of programming. It’s a good read, summarized as 66 chapters about different topics in Computer Science, with exercises to do for fun. I’ve been doing the exercises in Derw, which you can see here. It raised a question for me: how can I continue to play with theoretical topics beyond the capacity of my day job? Derw has been an outlet for that for sure, but when I think of the language designers I admire, like Evan, they all have a great understanding of theoretical concepts and often read new papers. So, to facilitate that, I’m hosting a “Computer Science for Computer Scientists” meetup. If you’re in Oslo, sign up and come along.
Article image from https://www.flickr.com/photos/82134796@N03/9727065079