Hi everyone, I would like to open a broader technical discussion regarding the long-term design philosophy of PHP's standard library, specifically focusing on the trade-offs between composable higher-order functions and dedicated native engine functions.
Over recent major versions, modern PHP has embraced functional programming idioms with first-class callable syntax, arrow functions, and generic higher-order operations. While this compositional style significantly enhances code expressiveness and flexibility, it introduces notable architectural considerations: 1. Performance & Engine Overhead: When composing generic higher-order utilities (such as array/string transformers, filters, and mapping operations), what is the acceptable threshold for closure invocation overhead and VM context switching in performance-critical paths? In what scenarios do we consider this overhead significant enough to warrant dedicated, low-level C implementations in the engine? 2. Standard Library Cohesion & API Surface: PHP has traditionally provided rich, specialized functions for common data manipulation tasks. How do we balance keeping the standard library lean and orthogonal versus providing high-utility, specialized native functions that eliminate recurring boilerplate across userland applications? 3. Performance Benchmarking & JIT Optimization: As the JIT compiler matures, should the engine rely more heavily on JIT optimizations to inline higher-order functional patterns, or will specialized native C functions always remain the preferred standard for mission-critical operations? 4. Edge Cases, Type Consistency & Encodings: When designing or evolving standard functions across different data domains (strings, arrays, multibyte handling, streams), what architectural guidelines should we establish to ensure uniform behavior, strict typing semantics, and consistent error handling across the entire API surface? I believe discussing these fundamental trade-offs will help provide clearer guidelines for future RFC proposals and the continuous evolution of PHP's standard library. I look forward to hearing your perspectives and insights. Best regards, Sepehr
