the cedar ledge

Pure Functions in Programming

Date: November 8 2021

Summary: An attempted overview on what is meant by pure functions

Keywords: #pure #functions #functional #programming #archive

Bibliography

Not Available

Table of Contents

  1. How To Cite
  2. References:
  3. Discussion:

The definition of pure is somewhat of a moving target. Pure can mean many things and when applied to programming functions - even more so. Based on querying the Julia community, here was what I understood pure functions to be.

Based on Milewski's definition, "A pure function is one in which the same result is always produced with no side effects given the same input." [1] Cameron Bieganek explained how, in Julia specifically, you can write functions that are "probably" pure. However, there is no real guarantee that a function is actually pure, because it depends on the various methods that have been implemented. I like the notion of "probably" pure as it encapsulates a more pragmatic approach to the internals of a given language. It lets one get away without having to necessarily be completely aware of all the internals when discussing purity.

Finally, pure functions are different from mathematical functions for the reason that mathematical functions map a value to another value. Pure functions written in a programming language involve more than just a mapping. [1]

How To Cite

Zelko, Jacob. Pure Functions in Programming. https://jacobzelko.com/11082021225843-pure-functions. November 8 2021.

References:

[1] B. Milewski, Category Theory for Programmers, Version v1.3.0-0-g6bb0bc0. 2019.

Discussion:

CC BY-SA 4.0 Jacob Zelko. Last modified: May 19, 2024. Website built with Franklin.jl and the Julia programming language.