On this page:
3.1 What Is This Assignment’s Purpose?
3.2 Ground Rule
3.3 Task
3.4 What Constitutes a WAT?
3 WAT🔗
3.1 What Is This Assignment’s Purpose?🔗

Every programming language tends to accrete strange corners. Often these come about because different features each made sense on their own but do not make sense when combined. We want you to explore these ideas in languages that you already know.

Also, we hope you’ll laugh a bit.

3.2 Ground Rule🔗

You should not use any LLM tools (like ChatGPT) for this. The goal here is to get you to do some research and digging, not to merely regurgitate what we can just as easily do ourselves.

3.3 Task🔗

The WAT talk may be the first instance of programming languages as stand-up comedy (for suitable values of “comedy”).

Watch the talk.

Then find three more behaviors that one might consider surprising in a language in general use. Explain why one might find each of these examples surprising.

A “behavior” may have multiple parts: it may be the juxtaposition of these parts that lead to the surprise. Your three behaviors can come from different languages.

Languages in general use include Python, Ruby, JavaScript, R, Matlab, Java, Julia, Swift, Haskell, OCaml, Erlang, Racket, …. If you want to use a language not in this list, feel free to ask. We’ll most probably say yes. All we’re trying to do is eliminate any truly silly choices (like languages that were invented to be confusing or obfuscated).

The objective of this assignment is to force you to get to know better languages you think you already know (and maybe like). Nevertheless, you are allowed to search on the Web for WAT behaviors. If you include any that you find, make sure to clearly attribute them (otherwise you are plagiarizing). When grading your work, we’ll be pretty underwhelmed if all your work came from Web sources: we really want you to introspect and experiment with programming languages, not only search engines.

In short, make your own WAT talk.We mean that as a euphemism. You’re not being asked to make a video! But hey, if you really want to…

3.4 What Constitutes a WAT?🔗

Think of it this way: if you showed the program to someone reasonably versed in programming and ask them to predict the output, would they
  1. predict it correctly, immediately

  2. predict it correctly, slowly

  3. predict it incorrectly, slowly

  4. predict it incorrectly, immediately

  5. not be able to predict it at all

  6. predict it incorrectly, then look at the "right" answer and say WAT?!?!?!?

Everything from 3 on down is a WAT, with more WAT the lower you go.

(Yes, 3 and 4 are in that order on purpose. See, 4 means you look at it and are immediately sure of what it should be, which means it’s especially misleading that it does something different.)