7 Control

Many 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. Examples of it include:
  • generators in Python

  • streams in Java 8

  • goroutines in Go

  • asynchronous functions in JavaScript

and more.

Your task for this assignment is to learn enough about the four constructs named above so that you can compare and contrast them. 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.