A cross-platform Swift library for evaluating mathematical and boolean expressions at runtime with support for custom symbols and types.
Expression is a cross-platform Swift library that parses and evaluates mathematical and boolean expressions at runtime. It allows developers to embed dynamic expression evaluation in their apps without relying on external scripting engines, solving the need for safe, performant runtime calculations. The library includes both a numeric-focused `Expression` class and a flexible `AnyExpression` extension for handling arbitrary data types.
Swift developers building applications that require runtime expression evaluation, such as calculators, layout engines, configuration systems, spreadsheet apps, or simple scripting environments.
Developers choose Expression for its native Swift implementation, superior performance compared to JavaScriptCore, thread-safe evaluation, and extensible symbol system that avoids the security risks and overhead of embedding full scripting languages.
A cross-platform Swift library for evaluating mathematical expressions at runtime
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmark tests show Expression outperforms JavaScriptCore, with optimizations like caching and constant inlining for repeated calculations.
AnyExpression extends support to arbitrary Swift types including strings, arrays, and dictionaries using NaN boxing, enabling diverse use cases like color parsing.
Allows custom variables, operators, and functions with thread-safe evaluation, making it adaptable to specific application needs such as layout engines.
Works on all Apple platforms and Linux, providing a consistent solution for Swift developers across ecosystems.
Boolean operators like && and || do not support short-circuiting, which can lead to unnecessary evaluations and potential performance hits in logic-heavy expressions.
Supports only ternary conditionals, lacking loops or other control structures, restricting it to expression-level logic and not full scripting.
Custom operators cannot have specified precedence; they default to the same level as addition/subtraction, limiting advanced mathematical expressions without workarounds.