awesome-pl-concepts
awesome-pl-concepts copied to clipboard
An menu/quick reference for Programming Language concepts
| Rationale | Convention | Contributing | TODO |
Note: some features doesn't have a name, I have to coin it out. That said, please make a PR if you find better term for them.
By topic
-
Caching: Caching with Reactive Invalidation
-
Calculus: Dot Calculus, Lambda Calculus, Symmetric Interaction Calculus, Term Rewriting, Turing Machine
-
Code Generation: Hygienic Macro, Lisp Macro, Reader Macro
-
Dependency: Fragment Based Code Distribution
-
Design Pattern: Async/await, Continuation Passing, Message Passing, Trait
-
Pattern Matching: Active Pattern, Pattern matching, View Pattern
-
Evaluation: Compile-time Code Evaluation, Lazy Evaluation
-
First Class: First Class Date, First Class Module, First Class Regex, First Class Type
-
Memory Management: Garbage Collection, Ownership, Reference Counting, Memory Safety
-
Mutitasking: Async/await, Coroutine, Green Thread, Symmetric Interaction Calculus, Free Parallelism
-
Paradigm: Functional Programming, Logic Programming
-
Polymorphism: Row Polymorphism
-
Property: Referential Transparency
-
Subsystem: Datalog, Module
-
Syntax Sugar: Automatic Broadcast Implementation, Chained Try, For Comprehension, Generalized Update Syntax, Universal Function Call Syntax
-
Type: Algebraic Data Type, Capability Safety, Class Invariant, Dependent Type, Effect System, Generalized Algebraic Data Type, Gradual Typing, Linear Type, Nil Fallthrough, Reference Capabilities
List of features
Actor Model
Active Pattern
Algebraic Data Type
Async/await
- Description: A syntax sugar for writing asynchronous concurrent code that looks serial.
- Implementation: JavaScript async-await
- Videos: Fireship: The Async Await Episode I Promised
Automatic Broadcast Implementation
- Description: Given a definition
f: a -> band a functorM,f: M a -> M bis implemented automatically. - Implementation: Chapel, Matlab array and matrix semantic (partial)
- Articles: Hillel Wayne - Microfeatures I'd like to see in more languages
Caching with Reactive Invalidation
- Description: Caching the result of function, invalidating the data reactively when the cache are potentially outdated.
- Implementation: Skip Caching with reactive invalidation
Capability Safety
- Description: A property that functions cannot access data besides that reachable via their closure, their inputs, and global constants. Generally implied by referential transparency, and incompatible with mutable global variables.
- Implementations: Pony, Monte, Wyvern
Chained Try
- Description: A generalization of optional chaining in JavaScript. A language construct that accepts a series of blocks where each block will be executed only if the previous blocks yield an error.
- Example Usage:
try {
assert user_exists(name)
current_user = get_user(name)
assert user_not_banned(current_user)
do_lots_of_stuff_with(current_user)
} {
deny_login_of_user(name)
}
// Replacing if-and-bind, like Python's walrus operator:
try {
match = regex.search("\d+(\d)", text)
assert match
process_numbers(match[0])
} {
match = regex.search("\w+(\d)", text)
assert match
process_letters(match[0])
} {
print("No match.")
}
// Replacing complicated conditions that would otherwise be in a single line.
try {
assert user.age > 18 and user.has_feature_enabled
assert user.has_billing_account and user.get_credits() > 0
assert user.get_last_payment().age_in_days < 90
process_as_premium_user()
} {
process_as_normal_user()
}
// Replacing nested catch blocks:
try {
response = fetch_from_network(resource_id)
assert response.network_success
value = response.value
} {
assert resource_id in offline_cache
value = offline_cache[resource_id]
} {
print("Failed to get resource. Use manual value?")
response = user_input("Resource override: ")
assert not response.cancelled
value = response.value
} {
raise Error('Network not available and ID {resource_id} not in offline cache.')
}
print(value)
Class Invariant
- Constraints of specific types that gets ran across function calls to ensure the data is in correct shape.
- Implementation Ada type invariant
- Articles: Riccardo Bernardini - Reasons for loving Ada: Type invariants (because bugs shouldn't sleep...)
Compile-time Code Evaluation
- Description: Evaluation of code at compile time.
- Implementation: Zig comptime, Konna 2LTT
Continuation Passing
- Description: a pattern in which the state of an executing program may be captured and passing around, resume on demand.
- Implementation: Scheme continuation
Coroutine
- Description: A syntax sugar for structuring cooperative concurrent code modularly.
- Implementation: Lua coroutine
Datalog
Dependent Type
- Articles:
Dot Calculus
- Articles: Essense of Scala
Effect System
- Description: A system similar to type system, but tracks side effects instead of type of the value.
- Implementation: Koka effect system
- Articles: Stephen Diehl - Exotic Programming Ideas: Part 3 (Effect Systems)
First Class Date
- Implementation: Frink Date/Time Handling
First Class Module
- Description: Modules are treated as structs
- Implementation: 1ML, Zig, Ocaml First class module
- Articles: Stackoverflow - What (exactly) are "First Class" modules?
First Class Regex
First Class Type
Fragment-based Code Distribution
- Description: A compiler infrastructure that identify codes fragment by its hash.
- Implementaion: Haskell fragnix, Unison hash identified AST
- Articles: Big Technical Idea on Unison
Free Parallelism
- Description: Parallelism is imposed implicitly by the langauge runtime.
- Implementation: Futhark, HVM
For Comprehension
Formal Methods
- Description: A series of techiques that helps proving the behavior of the program
- Implementation: Coq proof assitant
Functional Programming
Garbage Collection
- Description: A system that free unused heap-allocated memory in runtime
- Implementation: Common Lisp
Generalized Algebraic Data Type
Generalized Update Syntax
- Description: for any binary operator function
f : a -> a -> a, we can rewritea = f a basa f= b - Implementation: Noulith generalized update syntax
- Articles:
Gradual Typing
- Description: A type system that checks some expresions/variables at compile time while leaving others to the runtime type checker.
- Implementation: Typescript
- Articles:
Green Thread
- Description: An abstraction that allow easily writing preemptive concurrent code, without actually using OS thread
- Implementation: Java green thread
Hygienic Macro
- Description: Lisp macros that follows lexical scope.
- Implementation: Scheme Hygienic macro
Lambda Calculus
- Implementation: pLam
Lazy Evaluation
- Description: Any portion of the code is evaluated only when needed.
- Implementation: Haskell lazy evaluation
Linear Type
Lisp Macro
- Description: Compile-time AST-based code generation in a homoiconic and dynamically-typed language.
- Implementation: Common Lisp macros
Logic Programming
- Implementation: Prolog
Memory Safety
Module
Message Passing
- Implementation: Erlang concurrent programming, Smalltalk
Nil Fallthrough
- Description: A generalization of optional chaining in JavaScript, where any operation on nil will always yield nil.
- Articles:
Object Capabilities
- Description: See Capability safety
Ownership
- Description: A system that helps compiler decide when to free heap-allocated memory statically by annotating the ownership of heap allocated variables to entities in the program.
- Implementation: Rust ownership
Pattern matching
- Description: A structural way for obtain data from complicated data structures.
- Implementation: Haskell pattern matching
Reader Macro
- Description: Macro system that gets called by the reader, before AST is formed.
- Implementation: Common Lisp, Elixir Sigils (this is a weaker alternative to reader macro) )
Reference Capabilities
- Description: A type system feature in which each reference carries a modifier to the capabilites, which can describe whether reading or writing is allowed, and whether these features are isolated to this reference.
- Impelementation: Pony
Reference Counting
Referential Transparency
- Description: A property for a function where: 1. returns the same for identical arguments; 2. has no other side effects.
Row Polymorphism
- Description: A polymorphism that dispatch on concerned record fields and their type.
- Implementation: OCaml row polymorphism
- Articles:
- Paper: Objective ML: An effective object-oriented extension to ML
Symmetric Interaction Calculus
- Description: A calculus similar to Lambda Calculus, that can be implement concurrently due to its support for projection and duplication.
- Implementation: HVM
- Articles:
- Papers:
Term Rewriting
- Implementation: Mathematica
Trait
- Description: An interface that allows writing type safe code on different types.
- Implementation: Haskell typeclass, Rust trait
Turing Machine
Universal Function Call Syntax
- Description: A syntax sugar for function call that makes chaining function calls easy.
- Implementation: D UFCS, Elixir pipe operator, Clojure threading macro