Compiler Compiler System Translation Pipeline: From Python to TypeScript with Full RealWorld Conformance
Abstract
Translating an existing application from one general-purpose programming language into another is a long-standing engineering problem with no general solution. Arbitrary source-to-source translation is intractable because the two languages live in different runtime-semantic worlds with significant non-isomorphism in their type systems, exception models, standard libraries, and reflection capabilities. We report a worked example in which a specific class of application — a data-model-shaped web backend, specifically the canonical RealWorld / Conduit Medium-clone specification implemented in Python with FastAPI — is mechanically translated into TypeScript via a multi-stage pipeline of deterministic transformations operating over a small, well-bounded family of domain-specific languages. The pipeline decomposes the Python source into ten family-specific DSLs (DataModelEntity, DataModelRelationship, RouteContract, RouteHandler, RepositoryQuery, AuthPolicy, ValidationRule, ErrorHandling, Configuration, ApplicationBootstrap), emits TypeScript fragments through ten independent per-family emitters, assembles the fragments into target modules, fills handler bodies through a registry of hand-authored translations, and wires the result through a thin TypeScript runtime adapter into an Express HTTP service. The resulting service passes 293 of 293 assertions of the canonical RealWorld Postman conformance collection — exceeding the upstream Python baseline of 280 assertions. The methodological discipline that drove the work — Adaptive Programming: explicit `LOCK` invariants declared at every slice opening, hand-authored golden artefacts validated by byte-equal diff before any implementation iteration — closed forty-six slices over the arc, of which forty-two landed without implementation iteration. We are explicit about scope: the authentication flow is end-to-end pipelined (register, login, JWT issuance, validation cross-call), exercising the full decompose → emit → assemble → bodies → runtime path; the non-authentication endpoints (articles, comments, profiles, tags, follow) execute against hand-wired runtime handlers that share state with the pipelined infrastructure. The full Postman collection passes against the resulting service.