Update to the popular scripting language for web development also offers enhancements for concurrency and performance. Credit: Kevin Ku PHP 8.1, billed as a major update to the popular scripting language for web development, has been released with capabilities ranging from enums and read-only properties to first-class callable syntax. PHP 8.1 was released on November 25. Source code and Windows binaries can be downloaded from php.net. Enums, or enumerations, allow developers to define a custom type that is limited to a discrete number of possible values. This can be helpful when defining a domain model by “making invalid states unrepresentable,” according to PHP documentation. In PHP, enum cases are valid objects that can be used anywhere an object may be used, including type checks. Other new features and improvements in PHP 8.1: Fibers provide primitives for implementing lightweight concurrency. With first-class callable syntax, closures for callables can be created using the syntax myfunc(…), which is identical to Closure::fromCallable('myFunc'). The <a href="https://wiki.php.net/rfc/readonly_properties_v2" rel="nofollow">readonly</a> property modifier prevents modification of a property after initialization. Performance has been improved with a JIT (just in time) compiler back end for ARM64, inheritance cache, fast-class name resolution, and improvements to the standard library file system iterators. With initializers, objects now can be used as default parameter values, static variables, and global constants, along with being used in attribute arguments. This effectively makes it possible to use nested attributes. Intersection types can be used when a value needs to satisfy multiple type constraints simultaneously. Developers can declare final class constants, so they cannot be overridden in child classes. It is now possible to write octal numbers with the explicit 0o prefix. A never return type indicates the function does not return. Arrays can be unpacked with string keys. New classes, functions, and interfaces have been introduced, including an attribute for #[ReturnTypeWillChange]. Passing null to non-variable internal function parameters is deprecated. PHP 8.1 follows by nearly a year the release of PHP 8.0, which offered features such as union types and just-in-time compilation. Also new to PHP this month was the formation of the PHP Foundation, a non-profit organization intended to ensure the long life and prosperity of PHP, with members such as JetBrains and Zend. Participants will donate to cover salaries for PHP core developers. Related content news Go language evolving for future hardware, AI workloads The Go team is working to adapt Go to large multicore systems, the latest hardware instructions, and the needs of developers of large-scale AI systems. By Paul Krill Nov 15, 2024 3 mins Google Go Generative AI Programming Languages analysis And the #1 Python IDE is . . . PyCharm, VS Code, and five other popular Python IDEs duke it out. Which one do you think takes home the prize? By Serdar Yegulalp Nov 15, 2024 2 mins Python Programming Languages Software Development news JDK 24: The new features in Java 24 21 features are proposed for the next version of Java including quantum-resistant cryptographic keys designed to secure Java apps against future quantum computing attacks. By Paul Krill Nov 15, 2024 11 mins Java Programming Languages Software Development news Rust Foundation moves forward on C++ and Rust interoperability Problem statement released to address the challenges to making cross-language development with C++ and Rust more accessible and approachable. By Paul Krill Nov 14, 2024 2 mins C++ Rust Programming Languages Resources Videos