Skip to content
meta-convert-guide logo

Language Conversion Guide

meta-convert-guide

Guide for translating code between programming languages. Use when converting code from one language to another, planning language migrations, understanding conversion challenges, asking about type mappings, idiom translations, or referencing pattern mappings. Covers APTV workflow, type systems, ...

SKILL.md

Full skill instructions

Language Conversion Guide

Comprehensive patterns and strategies for converting code between programming languages.

Quick Navigation

ResourcePurpose
FORMS.mdTemplates, checklists, decision trees
tables/​quick-reference.mdCondensed lookup tables

Examples

FileContent
examples/​idiom-translation.mdNull handling, collections, pattern matching
examples/​error-handling.mdException→Result, error hierarchies
examples/​concurrency.mdPromise/​Future, parallel execution
examples/​metaprogramming.mdDecorators, macros, DI patterns
examples/​serialization.mdJSON, validation, polymorphic types

Reference Guides

FileContent
reference/​difficulty-matrix.mdConversion difficulty ratings
reference/​type-system-mapping.mdPrimitives, composites, generics
reference/​error-handling.mdError models, let-it-crash
reference/​concurrency.mdAsync models, channels, goroutines
reference/​dev-workflow-repl.md9th pillar, REPL patterns
reference/​memory-ownership.mdGC→ownership, borrowing
reference/​evaluation-strategy.mdLazy vs eager patterns
reference/​metaprogramming.mdMacros, reflection, code gen
reference/​type-system-translation.mdStatic↔dynamic, inference
reference/​paradigm-translation.mdOOP→FP, FP→FP
reference/​serialization.mdLibrary mapping, attributes
reference/​typescript-patterns.mdType guards, mapped types
reference/​hkt-type-classes.mdHKTs, Functor, Monad
reference/​async-patterns.mdCancellation, streams
reference/​dependency-management.mdPackage ecosystems
reference/​performance.mdPitfalls, benchmarking

Gotchas

FileContent
reference/​gotchas/​by-family.mdOOP→FP, Dynamic→Static, GC→Ownership
reference/​gotchas/​by-language.mdPython→Rust, TypeScript→Rust, etc.

When to Use This Skill

  • Converting code from one language to another
  • Planning a language migration
  • Understanding conversion challenges between languages
  • Looking up type mappings or idiom translations
  • Referencing error handling, concurrency, or async patterns across languages
  • Learning about gotchas when converting between specific language families

This Skill Does NOT Cover

  • Creating new conversion skills (see meta-convert-dev)
  • Language tutorials (see lang-*-dev skills)
  • Runtime interop/​FFI (see language-specific interop skills)

Related Skills

  • meta-convert-dev - For creating new convert-X-Y skills
  • convert-* skills - Language-pair specific conversion skills

Core Conversion Methodology

The APTV Workflow

Every conversion follows: Analyze → Plan → Transform → Validate

