Skip to main content

presumably unnecessary ambiguities in Java

[WORK IN PROGRESS, noob bashing welcome]

Its specification allows accessibilities to conflict.
  • Java lets you control how much of your program can access any given variable or class. However, the default level of accessibility doesn't have a closed specification, that is, it can be 'overloaded'; this causes problems when you have more than two packages and mix certain accessibility modifiers with inheritance between them. (The problem with the linked case is that it's syntactically correct and but the resulting output varies depending on the compiler you use. This matters not for the small number of programs it cockblocks or crashes, but because compiler writers are scarily devoted and prescient, so to see them failing to resolve ambiguity is a blow to human pride and existential security.)

Escape characters and directories
  • You can't use certain directories within strings, cos backslash is used to mark escape characters and the beginning of Windows directories (e.g. for the unicode escape command '\u', "C:\\users\\unnameable"). The same problem goes for a few other slashed letters, but less seriously for them, because they are only processed within strings unlike '\u'. A rule like "never begin directories with these lower-case letters" would plug it, but for why in the first place?

Type system
  • Strings are objects that can be given literal values like variables. Strings can be both initialised and printed, unlike every other object (in what I had taken to be the essential feature of objects, like a ruddy fool). They're also created like variables, not like objects:
    Object str = new Object("Hello World");
    but instead
    String str = "Hello World";

It makes numbers hard.
  • I haven't seen a good explanation for why the int/double divide requires so much casting and ambiguous operation (ambiguous at the human level, that is; the compiler don't give a fuck).

  • Also doesn't compare integers properly, if they are of an interval of more than 255 (?!)

Symbol pedantry
  • '*' is the operator for both multiplication and wildcard-all.

  • '%' is the operator for both modulo and format specifier.

  • More seriously, '/' is the operator for both integer quotient and floating-point quotient. This does produce silent stupidities.

  • 'System.out' is the name of an object awaiting a method, even though dots always demarcate the end of an object name everywhere else.
    [EDIT: Turns out that 'out' is the name of a static variable, so this isn't pointless. Still needless though.]

  • '//' begins a single-line comment ("Compiler, ignore this line") or is just one forward-slash if it's within a string ("Compiler, the following slash is text").*

Apart from the academic problem with overloading accessibilities, these aren't a big deal - in particular, the symbol ones are only serious ambiguities for humans, since they do get caught at syntax check - and in particular, millions upon millions of Java applets work really well a whole damn lot of the time. But - just sayin' - this gig is still all about humans.

* A simple solution to the unicode escape problem above might be to make "\\\u" the accepted syntax for directories beginning 'u', but it didn't work in the Eclipse compiler.