Skip to content

DRAFT port to ClojureScript backed by DataScript#58

Open
theronic wants to merge 3 commits intomainfrom
claude/eacl-clojurescript-dataScript-8RH2O
Open

DRAFT port to ClojureScript backed by DataScript#58
theronic wants to merge 3 commits intomainfrom
claude/eacl-clojurescript-dataScript-8RH2O

Conversation

@theronic
Copy link
Copy Markdown
Owner

@theronic theronic commented Feb 1, 2026

Summary

This PR adds a comprehensive implementation plan for porting EACL from Clojure/Datomic to ClojureScript/DataScript. The plan enables running EACL in browsers for demos and edge nodes while maintaining 1-for-1 API compatibility with the existing Datomic implementation.

Key Changes

  • New planning document (docs/plans/2026-02-01-clojurescript-datascript-port.md) with:
    • Executive summary and goals/non-goals
    • Detailed architecture comparison (Datomic vs DataScript)
    • Technical challenge analysis with proposed solutions:
      • d/index-range replacement using composite vector keys
      • Tuple attribute emulation via composite keys
      • Lazy sequence handling in ClojureScript
      • Entity ID resolution differences
      • LRU cache implementation
    • DataScript schema translation with concrete examples
    • API compatibility matrix showing method-by-method mapping
    • 6-phase implementation roadmap (6 weeks total)
    • Module structure for shared .cljc files and platform-specific implementations
    • Index strategy using sorted vectors and binary search
    • Comprehensive testing strategy with cross-validation framework
    • Performance targets and optimization opportunities
    • Future sync considerations from Datomic to DataScript

Notable Implementation Details

  • Shared code strategy: Core protocol and records moved to .cljc files for use in both Clojure and ClojureScript
  • Composite keys: Replaces Datomic's :db.type/tuple with vector-based composite keys that are comparable in ClojureScript
  • Index approach: Uses DataScript's :avet index with filtering for range-like queries, with optional sorted-map indices for hot paths
  • Lazy sequences: Confirms ClojureScript's lazy-seq works for in-memory DataScript operations
  • Simple LRU cache: Proposes pure ClojureScript implementation (~50 lines) instead of depending on clojure.core.cache
  • Testing: Includes cross-validation framework to compare results between Datomic and DataScript implementations

Open Questions for Review

  1. Vector vs string encoding for composite keys
  2. Eager vs lazy pagination approach
  3. Target percentage of shared code
  4. Demo scope (API validation vs full interactive UI)
  5. Build tooling choice (shadow-cljs vs Figwheel)

This plan is marked as "Draft - Pending Approval" and ready for team review before implementation begins.

https://claude.ai/code/session_01BJ1LJh2FzYBG3bXYYRakum

This plan outlines the translation of EACL from Clojure/Datomic to
ClojureScript/DataScript for browser demos and edge nodes.

Key sections:
- Architecture comparison (Datomic vs DataScript)
- Technical challenges and solutions (index-range, tuple attrs, lazy seqs)
- DataScript schema translation with composite key strategy
- 6-phase implementation timeline
- Module structure for shared .cljc code
- Testing and cross-validation strategy
- Performance considerations for browser environments

Awaiting approval before implementation begins.

https://claude.ai/code/session_01BJ1LJh2FzYBG3bXYYRakum
@theronic theronic changed the title Add ClojureScript/DataScript port plan for EACL DRAFT port to ClojureScript backed by DataScript Feb 1, 2026
After checking DataScript's actual tests, confirmed that d/index-range
is fully supported with the same API as Datomic. This significantly
simplifies the port.

Updated sections:
- 3.1: Now documents d/index-range as supported ✅
- 8: Revised index strategy - main challenge is tuple attrs, not range scans
- Architecture diagrams: Updated to reflect d/index-range works
- Phase 2-3: Removed references to custom workarounds

The only real challenge is manually computing composite keys since
DataScript doesn't support :db/tupleAttrs auto-computation.

https://claude.ai/code/session_01BJ1LJh2FzYBG3bXYYRakum
After checking DataScript's actual documentation, confirmed that
:db/tupleAttrs is fully supported with auto-computation of composite
values - same as Datomic.

This means the port is even simpler:
- Schema can be translated with minor syntax changes
- No manual composite key computation needed
- Transaction builders work unchanged
- d/index-range works on auto-computed tuples

Updated sections:
- 3.2: Now documents tupleAttrs as supported ✅
- 4.2: Proper DataScript schema using tupleAttrs
- 4.3: Schema conversion function
- 8: Simplified index strategy (direct port)
- Phase 2: Removed manual key helpers

https://claude.ai/code/session_01BJ1LJh2FzYBG3bXYYRakum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants