A list of 112 patterns found in computer languages.

Am I missing a pattern? Let me know at feedback@codelani.com.

pattern aka psuedoExample
Abstract Types   abstract class Div {}
Access Modifiers   class Box { private location }
Algebraic Data Type   garageContents = empty | vehicle
Anonymous Functions Lambdas () => doSomething()
Assert Statements   assert(isTrue)
Async Await   async doSomething => await somethingElse()
Binary Operators   1 + 1
Bitwise Operators   3 == (2 | 1)
Block Comments   /* a looong comment */
Booleans   doBabiesSleep = false
Case Insensitive Identifiers   AnYcASE = 2
Central Package Repository Pattern   npm install lani
Classes   class Dog {}
Comments   # a comment
Conditionals   if (isTrue) doSomething()
Constants   const ONE = 1
Constructors   Person: constructor(name: string): {}
Core Language Development Hosted on GitHub   git clone microsoft.com/typescript
undefined   say(message = "Hello")
Dependent types   sortedList // a list where is sorted is true
Destructuring   {name, age} = person
Directives   use strict;
Disk Output   write("foobar.txt", "something")
Dispose Blocks Pattern   with something: do something()
Duck Typing   length() // makes me an iterator
Dynamic Properties   person.age = 50
Exceptions   throw new Error("Uh oh")
Expressions   (1 + 2)
First-Class Functions   [2.1].map(Math.round)
Function Composition   undefined
Function Overloading Ad hoc polymorphism add(string: str, string2: str)
Functions routines or procedures or methods function foo() {}
Garbage Collection   var iDontNeedToFreeThis
Generators   yield 2
Generics   function identity<T>(arg: T): T
Gotos   goto 10
Homoiconic   (list ())
Identifiers   name = Bob
Implicit Arguments   shout(implicit message: string)
Implicit Type Casting   console.log("hello " + 2)
Import Pattern   import package
Increment and decrement operators   i++
Infix Notation   1 + 2
Inheritance   class Box extends Cube
Integers   int score = 28
Interfaces   interface Sendable
Iterators   for a in collection()
Lazy Evaluation   print(range(1000000)[2])
Letter-first Identifiers   seven11 = "OK" // 711 = "ERROR"
Lists array or vector or sequence [2, 3, 10]
Macros   #define height 10
Magic Getters and Setters   get(name) => obj[name]
Manual Memory Management   malloc(4);
Map Functions   [1,2].map(square)
Maps dict or dictionary or object or record or struct or hashtable or keyed list or associative array {name: "Mary"}
Merges Whitespace   result = 1 + 2
Method Chaining   a.toString().length
Methods   hi.length
Mixins   extends structure, paintable
Module Pattern   module Foobar {}
Monad   g >>= f
Multiline Strings   hello = """hello\nworld"""
Multiple Dispatch   collide_with(x::Spaceship, y::Spaceship)
Multiple Inheritance   extends parentWhichExtendsSomethingElse
Namespaces   namespace Stuff {}
Operator Overloading   def __add__(): doSomethingDifferent()
Partial Application   add5 = num => addNumbers(10, num)
Pattern Matching   fib 0 = 1; fib 1 = 1
Pipes   ls | wc
Pointers   int *foobar
Polymorphism   a + "b"; 1 + 2
Postfix Notation   2 3 4 + 2 -
Prefix Notation   + 1 2
Print Statements   print "Hi"
Processor Registers   eax 2
Range Operator   1 ... 10
References   fn(objPointer)
Refinement Types   evenInt where int % 2 = 0
Regular Expressions   /\w+\d?/
Runtime Guards   f x | x > 0 = 1 | otherwise = 0
Semantic Indentation   if true(newline/space)print True
Semaphores   singletonIsSet = 0
Sets   {black, red, yellow}
Shebang   #! /run
Single Dispatch   person.run()
Single-Type Arrays   const scores: int[]
Source Maps   {file: 'min.js',sources: ['one.js'], mappings: 'CAAC,IAAI,IAAM'}
Statements   print Hello world
Static Methods   static bark() {}
Static Typing   int score = 100
Streams   echo 123 | 123.txt
Strings   "hi"
Structs   struct account { int account_number; char *first_name; float balance; };
Supports Breakpoints   debugger;
Switch Statements   switch animal: case dog-buy; case cat-sell;
Symbol Tables   SymbolName|Type|Scope;bar|function,double|extern
Templates   template TCopy(T) {}
Ternary operators   true ? 1 : 0
Threads   thread1(); thread2();
Traits   use redBorder
Triples   Boston isCapitalOf Massachusetts
Type Casting   (float)score;
Type Parameters   function identity<T>(arg: T): T {return arg}
Typed Holes   2 + _ => 2 + [int|float]
Unary Operators   count++
Unicode Identifers   δ = 0.00001
Union Types   any = string | number
Units of Measure   Boston isCapitalOf Massachusetts
Variadic Functions   args.map(doSomething)
undefined   virtual Shout();
While Loops   while (true) loop()
Zippers   zipper.moveLeft()


Last updated August 09, 2020