A functional utility library for Apex (Salesforce) inspired by Lodash and Ramda.js, enabling functional programming patterns.
R.apex is a functional utility library for Salesforce's Apex programming language, inspired by Lodash and Ramda.js. It provides tools to overcome Apex's limitations in functional programming, such as the lack of first-class functions, by enabling function currying, composition, chaining, and collection manipulation. It solves the problem of writing verbose, imperative Apex code by allowing developers to adopt a more declarative and composable functional style.
Salesforce developers and Apex programmers who want to write cleaner, more maintainable code using functional programming principles. It's particularly useful for those familiar with JavaScript functional libraries like Lodash or Ramda who are working within the constraints of the Apex language.
Developers choose R.apex because it uniquely brings robust functional programming capabilities to the Apex ecosystem, which natively lacks these features. Its API is heavily inspired by popular JavaScript libraries, reducing the learning curve, and it offers both composition and chaining styles to fit different coding preferences.
Functional utility library for Apex
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides Lodash-inspired methods like map, filter, and reduce for lists, enabling readable data transformations without verbose loops, as shown in examples for sorting accounts or combining lists.
Supports both compose (right-to-left) and pipe (left-to-right) to combine small functions into complex operations, allowing for modular and reusable logic, illustrated in the arithmetic composition example.
Offers a fluent, jQuery-like chaining interface for sequential data transformations, making code more intuitive, as seen in examples like reversing lists or plucking IDs from records.
Simulates first-class functions via Func objects with currying and partial application, enabling higher-order functions that Apex natively lacks, detailed in the HelloWorld and AddFunc examples.
Only supports Set<String> and Map<String, Object> due to Apex's casting restrictions, as admitted in the Known Limitations, which hinders use with other collection types common in Salesforce.
Creating custom functions requires extending the Func class and overriding exec methods, adding verbosity compared to lambda expressions in modern languages, as shown in the AddFunc example.
Uses renamed functions for reserved keywords (e.g., doMap instead of map) and has caveats like apply not invoking functions until run is called, which can lead to errors and a steeper learning curve.