Slide with text: “Rust teams at Google are as productive as ones using Go, and more than twice as productive as teams using C++.”

In small print it says the data is collected over 2022 and 2023.

  • orclev@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    7 months ago

    It also massively helps with productivity

    Absolutely! Types are as much about providing the programmer with information as they are the compiler. A well typed and designed API conveys so much useful information. It’s why it’s mildly infuriating when I see functions that look like something from C where you’ll see like:

    pub fn draw_circle(x: i8, y: i8, red: u8, green, u8, blue: u8, r: u8) -> bool {
    

    rather than a better strongly typed version like:

    type Point = Vec2<i8>;
    type Color = Vec3<u8>;
    type Radius = NonZero<u8>;
    pub fn draw_circle(point: Point, color: Color, r: Radius) -> Result<()> {
    

    Similarly I think the ability to use an any or dynamic escape hatch is quite useful, even if it should be used very sparingly.

    I disagree with this, I don’t think those are ever necessary assuming a powerful enough type system. Function arguments should always have a defined type, even if it’s using dynamic dispatch. If you just want to not have to specify the type on a local, let bindings where you don’t explicitly define the type are fine, but even in that case it still has a type, you’re just letting the compiler derive it for you (and if it can’t it will error).