Search code examples
language-agnosticlanguage-designcode-snippets

Code Examples For Programming Languages


When you are designing a new programming language, or comparing existing programming languages, what types of code examples should you write? They should:

  • emphasize the important features of the language(s)
  • take considerations into important/common features
  • allow learning by examples.

Also, list some simple algorithms that worth to be written as a showcase?


Solution

  • The code examples should:

    • Show how to start a fresh app (ex. Hello World)
    • Show how to do common patterns (ex. Instead of loops, functional languages use tail-recursive calls)
    • Show what makes the language unique/right for certain tasks (ex. Meta-programming in Ruby, Pattern-matching in Erlang)