Comment

Comment by himom

Ever since the JDK 1.0 days, I didn’t get why there was this C/C++ carry-over inconsistency of manually-boxed types and non-Objects primitive types separated from Objects. A type hierarchy, patterned similar to Ruby’s as an example, makes the most sense:

- Object contains a Class that it derrives from (no BaseObject or Modules)

- Class is an Object

- String is an Object

- Boolean is a two-value singleton of true and false

- Number is an abstract subclass of Object

- Decimal and Integer are abstract subclasses of Number

- Float, Double, LongDouble, BigDecimal are concrete subclasses of Decimal

- SignedByte, Byte, Short, UnsignedShort, Int, Unsigned, Long, UnsignedLong, Char, BigInt are concrete subclasses of Integer (or U/I/F## types reminiscent of Rust instead of C type names)

and so on.

Then there is no boxing/unboxing of simple types or literals because they are one-and-the-same, and no there’s no confusion about how to interact with any truly generic type of value.

parent himom 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton