Browse OOP reference
Paradigms in practice

How do modern languages approach object orientation?

On this page

Python provides classes and runtime method lookup, TypeScript checks public shapes structurally, and Rust combines data types with implementations and traits. To translate a design, identify the promised behaviour and who owns each value. A class-for-class translation can miss a language’s simpler representation.

Worked example

Rust
trait Label { fn label(&self) -> &str; }
struct Job { name: String }
impl Label for Job {
    fn label(&self) -> &str { &self.name }
}
fn describe(item: &dyn Label) -> String {
    format!("Queued: {}", item.label())
}
fn main() {
    let job = Job { name: String::from("export") };
    assert_eq!(describe(&job), "Queued: export");
}

The Rust Programming Language on traits

Explore class relationships in the OOP Playground

What are traits?What is structural typing?What is a class?

All OOP questions

Search ObjectFAQ