A list of 92 patterns found in computer languages.

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

pattern psuedoExample
Abstract Types abstract class Div {}
Access Modifiers class Box { private location }
Anonymous Functions () => 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
Core Language Development Hosted on GitHub git clone microsoft.com/typescript
Dependent types sortedList // a list where is sorted is true
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 Overloading add(string: str, string2: str)
Functions function foo() {}
Garbage Collection var iDontNeedToFreeThis
Generators yield 2
Generics function identity<T>(arg: T): T
Gotos goto 10
Identifiers name = Bob
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()
Letter-first Identifiers seven11 = "OK" // 711 = "ERROR"
Macros #define height 10
Magic Getters and Setters get(name) => obj[name]
Manual Memory Management malloc(4);
Map Functions [1,2].map(square)
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
References fn(objPointer)
Regular Expressions /\w+\d?/
Runtime Guards f x | x > 0 = 1 | otherwise = 0
Semantic Indentation if true(newline/space)print True
Semaphores singletonIsSet = 0
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
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
Type Casting (float)score;
Typed Holes 2 + _ => 2 + [int|float]
Unary Operators count++
Unicode Identifers δ = 0.00001
Union Types any = string | number
Variadic Functions args.map(doSomething)
While Loops while (true) loop()
Zippers zipper.moveLeft()


Last updated November 16, 2019