Choosing an Implementation

DTRules has two implementations: Java (the original) and Go (high-performance runtime). Understanding how they work together helps you choose the right tools for your workflow.

The DTRules Workflow

DTRules separates rule authoring from rule execution. This is the key concept:

┌─────────────────────────────────────────────────────────────────┐
│                      AUTHORING PHASE                            │
│                                                                 │
│   Excel Files (.xls)  ───►  Java Compiler  ───►  XML Files      │
│   - EDD (data model)        (Excel2XML)         - *_edd.xml     │
│   - Decision Tables                             - *_dt.xml      │
│                                                                 │
│   Requires: Java 8+, Maven                                      │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                      EXECUTION PHASE                            │
│                                                                 │
│   ┌─────────────────────┐          ┌─────────────────────┐      │
│   │   Java Runtime      │    OR    │    Go Runtime       │      │
│   │                     │          │                     │      │
│   │ • Auto-mapping to   │          │ • High performance  │      │
│   │   Java objects      │          │ • REST API          │      │
│   │ • Full tooling      │          │ • Visual UI backend │      │
│   │ • IDE debugging     │          │ • Cloud-native      │      │
│   │                     │          │                     │      │
│   │ Requires: Java 8+    │          │ Requires: Go 1.21+   │      │
│   └─────────────────────┘          └─────────────────────┘      │
│                                                                 │
│                    Both read the same XML files                 │
└─────────────────────────────────────────────────────────────────┘

Key Insight

Excel compilation requires Java, but once you have XML files, you can execute them with either Java or Go. This means:

  • Rule authors use Java to compile Excel → XML
  • Runtime execution can use Java or Go, depending on your needs
  • You can develop with Java and deploy with Go for better performance

Feature Comparison

Feature Java Go
Excel Compilation Yes No
XML Execution Yes Yes
Auto Object Mapping Yes (Java objects) Manual / JSON
REST API Build your own Built-in
Visual UI Backend No Yes
CLI Tool No Yes
Performance Good Excellent (130x faster operator lookup)
IDE Debugging Full support Limited

When to Use Java

Use Java when you need:

  • Excel compilation - Converting Excel files to XML (required for rule authoring)
  • Automatic Java object mapping - Direct mapping between rule entities and Java classes
  • IDE debugging - Step-through debugging of rule execution
  • Enterprise Java stack - Integration with Spring, J2EE, or existing Java applications
  • Full tooling - Test harness, comprehensive diagnostics

Typical Java Workflow

  1. Define entities in *_edd.xls Excel files
  2. Write decision tables in *_dt.xls Excel files
  3. Run the Java compiler to generate XML
  4. Load XML and execute rules in your Java application
  5. Use the test harness to validate rules

When to Use Go

Use Go when you need:

  • High performance - 130x faster operator lookup, 24x faster arithmetic
  • REST API - Built-in HTTP API for rule execution
  • Visual UI - The React UI requires the Go backend
  • Microservices - Lightweight, single-binary deployment
  • Cloud-native - Container-friendly, low memory footprint
  • CLI tool - Quick validation and testing from the command line

Typical Go Workflow

  1. Receive pre-compiled XML files (from Java compilation)
  2. Use the CLI to validate rules: ./dtrules -validate
  3. Start the REST API server for production use
  4. Or use the Visual UI for interactive editing and testing

Common Scenarios

Scenario 1: New to DTRules

Recommended: Start with the Visual UI (Go backend)

The Visual UI is the easiest way to understand DTRules concepts. Load the CHIP sample project and explore decision tables visually. You don't need to write any code.

Scenario 2: Rule Author

Recommended: Java for compilation + Go for testing

  1. Write rules in Excel
  2. Compile with Java: mvn exec:java -Dexec.mainClass="CompileRules"
  3. Test with Go CLI: ./dtrules -rules xml/ -entry Main -trace
  4. Use Visual UI for interactive debugging

Scenario 3: Java Application Integration

Recommended: Java only

If you're embedding DTRules in a Java application and want automatic object mapping, use the Java runtime. Your Java objects will map directly to rule entities.

Scenario 4: Production Service

Recommended: Java for compilation, Go for deployment

  1. Compile rules with Java (CI/CD pipeline)
  2. Deploy XML files with Go runtime
  3. Use the REST API for rule execution
  4. Benefit from Go's performance and low resource usage

Project Structures

Java Project Structure

myproject/
├── DecisionTables/           # Excel files with business rules
│   └── MyRules_dt.xls
├── edd/                      # Entity Definition Documents
│   └── MyRules_edd.xls
├── xml/                      # Compiled XML (generated)
│   ├── MyRules_edd.xml
│   └── MyRules_dt.xml
├── testfiles/                # Test case input files
├── DTRules.xml               # Project configuration
├── pom.xml                   # Maven configuration
└── src/main/java/
    └── CompileRules.java     # Compiles Excel → XML

Go Project Structure

myproject/
├── xml/                      # Pre-compiled XML files
│   ├── MyRules_edd.xml       # (from Java compilation)
│   └── MyRules_dt.xml
├── testfiles/                # Test case input files
└── main.go                   # Your Go application (optional)

Note: Go projects consume pre-compiled XML. If you need to modify rules, you'll need access to the Excel sources and Java compiler.

Hybrid Workflows

Many teams use both implementations together:

Phase Tool Why
Authoring Excel + Java Required for compilation
Testing Go CLI + Visual UI Fast iteration, visual debugging
CI/CD Java (compile) + Go (validate) Automated quality gates
Production Go REST API Performance, scalability

Next Steps

Choose your quick start guide based on your needs: