~/talk

Never* use arrays

Talkat phpday 2021 · 2021-06-08..06-09· [php]
slides:none on file

Claim: stop using PHP arrays as public data structures and replace them with purpose-built classes, iterables and generators. Examples: type‑safe Sequence, immutable collections, a lazy Collection wrapper around generators; demos take under ten minutes (most under five). Tools shown: array_object, iterable type, generators, PSR‑14, array_map/filter reimplemented. Benchmarks: 1M associative‑array iterations = 9.4s ~0.5GB; class instances use ~53% less memory, stdClass ~20% slower. Result: smaller, safer, often faster code.

AI-written summary · about

  1. 0:00Start
  2. 0:52Larry Garfield
  3. 3:48Arrays Come with an Array of Problems
  4. 4:03Inconsistent Behavior
  5. 6:47Arrays Are Fundamentally a Hack in Php
  6. 10:34Array Object
  7. 13:53Arrays Pass by Value but Objects Pass by Reference
  8. 14:50An Immutable Type Sequence
  9. 15:24Remove a Value
  10. 28:28Immutable Collection
  11. 32:23Associative Arrays
  12. 32:35Lookup Tables and Anonymous Structs
  13. 37:50Anonymous Structs
  14. 47:00Results
  15. 48:57Is It Ever Okay To Use an Array
  16. 55:15What about Configuration Files as Php Arrays
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.