Basics

38 entries

Arrays (indexed/associative) Syntax Demonstrates creating and reading indexed arrays and associative arrays (key-value pairs). Asymmetric Visibility Syntax Public to read, restricted to write — PHP 8.4 public private(set) against read/write splits in 10 languages. Attributes and Annotations Syntax How metadata is attached and who reads it — PHP 8 Attributes surveyed across 10 languages. Autoloading Syntax Demonstrates on-demand class loading; Go and Rust resolve everything statically at compile time and have no runtime autoloading. Variables and types Syntax Demonstrates variable declaration and basic data types: integers, strings, and floats. Closures and anonymous functions Syntax Demonstrates closures capturing outer variables; Java expresses them with lambdas, Rust through its three Fn capabilities. Closure Binding Syntax Who owns the call's context — Closure::bind against rebinding this/the receiver across 10 languages. Constructor Property Promotion Syntax Who writes the boilerplate for you — PHP 8.0 constructor promotion against parameter-to-field shortcuts in 10 languages. Array Value Semantics and Copy-on-Write Syntax What assignment actually does — PHP array value semantics and COW against array assignment in 10 languages. Enumerations (Backed Enums) Syntax PHP 8.1 backed enums: value/name/lookup versus enum models across 10 languages; Rust variants can carry data. Exceptions (try/catch) Syntax Throws and catches an exception, printing the caught message. Fibers Syntax Suspending the whole call stack or just one frame — PHP 8.1 Fiber against the concurrency-primitive spectrum of 10 languages. First-Class Callables Syntax Functions as values — PHP 8.1's `...` syntax against passing behavior as data in 10 languages. foreach by Reference Syntax as &$v writes straight into the array — PHP foreach by reference against traversal write-back in 10 languages. Function definition and call Syntax Defines a function that returns a string and calls it. Generators Syntax Demonstrates lazy sequence generation; Go approximates it with channels plus goroutines, Java with Streams, Rust with iterators. Generators and Lazy Evaluation Syntax Are values produced on demand or precomputed — PHP's lazy yield taught across 10 languages and four schools. if/else conditionals Syntax Demonstrates multi-branch conditionals with if / else if / else. Integer Overflow Syntax The outlier that promotes to float — PHP integer overflow surveyed against overflow strategies in 10 languages. Lazy Objects Syntax State initializes on first touch — PHP 8.4 lazy ghosts and proxies against deferred initialization in 10 languages. Loops (for/foreach/while) Syntax Demonstrates counting for loops, traversal loops (foreach/range/for...of), and while loops. Magic Methods and Metaprogramming Syntax Trigger paths of __get/__set/__call/__toString/__invoke, beside Python dunders, JS Proxy and Rust traits as metaprogramming entries. match expressions Syntax Compares switch and match; PHP match uses strict comparison, Rust match checks exhaustiveness at compile time. Pattern Matching and Exhaustiveness Syntax Expression or statement, exhaustive or not — PHP match surveyed across 10 languages on two dimensions. Named Arguments Syntax Position or name — PHP 8.0 named arguments versus how 10 languages pass parameters. Namespaces and use Syntax Demonstrates namespace organization and importing; each language maps the concept to modules or packages. Namespaces and Module Systems Syntax PHP namespace/use resolution and aliasing, surveyed against Go, Java, Rust, Python and JS module systems; links to spl_autoload_register. Nullsafe Operator (?->) Syntax Is null a type or a value — PHP ?-> chain short-circuiting beside C# ?., JS ?., Rust Option and Java Optional. Operators Syntax Demonstrates common operators: arithmetic, integer division, and modulo. Partial Function Application Syntax PHP 8.6's `?` placeholder — a call expression with holes returns a Closure that only runs once the remaining arguments arrive, contrasted with fixing some arguments in 10 languages. Property Hooks Syntax Properties whose reads and writes run code — PHP 8.4 property hooks against accessors across 10 languages. Readonly Properties Syntax The immutability spectrum — PHP 8.1 readonly versus how 10 languages block reassignment, and when. Reference Variables Syntax Is & an explicit alias or implicit sharing — PHP reference variables against the reference models of 10 languages. String Value Semantics Syntax Who changes after assignment — PHP string value semantics against string mutability in 10 languages. String interpolation Syntax Embeds variables into a string to build a complete sentence. Typed Properties Syntax Who catches the bad type first — PHP 7.4 typed properties against the core runtime-versus-compile-time check across 10 languages. Union Types Syntax Whether 'or' lives in the type or in the branches — PHP 8.0 union types against the type-system expressiveness of 10 languages. Weak Maps Syntax Whether entries follow the object or the map — PHP 8 WeakMap against GC-cooperative caching in 10 languages.