Congame

Marc Kaufmann, Central European University

March 2020

  • A strange and strangely infectious flu is spreading

  • Two intrepid travelers meet in a dingy bar in Berlin

  • They make a racket, scheme, and plot

  • Just as the borders are closing, they finalize a blueprint…

Congame

congame is the best experimental economics software written in Racket

Principal Conartists (Connarts)

Marc Kaufmann

  • behavioral economist
  • runs online experiments

Bogdan Popa

  • ‘Some Software Engineer’

Econ Software 101

What I get from oTree

  • Quick development for many use cases
  • Makes the average experiment easy
  • Python and indentation

What I want from congame

  • Code reuse, composability, and extensibility
  • Make the impossible experiment possible
  • Racket and parenthesitis

Today: Racket in production

congame as case study: 10-12k loc, uses many Racket features

  1. Structure of study code
  2. Example of study in action
  3. Racket features used
  4. Unwarranted lessons

Structure of Study Code

  1. A study consists of
    • a list of steps;
    • and transitions between steps.
  2. A step is a name for a substudy or consists of:
    • a handler: a renderer with pre- and post-logic
    • a transition
  3. A transition determines the next step

Example: Dictator Game with Tasks

Let’s show some code in action.

  • composing and reusing especially of tasks

Racket Features

We used most Racket features, many prominently:

  • Contracts
  • Continuations
  • Parameters
  • Macros
  • Generics

Continuations and parameters

Continuations and parameters

Why continuations and parameters?

  • Mindbending! I wanted to understand continuations
    • (I still don’t.)
  • Super convenient
    • Alternative: pass values around via lexical scope

Why not?

  • Mindbending! Hard to understand.
  • Interactions with parameters are subtle.

Contracts are THE BESTEST!

We use them everywhere

  • Great writing code/ease of debugging trade-off
    • good error messages with little overhead
    • easy to change as design changes
  • Can refine them (validate-xexpr)

Downside:

  • Cannot customize error messages

Macros and syntax-parse

It’s Racket, so duh, we used them.

  • But: extra shout-out to error messages of syntax-parse
  • As with contracts, we get so much for so little

Lessons learned in production

(Note: performance is a non-goal)

  1. Get with the plan, use contracts!
  2. Racket libraries work surprisingly well together
    • with dark corners: there be dragons!
  3. Error messages are first order (see point 1)
  4. Racket is pretty feature rich
    • But often requires tailoring beyond my skill