3 ms·
> I don't split up my code manually for the compiler, I do it for the humans, being compiler friendly is just a pleasant side effect. There is no human benefit
by pcwalton 10y ago
> I don't split up my code manually for the compiler, I do it for the humans, being compiler friendly is just a pleasant side effect.
There is no human benefit to having to copy and paste function signatures—and worse, the bodies of functions you want to be inlined, including all templates—into header files. There's also no benefit to having the compiler parse hundreds of KB of header files over and over and over again.
> You can build java files the same way without header files, worst case scenario is you have some fat compilation units.
Java (production implementations used in practice) performs whole program optimization via its JIT. It's nice for Java, but that isn't how Rust works.
- flukus 10y agoI don't disagree on the header files, no sane language designed today would include that. > Java (production implementations used in practice) performs whole program optimization via its JIT. It's nice for Java, but that isn't how Rust works. Whole program optimization isn't generally something you want on dev builds, which is where incremental compilation is useful. For a production build why wouldn't you do a full rebuild anyway?
- pcwalton 10y ago> Whole program optimization isn't generally something you want on dev builds, which is where incremental compilation is useful. By "whole program optimization" I also include things like generic/template instantiation. Whenever you use, say, a HashMap, you have to recompile the implementation of the HashMap specialized to the size, alignment, destructor, etc. of types you're using with it. > For a production build why wouldn't you do a full rebuild anyway? When I profile apps written in Rust, it's important for me to be able to get good turnaround time on optimized builds.
- enitihas 10y agoDo Java generics work like that? I thought the JVM did not know about the generics as the types are erased at compile time.
- eonwe 10y agoJVM doesn't know about generic types at the runtime. There's no specialization of HashMaps, it's just arrays of points to objects all around. With project Valhalla: https://en.wikipedia.org/wiki/Project_Valhalla_(Java_language) https://en.wikipedia.org/wiki/Project_Valhalla_(Java_languag... there's been talk about specialization for value types.
- enitihas 10y agoI too thought the same. That's why pcwalton's comment confused me.
- pjmlp 10y agoIt is already available for those that want to play with it. https://adoptopenjdk.gitbooks.io/adoptopenjdk-getting-started-kit/content/en/openjdk-projects/valhalla.html https://adoptopenjdk.gitbooks.io/adoptopenjdk-getting-starte...
- pcwalton 10y agoRust generics do. Java's don't.