Skip to content

Feasibility Analysis: Refactoring MyCoder from TypeScript to Clojure/Babashka #395

Open
@bhouston

Description

@bhouston

Overview

This issue analyzes the feasibility and implications of refactoring the entire MyCoder codebase from TypeScript to Clojure with Babashka runtime.

Current Codebase Assessment

  • MyCoder is a TypeScript/JavaScript monorepo with three main packages:

    • cli: Command-line interface for MyCoder
    • agent: Core AI agent system
    • docs: Documentation website
  • The codebase consists of approximately 108 TypeScript files

  • Uses modern JavaScript/TypeScript features and ecosystem tools

  • Has a well-structured architecture with clear separation of concerns

  • Relies on npm/pnpm for package management

  • Has an established testing framework (Vitest)

Key Dependencies

  • LLM integrations (Anthropic Claude, OpenAI)
  • Browser automation via Playwright
  • Various Node.js utilities and libraries
  • Semantic release for versioning

Clojure/Babashka Capabilities

  • Clojure is a dynamic, functional programming language that runs on the JVM
  • Babashka is a native Clojure scripting runtime with fast startup time
  • Babashka includes many built-in libraries for scripting tasks
  • Supports multi-threading and has good interop capabilities

Refactoring Implications

Potential Benefits

  • Functional programming paradigm may align well with AI agent workflows
  • Immutable data structures could simplify state management
  • Clojure's macro system could provide powerful abstractions
  • Babashka offers fast startup times for CLI applications
  • Potential for more concise code in some areas

Challenges and Considerations

  1. Ecosystem Compatibility:

    • Need to find/create Clojure equivalents for all current dependencies
    • LLM client libraries would need to be rewritten or wrapped
    • Browser automation would require interop with Playwright or alternative solutions
  2. Development Infrastructure:

    • Complete rewrite of build system, testing framework, and CI/CD pipeline
    • New deployment processes for all components
    • Developer experience changes requiring team retraining
  3. Maintenance Burden:

    • Parallel maintenance during transition period
    • Documentation updates across the entire codebase
    • Potential for regressions during rewrite
  4. Community Impact:

    • Smaller ecosystem and community compared to TypeScript/JavaScript
    • Fewer available libraries and integrations
    • Steeper learning curve for new contributors
  5. Time and Resource Investment:

    • Complete rewrite would require significant developer time
    • Extensive testing to ensure feature parity
    • Potential delays in roadmap for new features

Recommendation

Before proceeding with a full refactoring effort, consider:

  1. Creating a proof-of-concept for a limited component to evaluate feasibility
  2. Starting with a smaller, non-critical package to test the approach
  3. Evaluating specific pain points in the current TypeScript implementation that Clojure might address
  4. Considering a gradual approach where new features are written in Clojure while maintaining existing TypeScript code

Next Steps

  • Gather input from team members on this analysis
  • Create a small proof-of-concept implementation of a core component
  • Benchmark TypeScript vs Clojure implementations for key workflows
  • Develop a more detailed migration plan if the team decides to proceed

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions