datafusion note 01
datafusion note
A Computer System Can Be Abstracted as a Function
At the simplest level, a computer program can be modeled as a function:
output = F(input)
However, most real computer systems have state and depend on their environment. A more general model is:
(new state, output) = F(old state, input, environment)
A software engineer’s job is to design, implement, and compose these state-transition functions.
A large system can usually be decomposed into smaller functions:
input
→ F₁
→ F₂
→ F₃
→ output
The output of one function becomes the input of another. Together, these smaller functions form the behavior of the whole system:
F_{\mathrm{system}} = F_3 \circ F_2 \circ F_1
This is similar to building a house or assembling building blocks. We construct a foundation, divide the system into modules, define the interfaces between them, and gradually fill in the implementation details.
Consider a calculator. A simple expression evaluator can be modeled as:
result = evaluate(expression)
Its input is an expression such as:
2 + 3 * 4
Its output is either the calculated result or an error:
evaluate(expression) → Result<number, error>
An interactive calculator is stateful. It may contain the current display value, a stored operand, a pending operator, and a calculation history. Its complete model is therefore:
(new calculator state, display output)
= Calculator(old calculator state, user action, settings)
The calculator can then be decomposed into smaller transformations:
user action
→ input handling
→ expression parsing
→ calculation
→ result formatting
→ display output
Addition, subtraction, multiplication, and division are smaller functions inside the calculation stage. Each function has its own input, output, and responsibility.
This gives us a useful way to understand software systems:
A computer system is a composition of state transformations. Software engineers define the state, input, output, environment, and transformation rules, then organize them into smaller functions that can be understood, tested, and combined.
Different software systems ultimately implement different forms of:
(new state, output) = F(old state, input, environment)
// datafusion是关于什么的f函数