-
Notifications
You must be signed in to change notification settings - Fork 14
feat: fluent dsl #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: fluent dsl #221
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #221 +/- ##
==========================================
+ Coverage 64.28% 65.66% +1.37%
==========================================
Files 128 182 +54
Lines 13006 17519 +4513
Branches 1867 2621 +754
==========================================
+ Hits 8361 11503 +3142
- Misses 4617 5986 +1369
- Partials 28 30 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fd1cb6f to
f6953be
Compare
|
Working through reviewing the details, but at the top I wanted to start the conversation around what we should actually call this. IMO |
| @@ -0,0 +1,7 @@ | |||
| export * from "./action"; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be shipping examples of these components like this. IMO this should either just be:
- In the docs
- An unpublished package
- Exported along side our existing reference assets from the player repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeScript lacks built-in documentation testing, making it easy for examples in external documentation to become stale and broken. By keeping examples in language/fluent/src/examples/ we ensure they're part of the regular test suite and CI pipeline, preventing drift between documentation and actual API behavior. This approach guarantees that examples remain functional and up-to-date, while documentation can safely link to these verified examples rather than maintaining separate, potentially outdated code snippets. Additionally, this method does not affect the bundle size, as we do not expose these examples in the index.ts file.
You're right that In our case, That said, I'm definitely open to alternatives if we can find something that feels more intuitive while still being concise. Do you have any initial thoughts on what direction might work better? |
79582d3 to
0684fa9
Compare
|
/canary |
884ae8d to
0083505
Compare
|
/canary |
1 similar comment
|
/canary |
|
/canary |
|
/canary |
|
/canary |
|
/canary |
|
/canary |
|
/canary |
|
/canary |
|
/canary |
|
/canary |
|
/canary |
|
/canary |
RFC: Fluent DSL Architecture for Player-UI Content Authoring
Executive Summary
This RFC proposes a fundamental architectural evolution for Player-UI content authoring through the adoption of a fluent DSL (Domain Specific Language) approach.
The current React-based DSL compilation performance limitations present critical barriers to scaling dynamic content generation (Player-UI content generation at runtime).
Our benchmarking demonstrates that a function-based fluent DSL approach could deliver 31-63x performance improvements over the current React implementation while maintaining full TypeScript support, IDE autocompletion, and developer experience benefits. This architectural shift addresses immediate performance bottlenecks while establishing a foundation for multi-language authoring, WebAssembly execution, and edge computing capabilities.
1. Problem Statement
1.1 Current Performance Crisis
The Player-UI ecosystem faces a critical performance bottleneck in DSL compilation:
1.2 Root Cause Analysis
Our performance profiling identified these key bottlenecks:
2. Current Architecture Limitations
2.1 Content Authoring Approaches
Player-UI currently supports two methods for content authoring:
JSON Authoring
React DSL
The React approach relies on
react-json-reconciler, which waits for alluseEffectandsetStateupdates to settle before returning results, constrained by both React APIs and JS runtime limitations.3. Proposed Solution: Fluent DSL Architecture
3.1 Fluent API Builders (Function-Based)
We propose a fundamental shift: replacing the React-based DSL with a dependency-free function-based approach for content that needs to be compiled/generated at runtime. This isn't a minor optimization — it's rethinking how we generate Player-UI content from first principles.
The function-based alternative offers:
3.2 Fluent API in Action
The fluent DSL provides a chainable, type-safe API for constructing Player-UI assets:
4. Performance Analysis
4.1 Benchmark Results
Our benchmarking across multiple approaches reveals dramatic performance improvements:
Performance Metrics (Average Execution Time in ms)
Alternative Approaches Comparison:
4.2 Flame Graph Analysis
Performance profiling of complex content with a 300KB payload revealed these hotspots in the current React implementation:
createElementWithValidation (BoundLabeledText): 4%coerceRef in updateContextProvider: 2.5%reconcileChildren: 2.3%reconcileChildrenArray: 1.7%flatMap (flattenNode): 1.7%createFiberFromElement: 1.4%validateChildKeys (Slot): 1.1%5. Technical Architecture
5.1 Core Components
Context-Aware ID Generation
Builders automatically generate hierarchical IDs based on parent context:
Tagged Template Integration
Support for dynamic content through tagged templates:
5. Advanced Features
5.1 Schema-Driven Development
Accepting bindings and expressions as strings exposes users to typos, trying to access nonexistent data, or using wrong arguments on expressions.
Generating bindings from the schema helps prevent that and adds nice IDE support with autocompletion based on the schema:
5.2 Multi-Language, Edge Computing Future
The dependency-free function-based approach opens doors that React-based generation could never unlock:
Content Authoring Logic in Other Languages
Being dependency-free allows using different languages to create tooling to author/generate Player-UI content (e.g., Rust implementation).
WebAssembly Transformation
Without React and DOM dependencies, we can author and generate content leveraging WASM and more performant languages like Rust:
6. Conclusion
The dependency-free function-based approach to Player-UI content authoring isn't just an optimization, it's aligning our tools with our true purpose. By freeing ourselves from framework dependencies, we gain performance, clarity, and future flexibility.
We are currently using the fluent pattern at Intuit, demonstrating that it's possible. The performance gains are real and substantial. The architectural benefits extend far beyond immediate performance improvements, opening doors to multi-language authoring, edge computing, and WebAssembly execution.
This RFC represents a fundamental change in how we think about Player-UI content authoring. Rather than accepting the compromises inherent in repurposing a general UI framework, we're establishing a purpose-built foundation that can evolve with our needs rather than being constrained by external framework decisions.
📦 Published PR as canary version:
0.13.0--canary.221.5964Try this version out locally by upgrading relevant packages to 0.13.0--canary.221.5964