Darklang
Published in

Darklang

How to add a new feature to Dark

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.

A tuple looks like this:

let x = (somevar, "a string", 567)

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:

match someNumber
Ok 5 -> 6
Ok 6 -> 7
Ok num -> num + 1
Err msg -> 0

But we don’t support:

let Ok num = someNumber

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.

--

--

--

Updates on and from Dark — darklang.com

Recommended from Medium

Yet Another Intro to Concurrency in Python

New mFund project: start of SocialMedia2Traffic — derivation of traffic information from social…

Drawbacks of app development using web tech

REST API s

Nec C++ Quiz — 0024

Simplify EMR Provisioning with AWS Service Catalog

In Da Programming: BINDING

Why Public Cloud Fragmentation Adds Complexity

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
Paul Biggar

Paul Biggar

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

More from Medium

Compile Clojure to native binary using GraalVM

PipyJS — A functional style JavaScript engine for programming Pipy

Basics of Git Flow (featuring Emacs and Magit!)