Clojure 1.13 adds support for checked keys
Clojure unveils its 1.13.0-alpha1 release, introducing significant enhancements for data handling and performance. The highlight is 'checked keys,' a new feature ensuring robust map destructuring by enforcing key presence. This update demonstrates Clojure's continuous commitment to developer experience and efficiency, resonating with HN's appreciation for language evolution and practical tooling.
The Lowdown
Clojure has announced the alpha release of version 1.13.0, bringing several key improvements for developers. This update focuses on increasing code robustness and optimizing internal data structures, particularly concerning map manipulation and collection performance.
- Checked Keys for Map Destructuring: New directives such as
:keys!,:syms!, and:strs!are introduced. These allow developers to enforce the presence of required keys during map destructuring, throwing an error if a key is missing. This significantly enhances type safety and reduces runtime errors related to missing data. - Documentation and Checking: Keys can now be specified after
&in destructuring forms. These keys will not be bound but serve for documentation or additional checking purposes, providing more clarity and control. - PersistentArrayMap Optimization: The threshold for PersistentArrayMaps containing only keyword keys has been increased from 8 to 64 elements before transitioning to PersistentHashMaps. This change improves performance for smaller maps by leveraging the more efficient identity scans of PersistentArrayMaps.
- Java Bytecode Baseline Preparations: The
ACC_FINALdesignation has been removed from static initializer constants, a preparatory step for updating the Java bytecode baseline to align with new verifier checks. - Dependency Updates: The release also includes updates to runtime and test dependencies, ensuring compatibility and leveraging the latest improvements from external libraries.
These enhancements reflect a targeted effort to improve Clojure's reliability, developer ergonomics, and underlying performance. Developers are encouraged to test this alpha release to experience the new features and optimizations firsthand.