Last week, on the 27th of April, issuu held a meetup for Copenhagen Tech Polyglots. Around 30 people got together for talks, pizza and beer. Topics of the day included an introduction to dependent types in Idris; and Brainfuck, an esoteric programming language.

Close-up of David

David Christiansen, a PhD student at ITU, started off with a very interesting talk about Idris. This language supports dependent types, which allows you to encode information in the type system that would traditionally only be enforced at run-time. For example, it is possible to specify that a function should accept only lists of a fixed length, and then have a type system guarantee that all applications of the function will only be in a context where the list argument has that length. More advanced examples could be defining an AVL tree that the type system guarantees will always be balanced. The talk was similar to one David did at Galois, which can be found on Vimeo.

Jan introducing Brainfuck

The second part of the talk – by Jan Krag – covered the esoteric programming language Brainfuck, which basically implements a Turing Machine with a language with single-character instructions. There is a (conceptually infinite) memory, a memory pointer and an instruction pointer. The instructions for the memory pointer are move left (<); move right (>); increment the value by one (+); decrement the value by one (-); print the ASCII value of the value at the pointer (.); and input a character from stdin (,). There is a “branch-if-zero” ([ and ]) instruction as well. Jan entertainingly walked us through a program that could print polyglots.dk\n to the console on the whiteboard. The program is shown in the listing below:

+++++++++
[
  >+++++ ++++        (9*9 = 81)
  >+++++ +++++ +     (9*11 = 99)
  >+++++ +++++ ++    (9*12 = 108)
  >+++++ +++++ +++   (9*13 = 117)
  >+++++             (9*5 = 45)
  >+                 (9*1 = 9)
  <<<<<<-
]                    Result: 0 81 99 108 117 45 9
>
-.           P = 80 = 81 minus 1
>>+++.       o = 111 = 108 plus 3
---.         l = 108 = 111 minus 3
>++++.       y = 121 = 117 plus 4
<<++++.      g = 103 = 99 plus 4
>.           l = 108
+++.         o = 111 = 108 plus 3
>-----.      t = 116 = 121 minus 5
-.           s = 115 = 116 minus 1
>+           . = 46  = 45 plus 1
<<<---.      d = 100 = 103 minus 3
>----.       k = 107 = 111 minus 4
>>>+.        newline = 10 = 9 plus 1

As an encore, David started live-programming an Idris implementation of a Brainfuck interpreter, with several of the participants following along with questions and suggestions.

Below are a few pictures from the event:

David presents Idris Emacs buffer showing Idris code Slide with the title 'Heterogeneous Lists' Jan executing Brainfuck code