On this page:
6.1 What is This Assignment’s Purpose?
6.2 Task
6 Control
6.1 What is This Assignment’s Purpose?

Modern languages now have interesting forms of control that go beyond traditional call-and-return, such as pausing the computation and being able to resume it. They make programs much more readable, elegant, and even performant.

Yet you may or may not have been exposed to these features before, and even if you have been, you may not have thought about them systematically. We want you to learn enough about these to compare and contrast them, so you have them in your toolbox when you program in the future.

6.2 Task

In this assignment we will consider four control constructs:
  • generators in Python

  • streams in Java 8

  • goroutines in Go

  • asynchronous functions in JavaScript

What are their relative similarities and differences, strengths and weaknesses? As a prompt, imagine someone approaches you saying they need to write a program that would benefit from these kinds of operators, and they have complete flexibility in language choice. How would you guide them to pick one of these? You may use whatever granularity is easiest: whether as one big table, or a sequence of (up to 6) pair-wise comparisons, or some combination thereof.

In your comparison, ignore all other aspects of the languages: assume the rest of the language is identical, or that these features have been transplanted to an otherwise identical base (like SMoL), as we did for Mystery Languages. The only exception is if a feature from the rest of the language—e.g., types—materially affects how these features work, or if there’s a feature that is routinely used in conjunction with these features. The spirit of this rule is not to be strict, but rather to keep your answers focused (i.e., don’t get distracted by things that have nothing to do with these operations).

You may use any Web resources you wish (within the rules set down in the syllabus). Be sure to credit them appropriately. But beware that many Web sites are written by authors who are underinformed or even wrong, so don’t just take them at their word! Trust but verify.