Comment by tialaramex

4 hours ago

I mean, Rust calls this function you want abs_diff

    let a = 1234_u32;
    let b = 5678_u32;
    let c = a.abs_diff(b); // Or equivalently u32::abs_diff(a, b);

Some languages hate offering convenience functions, in particular in a language like C or one of the would-be C-replacements, those functions just clog up the same namespace as everything else, so having 100 intrinsic arithmetic functions for integers feels disproportionate. The C-like languages, even those which do have methods, often forbid methods on their "built-in" or "core" types like integers so they can't do what Rust did here.

Edited: tweaked language