Mỗi lần refactor là một cực hình

Rust’s rich type system is a blessing and a curse. Thinking in Rust types is a dream. Managing Rust’s types can be a nightmare. Your data and function signatures can have generic types, generic lifetimes, and trait constraints. Those constraints can have their own generic types and lifetimes. Sometimes, you’ll have more type constraints than actual code.

Constraints that outweigh logic

You also need to define all your generics on every impl. It’s tedious when writing it the first time. When refactoring though, it can turn a minor change into a cascading mess.

Simple generic IDs are duplicated over and over again.

It’s hard to make rapid progress when you need to tweak 14 different definitions before you can take a single step forward.

Edit to address external comments: The problem isn’t the expressibility, the problem is no language or tooling solution to reduce the duplication. There are frequent reasons to have the same constraints or refer to the same generic lists, but there’s no way to alias or otherwise refer to a central definition. I’m not sure there should be, but it doesn’t change the burden of duplication.

Nguồn:: Was Rust Worth It?. From JavaScript to Rust, three years… | by Jarrod Overson | Medium


Cập nhật lần cuối : 30 tháng 6, 2024
Tạo : 4 tháng 1, 2024