Comment by rf15

Comment by rf15 2 days ago

13 replies

> due to the mlibc code using the char value from the format string, the values above 127 passed by OpenJDK would be handled as negative integers

It's 2025 and I still don't get why Java needed signed chars and bytes. Why completely disregard the convenience of using them for array access/etc..

pjmlp 2 days ago

Easy,

> Gosling: For me as a language designer, which I don't really count myself as these days, what "simple" really ended up meaning was could I expect J. Random Developer to hold the spec in his head. That definition says that, for instance, Java isn't -- and in fact a lot of these languages end up with a lot of corner cases, things that nobody really understands. Quiz any C developer about unsigned, and pretty soon you discover that almost no C developers actually understand what goes on with unsigned, what unsigned arithmetic is. Things like that made C complex. The language part of Java is, I think, pretty simple. The libraries you have to look up.

From http://www.gotw.ca/publications/c_family_interview.htm

Note that Java has unsigned support nowadays, only not as primitive types, although this is considered post Valhala.

For example, https://docs.oracle.com/en/java/javase/25/docs/api/java.base...

toast0 2 days ago

Java creators tried to avoid giving developers any sharp edges. Interactions between signed and unsigned integers can be surprising, so they disallowed unsigned integers.

Of course, not having access to unsigned quantities makes interaction with other programs difficult :(

  • Hendrikto 2 days ago

    > Java creators tried to avoid giving developers any sharp edges.

    They failed.

    • fhd2 2 days ago

      Well, I'd argue they created a straight jacket. That prevents a number of self harm tactics. It also makes a lot of easy things pretty hard to do.

  • astrange 2 days ago

    The one that annoys me is that people think implicit type conversions are dangerous for some reason, so they also disallowed `char a = 10; short b = a;` without writing a cast even though this makes no sense.

    • resonious 2 days ago

      It feels like "sharp edges" often means "I once had a horrible bug due to accidentally misusing this". But if you cut features based on that definition, you'd soon have an empty programming language.

      • lukan 2 days ago

        Java was apparently quite successful, though. So maybe they got the balance right for their goal?

    • pdw 2 days ago

      The signedness of `char` is implementation-defined, it is signed on x86 but unsigned on ARM. So assigning a plain char to a wider integer type is suspicious, did the programmer expect sign-extension or zero-extension?

      • astrange a day ago

        It's not implementation-defined in Java because there aren't any unsigned types.

        Personally I think explicit typecasts are even more suspicious, because introducing explicit semantics is worse than implicit semantics if the explicit ones are wrong.

bji9jhff 2 days ago

[flagged]

  • kjs3 2 days ago

    Look up James Gosling and get back to us. I'd especially be interested in hearing how your undoubtedly superior experience would result in a more successful language. I'm sure you can vibe code something up.