Project ideas from Hacker News discussions.

Are arrays functions?

📝 Discussion Summary (Click to expand)

3 Prevalent Themes in the Hacker News Discussion

1. Arrays and Functions are Conceptually Equivalent in Type Theory

Many users argued that from a mathematical or functional programming perspective, an array can be viewed as a function mapping an index (domain) to a value (codomain). This equivalence is foundational in functional languages and type theory, where both are defined by their input-output mappings.

"In fact, from wikipedia: 'An n-tuple can be formally defined as the image of a function that has the set of the n first natural numbers as its domain.'" — stevefan1999

"In Clojure, vectors literally are functions. You can supply a vector (~= array) or map any place that a single parameter function is expected." — sethev

"Haskell provides indexable arrays, which may be thought of as functions whose domains are isomorphic to contiguous subsets of the integers." — [Referenced in the discussion]

2. Practical Utility vs. Theoretical Elegance

A recurring debate centered on whether unifying arrays and functions is practically useful or merely an abstract, academic exercise. Proponents highlighted benefits like memoization and language simplicity, while critics argued it obscures performance realities and common programming needs.

"For example this insight explains Memoization. If you know that Arrays are Functions or equivalently Functions are Arrays, in some sense, then Memoization is obvious." — tialaramex

"This is one of those rare times when I read something coming our of the FP community and go 'oh, you mean iterators, we've had those for decades over here in imperative-programming land'" — swiftcoder

"This presumes the framework in which one is working. The type of map is and always will be the same as the type of function. This is a simple fact of type theory, so it is worthwhile to ponder the value of providing a language mechanism to coerce one into another." — d-us-vb

"Industry programmers do not struggle because arrays lack ontological clarity. They struggle because memory hierarchies exist, cache lines exist, branch predictors exist, GPUs exist, deadlines exist." — diimdeep

3. Implementation and Performance Considerations

Many participants moved beyond theory to discuss how the array-function equivalence manifests in real systems, emphasizing that computational performance (e.g., memory access vs. recomputation) and language-specific implementations are critical practical concerns.

"Modern CPUs are usually bottlenecked by memory bandwidth and cache size. So a function that recomputes the value can often be quicker than a look up table, at least outside of microbenchmarks." — VorpalWay

"However the big difference (in most languages) is that functions can take arbitrarily long. Array access either succeeds or fails quickly." — eru

"An array is a data structure that stores pre-calculated values in memory, whereas a function is executable logic that computes a result only when it is called." — dankwizard

"No, the best thing you can do for simplicity is to not conflate concepts. The perpetual idea of mixing data and execution is a misguided search for a silver bullet..." — CyberDildonics


🚀 Project Ideas

ArrayFunc Memoizer

Summary

  • Auto‑generates lookup tables (arrays) for pure functions with small, finite domains.
  • Eliminates manual memoization overhead and mental friction when trading compute for memory.

Details

Key Value
Target Audience Pure‑functional developers, performance‑critical library authors, educators
Core Feature Generates static arrays for pure functions and switches seamlessly between function calls and indexed access
Tech Stack Rust backend, WebAssembly front‑end, CLI tool, Python/JS bindings
Difficulty Medium
Monetization Revenue-ready: $9/mo

Notes

  • HN commenters often lament the “recompute vs pre‑compute” trade‑off; this tool makes the optimization automatic.
  • Aligns with the desire to “harvest the downvotes” by giving a pragmatic utility to the “everything is a function” insight.

FuncArray Visualizer

Summary

  • Interactive REPL that treats arrays as first‑class functions and functions as arrays, visualizing the isomorphism.
  • Provides an intuitive sandbox for experimenting with the array‑function equivalence.

Details

Key Value
Target Audience Students, FP educators, hobbyist programmers
Core Feature Live code editor where you can define an array and call it like a function, and vice‑versa, with visual index ↔ input mapping
Tech Stack React + TypeScript front‑end, Node.js server, WebSocket for REPL
Difficulty Low
Monetization Hobby

Notes

  • Appeals to the same audience that upvoted “Algebra Driven Design” and seeks a hands‑on way to “see everything as a function.”
  • Directly addresses the frustration expressed by users who “cannot stand this framing” by making the concept tangible.

EquivalencyLinter

Summary

  • Static analysis plugin that flags functions that could be expressed as arrays (or arrays that could be expressed as functions) and suggests safe refactorings.
  • Turns the abstract debate on function versus array equivalence into actionable code improvements.

Details

Key Value
Target Audience Library maintainers, performance engineers, CI/CD pipelines
Core Feature Detects finite‑domain pure functions and suggests conversion to static lookup tables; also flags large sparse arrays for functional refactoring
Tech Stack Python mypy plugin, AST transformation, GitHub Actions integration
Difficulty High
Monetization Revenue-ready: $15/mo

Notes

  • Tackles the perennial HN discussion about “undecidable function equality” by providing concrete tooling.
  • Offers a practical solution to the “everything is a function” crowd who wants a way to make the insight usable in real codebases.

Read Later