by makecheck · 8y ago · 0 comments
And the distinction has worked elsewhere. Objective-C for instance has an NSObject in Cocoa but the language is a proper superset of C and has no problem with plain types. (Granted if you use low-level objcruntime functions, it will be more complex to pass in C data types that are not objects but they still work.)
Despite not requiring Object everywhere, early Java had a frustrating tendency to use Object for many basic things, seemingly requiring boxing and casting more than it should. (At least with Objective-C++ you had the option of some std:: container of plain data, if you didn’t want to wrap in some NS<container> type.) Both Java and Objective-C ultimately changed the syntax to allow type specifications in containers to compensate.
Early Java didn’t have Generics. With Generics, using Object instead of genericizing the type would be an anti-pattern in modern Java.
A lot of warts in Java are being removed.
Never mind the machines back when Java was 1.0 — one of the reasons Project Valhalla exists is that "the poor performance of requiring a minimum object overhead" is very much still a significant cost!
In Eiffel for example, you can declare what is the default behavior (reference or value type), and then any user of the type is able to still override it at declaration site.
Even if it would be your preferred way for a language to do things, not doing so isn't necessarily wrong.
Those early decisions may not have been technically right in some sense, but technical considerations are not the only factor.