Programming Languages - Functional Programming
Side Effects
to yield actions(e.g. change states) in addition to return values. (i.e. returning values is "main", everything else is "side")
Pure Functions
- no side-effects
- operate on immutable data, do not alter the original input data, but make a copy and transform it from there.
Benefits:
- composable, self-contained and stateless
- code is easier to refactor
- no writes, so no synchronization, no locks, semaphores, mutexes
- result only depend on arguments, easy to test, debug, understand, and reuse
- modeled after mathematics.
- can chain transformations of an immutable collection to its desired result.
- enable lazy evaluation(since it does not depend on states, only inputs)
Functions are First-Class
Functional programming requires that functions are first-class
- functions are treated like any other values; can be passed as arguments to other functions; can be the returned result of a function.
- possible to define and manipulate functions from within other functions.
Higher-order functions (HOFs)
Higher-order functions: functions that take other functions as their arguments. e.g. map
- often used to implement domain-specific languages
- can be usually simulated in object-oriented languages by functions that take function-objects, also called functors
Recommended Reading
SponsoredConcepts
- Overview
- Which Programming Languages To Learn
- Compile Time and Runtime
- Standard Libraries
- Build Tools
- Memory Management
- Zero Cost Abstractions
- Design Patterns
- Constructors
- Compatibility
- Closures
- Functional Programming
- Generics
- String Interning
- Coding Conventions
- Main
- Ranges
- Lambda
- Random
- IO
- Operators
- Built-in
- Constants
- Functions
- Generics
- Print
- Pointers
- Annotations
- Quotes
- Destructuring
- Generators
- Imports
- Iterators
- Testing
- Visibility
- Assignment Semantics
- Slices
- SSA
- Versus
Concurrency
Control Flow
Data Structures

