Hacker News new | ask | show | jobs
by rondaerth92 124 days ago
How do you map dynamically typed languages? Where types are determined at runtime rather than at compile time
1 comments

You don't map the types, you map the behavior.

Define a behavioral contract (inputs, outputs, edge cases) with test cases, and let each language handle types idiomatically. `dict[str, Any]` becomes `Record<string, unknown>` in TS, `map[string]interface{}` in Go, `HashMap<String, Box<dyn Any>>` in Rust. You don't force one type system onto another.

For dynamic languages, type hints document intent but tests enforce the contract. If the function accepts the specified inputs and produces the specified outputs, the contract is satisfied, regardless of whether types are checked at compile time or runtime.

What do you think?