┌─────────────────────────────────────────────────────────────┐
│                    CONVERSION WORKFLOW                       │
├─────────────────────────────────────────────────────────────┤
│  1. ANALYZE    │  Understand source code structure          │
│                │  • Parse and identify components            │
│                │  • Map dependencies                         │
│                │  • Identify language-specific patterns      │
├─────────────────────────────────────────────────────────────┤
│  2. PLAN       │  Design the target architecture            │
│                │  • Create type mapping table                │
│                │  • Identify idiom translations              │
│                │  • Plan module/​package structure            │
├─────────────────────────────────────────────────────────────┤
│  3. TRANSFORM  │  Convert code systematically               │
│                │  • Types and interfaces first               │
│                │  • Core logic second                        │
│                │  • Adopt target idioms (don't transliterate)│
├─────────────────────────────────────────────────────────────┤
│  4. VALIDATE   │  Verify functional equivalence             │
│                │  • Run original tests against new code      │
│                │  • Property-based testing for edge cases    │
│                │  • Performance comparison if relevant       │
└─────────────────────────────────────────────────────────────┘

See also: FORMS.md for APTV phase checklists

Analyze Phase

Before writing any target code:

  1. Parse the source - Understand structure, not just syntax
  2. Identify components:
    • Types/​interfaces/​classes
    • Functions/​methods
    • Module boundaries
    • External dependencies
  3. Note language-specific features:
    • Generics usage
    • Error handling patterns
    • Async patterns
    • Memory management approach

Plan Phase

Create explicit mappings before transforming. Use the templates in FORMS.md:

## Type Mapping Table

| Source (TypeScript) | Target (Rust)      | Notes             |
| ------------------- | ------------------ | ----------------- |
| `string`            | `String` / `&str`  | Owned vs borrowed |
| `number`            | `i32` / `f64`      | Specify precision |
| `T[]`               | `Vec<T>`           | Owned collection  |
| `T \| null`         | `Option<T>`        | Nullable handling |
| `Promise<T>`        | `Future<Output=T>` | Async handling    |

See also: reference/​type-system-mapping.md for complete mappings

Transform Phase

Golden Rule: Adopt target idioms, don't write "Source code in Target syntax"

// Source: TypeScript
function findUser(id: string): User | null {
  const user = users.find((u) => u.id === id);
  return user || null;
}
// BAD: Transliterated (TypeScript in Rust clothing)
fn find_user(id: String) -> Option<User> {
    let user = users.iter().find(|u| u.id == id);
    match user {
        Some(u) => Some(u.clone()),
        None => None,
    }
}

// GOOD: Idiomatic Rust
fn find_user(id: &str) -> Option<&User> {
    users.iter().find(|u| u.id == id)
}

See also: examples/​idiom-translation.md for more patterns

Validate Phase

  1. Functional equivalence: Same inputs → same outputs
  2. Edge case coverage: Property-based tests
  3. Error behavior: Same error conditions trigger appropriately
  4. Performance baseline: Comparable or better performance

See also: FORMS.md for testing strategy checklist


The 8 Pillars of Conversion

Every comprehensive conversion addresses these domains:

PillarWhat to ConvertReference
1. Module SystemImports, exports, packagesreference/​type-system-mapping.md
2. Error HandlingExceptions, Results, panicsreference/​error-handling.md
3. ConcurrencyAsync, threads, channelsreference/​concurrency.md
4. MetaprogrammingDecorators, macros, reflectionreference/​metaprogramming.md
5. Zero/​Default ValuesNullability, defaultsreference/​type-system-mapping.md
6. SerializationJSON, validation, schemasreference/​serialization.md
7. Build SystemPackage managers, dependenciesreference/​dependency-management.md
8. TestingTest frameworks, assertionsFORMS.md

The 9th Pillar: Dev Workflow

For REPL-centric languages (Clojure, Elixir, Haskell), add:

SourceTargetConsideration
REPL-centricCompiledDocument workflow changes
Hot reloadRecompileFaster incremental builds
Live inspectionDebuggingLogger, debugger setup

See also: reference/​dev-workflow-repl.md


Quick Reference Tables

Type System Comparison

LanguageTypingNull SafetyGenerics
TypeScriptStaticOptional (strict)Full
PythonDynamicNone (runtime)Type hints
RustStaticEnforced (Option)Full
GoStaticNil pointers1.18+
ElixirDynamicnil atomsNone
HaskellStatic (HM)Enforced (Maybe)Full + HKT

See also: tables/​quick-reference.md for complete tables

Error Model Comparison

LanguageModelPropagation
TypeScriptExceptionsthrow / try-catch
PythonExceptionsraise / try-except
RustResult type? operator
GoError returnsif err != nil
ElixirPattern match{:ok, _} / {:error, _}
HaskellEither/​MaybeMonadic bind

See also: reference/​error-handling.md

Concurrency Model Comparison

LanguageModelPrimitives
TypeScriptEvent loopPromises, async/​await
PythonEvent loopasyncio, await
RustFuturestokio, async/​await
GoCSPGoroutines, channels
ElixirActorsProcesses, GenServer
ErlangActorsProcesses, mailboxes

See also: reference/​concurrency.md


Common Conversion Patterns

Null Handling

SourceTarget RustPattern
x ?? defaultx.unwrap_or(default)Default value
x?.propx.map(|v| v.prop)Optional chaining
if (x != null)if let Some(v) = xNull check

See also: examples/​idiom-translation.md

Error Propagation

SourceTargetPattern
throw new Error(msg)return Err(Error::new(msg))Throw → Result
try { } catch { }match result { Ok(_) => ..., Err(_) => ... }Try/​catch → match
Rethrow? operatorPropagate error

See also: examples/​error-handling.md

Collection Operations

Source (JS/​TS)Target (Rust)Notes
.map(f).iter().map(f)Lazy in Rust
.filter(f).iter().filter(f)Lazy in Rust
.reduce(f, init).iter().fold(init, f)Different arg order
.find(f).iter().find(f)Returns Option

See also: tables/​quick-reference.md


Decision Trees

When to Clone vs Borrow

Is the data needed after the function returns?
├─ NO → Borrow (&T)
└─ YES → Does caller need to keep using it?
         ├─ NO → Move (T)
         └─ YES → Clone (.clone())

See also: FORMS.md for complete decision trees

GC → Ownership Strategy

Is this data shared across components?
├─ YES → Consider Arc<T> or Rc<T>
└─ NO → Single owner, use moves

Is this data mutated by multiple parts?
├─ YES → Arc<Mutex<T>> or channels
└─ NO → Immutable borrows (&T)

See also: reference/​memory-ownership.md


Common Pitfalls

PitfallWrongRight
TransliterationWrite TypeScript in Rust syntaxWrite idiomatic Rust
Ignoring idiomsPort class hierarchies to RustUse enums and traits
1:1 mappingEvery function maps exactlyRestructure as needed
Preserve inefficiencyPort inefficient algorithmsOptimize for target
Ignore conventionscamelCase in Pythonsnake_case (Python)

See also: reference/​gotchas/​by-family.md


Testing Conversions

Testing Pyramid

         ┌───────────────┐
         │  Integration  │  Same API behavior
         └───────────────┘
    ┌─────────────────────────┐
    │    Property-Based       │  Invariants hold
    └─────────────────────────┘
 ┌───────────────────────────────────┐
 │           Unit Tests              │  Logic matches
 └───────────────────────────────────┘
┌─────────────────────────────────────────┐
│        Input/​Output Comparison          │  Golden tests
└─────────────────────────────────────────┘

Golden Testing

  1. Generate test cases from original implementation
  2. Save as JSON fixtures
  3. Run converted code against same inputs
  4. Compare outputs

See also: FORMS.md for testing checklist


Language-Specific Quick Links

Converting FROM

SourceKey GotchasReference
PythonDuck typing, None everywherereference/​gotchas/​by-language.md
TypeScriptOptional properties, anyreference/​typescript-patterns.md
GoZero values, nilreference/​gotchas/​by-language.md
JavaNull, checked exceptionsreference/​gotchas/​by-language.md
HaskellHKTs, lazinessreference/​hkt-type-classes.md
ElixirPattern matching, processesreference/​gotchas/​by-language.md

Converting TO

TargetKey ConsiderationsReference
RustOwnership, borrowingreference/​memory-ownership.md
GoSimplicity, explicit errorsreference/​error-handling.md
PythonDynamic typingreference/​type-system-translation.md
ElixirFunctional, BEAMreference/​paradigm-translation.md

References

Related Skills

  • meta-convert-dev - For creating new convert-X-Y skills
  • convert-typescript-rust - TypeScript → Rust conversion
  • convert-python-rust - Python → Rust conversion
  • convert-golang-rust - Go → Rust conversion

Language Skills

For language-specific fundamentals (not conversion):

  • lang-typescript-dev - TypeScript development patterns
  • lang-python-dev - Python development patterns
  • lang-rust-dev - Rust development patterns
  • lang-elixir-dev - Elixir development patterns

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View