Functions in math and programming

LORY
8 min readSep 2, 2023

Are they the same?

Today I talked with a friend who has a math degree. and we talked about something in common in both programming and mathematics — function.

Which was a very interesting discussion.

Are they the same?

Yes and no.

First, let's talk about programming. after a decade of programming with 5+ languages, I found that programming itself is always a kind of building some system, and function is one part of the work — get things done.

Let’s break down further.

To programming, the function is a piece of “computation abstraction component” in a larger system

It’s hard to describe what programming actually is, let me try my best.

Programming is to:

  • Build a system
  • We design and find the relationships between different components or modules
  • Further breakdown into smaller abstraction pieces.
  • Identify the control or flow(common abstraction. generic type, GC, async, multi-processing, MVC, MVP, design patterns, etc.) and logic (changes. business logic). separation of the control and logic.
  • Generalization of the flow control (becomes framework); and making logic easy to change. repeat by applying SOLID principles and best practices.
  • Keep reducing technical depts to reduce the overall entropy regularly and keep the house clean

Across different languages, I find that function is the “smaller abstraction piece”.

The programming function focuses on the process

By writing a function, we mean

Just gets things done.

  • in “procedure style” programming, we split the work into different functions to finish the logic flow.
def login(username, password):
sanitize_input(username, password)
res = validate_in_db(username, password)
return res

Positioning into a system as a piece of abstraction

  • When you code the “OO way”, the function is focused more on the abstraction structure and design. every function has an “access descriptor”…

--

--

LORY

A channel which focusing on developer growth and self improvement