Rust's Huge Compilation Units
pingcap.com
pingcap.com
This happened to me too. One important problem to overcome is the orphan rule. This means: you can only implement a trait you own or for a type you own. If both the type and the trait are not in your crate, you are out of luck.
So my first attempt failed utterly. It was very disappointing. You see, by splitting the project in different crates I put one type and one trait in different crates.
After thinking about this problem for a few weeks I accepted that I needed to write wrappers, so called newtypes. But this hurt a lot. I managed to abstract away a lot of the boilerplate by writing macros but still am not very happy about the complexity.
Growing pains.
I find it hard to believe that there exists no set of import declarations which remove all ambiguity, i.e., allowing orphan traits but requiring that they get imported explicitly.
> I find it hard to believe [...]
I think you should read up stuff about the orphan rule, then you will understand better.
I recently divided a 100k line Java app into 5 different modules and it compiles 4 times faster. The new boundaries have encouraged better code as well. Suddenly we have things like interfaces and IoC. Before, people just stuffed things wherever.
Definitely not the same. With Java, you decide what you want to compile with your build script. You don't need to compile entire application as a single unit. If you have to recompile a lot of code when you only make small modification it is likely because did not use many of available ways to just recompile the classes that you modified.
Also, with Java some optimizations are pushed to runtime. JIT has access to all code running even if it wasn't available at compilation time.
(Orphan instances in apps are horrible, orphan instances in libraries run the risk of making your whole library unusable.)
As useful as they sometimes are, I can't help feeling Rust made the right call here.
It does seem like Rust is just enforcing the rough consensus in the Haskell community re: best practices.
Maybe there should be a lint for not having modules be mutually dependent?