How to add a new feature to Dark

Paul Biggar
Sep 1 · 2 min read

On Saturday, we had our third contributor meetup, this one was organized by Shahriyar Nasir (thanks Shah!). This time, we did mob coding to add a Tuple type to Dark, and we recorded the whole thing.

Image for post
Image for post

A tuple looks like this:

A tuple allows you to combine multiple values of different types. In the video, we added Tuples to the editor and frontend, including in particular the keystrokes to add, update, and delete tuples. Shah followed up later to add backend support. We hope to get this merged soon.

The video is about two hours, which is about how long it takes to add a language feature to the frontend (it probably takes a similar amount of time to add a feature to the backend). This was straightforward as Tuples have a very similar interaction model to Lists — hopefully other language improvements won’t take too much longer.

Note that if you’re interested in contributing other language features, the issues have a good list of what we need.

Now that tuples exist in the language, we still have make them more usable. We need functions to get the contents, such as Tuple2::getFirst, Tuple2::getSecond, etc. This also highlights that we need to support destructuring: while we currently support destructuring some expression types in pattern matches, we don't support that in let statements. We support:

But we don’t support:

There are quite a lot of functions in Dark that could return Tuples, where we’ve hacked support using other methods. For example, request.headers uses a dictionary (as does the header parameter in HttpClient::get), DB::getAllWithKeys_v2 returns a dictionary, and List::zip returns a list of two-element arrays. These would much more naturally use tuples.

Overall, this is part of fleshing out the language, in order to allow us to build new features without having to hack around an incomplete language. We’ll be doing more of this in the next few months.


You can sign up for Dark here, and check out our progress in these features in our contributor Slack or by watching our GitHub repo. Follow Dark on Twitter, or follow the blog using RSS.

Darklang

Updates on and from Dark — darklang.com

Paul Biggar

Written by

Tech entrepreneur, software engineer. Founder of Dark: https://darklang.com. Founder of CircleCI. Lover of chocolate and pastries.

Darklang

Darklang

Updates on and from Dark — darklang.com

Paul Biggar

Written by

Tech entrepreneur, software engineer. Founder of Dark: https://darklang.com. Founder of CircleCI. Lover of chocolate and pastries.

Darklang

Darklang

Updates on and from Dark — darklang.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store