QLExpress4: Boosting Rule Engine Performance and AI-Friendliness

QLExpress4, the latest major rewrite of Alibaba's Java rule engine, dramatically improves compilation and execution speed, adds expression tracing for AI-friendly debugging, supports native JSON syntax for complex data structures, and provides extensive testing, documentation, and integration examples, demonstrating its continued strong demand and adoption across major Alibaba services.

Alibaba Cloud Developer
Alibaba Cloud Developer
Alibaba Cloud Developer
QLExpress4: Boosting Rule Engine Performance and AI-Friendliness

Introduction

QLExpress is a lightweight Java embedded script engine that allows developers to write and execute expressions with Java‑like syntax. It has been widely adopted in business rule scenarios for its ease of integration and flexibility.

Why Rewrite in the AI Era

Despite the rise of AI, the demand for rule engines has not decreased; the project’s star count has more than doubled since 2022, showing strong community interest. The original codebase, over ten years old, accumulated more than three hundred unresolved issues, prompting a complete rewrite called QLExpress4.

Key Improvements

Performance : Compilation speed improves up to tenfold in some scenarios, and execution speed gains about one‑fold even with compilation caching.

Experience : Errors are reported at token level, JSON syntax is natively supported, and a new "expression tracing" feature provides a tree‑like view of intermediate results, making debugging easier for both humans and AI models.

Expression Tracing Example

|| true
       /     \
    ! false  myTest true
    /       /   \
 true true   a 10 11

The tracing tree records the intermediate value at each node, enabling AI models to diagnose why a rule produced a certain result.

JSON Support and Model Mapping

QLExpress4 can directly construct complex data structures using JSON. For example, a list of maps can be created as:

list = [
  {"name": "Li", "age": 10},
  {"name": "Wang", "age": 15}
]
assert(list[0].age == [10, 15])

It also supports constructing Java objects via JSON, e.g.:

myHome = {
  '@class': 'com.alibaba.qlexpress4.inport.MyHome',
  'sofa': 'a-sofa',
  'chair': 'b-chair',
  'myDesk': {
    'book1': 'Then Moon and Sixpence',
    '@class': 'com.alibaba.qlexpress4.inport.MyDesk'
  }
}
assert(myHome.sofa == 'a-sofa')

Real‑World Scenarios

Large‑scale use cases include:

Rule Attribution Clustering – Taobao Group : Tracks which conditions (e.g., VIP status, login inactivity) block users from triggering promotions.

Model Dynamic Mapping – DingTalk : Uses JSON syntax to define mappings between data models.

Performance benchmarks show that for long scripts, compilation time improves nearly tenfold, while simple calculations with cache see a one‑fold speedup. In production, script latency stays below 100 µs for high‑throughput services such as product detail pages and order rendering.

Testing and Documentation

QLExpress4 treats unit tests as the primary source of truth. Test suites are organized by feature under src/test/resources/testsuite, achieving 100% scenario coverage and about 77% line coverage. Documentation is written in Asciidoctor (adoc) and includes code snippets directly from test cases using tag markers, ensuring that examples are always up‑to‑date.

GitHub Actions automatically run an Asciidoctor reducer to pre‑process include directives, committing the rendered README so that the repository displays correct documentation on GitHub.

Open Source and Community

The project is hosted at https://github.com/alibaba/QLExpress . A dedicated DingTalk group (ID 122730013264) provides feedback and support.

Images

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Javaperformancerule engineAIJSONQLExpress
Alibaba Cloud Developer
Written by

Alibaba Cloud Developer

Alibaba's official tech channel, featuring all of its technology innovations.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.