Java has
int
andInteger
boolean
andBoolean
This seems a bit inconsistent, why not either
bool
vsBoolean
to use an established shorter name for primitive type?
or
integer
vsInteger
to keep type names consistent?
I think C++ had decided to use bool
quite a bit earlier than Java decided to use boolean
, and maybe also some (non-standard at the time?) C extensions too, so there would have been historical precedence for bool
. I’ve noticed I often instinctively try to use bool
at first (good thing modern editors immediately spot this without extra compilation round), so it’d be nice to know the rationale behind current state of affairs.
If someone remembers (a part of) the story, or can even find and link to relevant historical discussion in the net, that would be great.
9
Without getting in contact with people who were actually involved in these design decisions, I think we’re unlikely to find a definitive answer. However, based on the timelines of the development of both Java and C++, I would conjecture that Java’s boolean
was chosen before, or contemporaneously with, the introduction bool
to C++, and certainly before bool
was in wide use. It is possible that boolean
was chosen due to its longer history of use (as in Boolean Algebra), or to match other languages (such as Pascal) which already had a boolean
type.
Historical context
According to Evolving a language in and for the real world: C++ 1991-2006, the bool
type was introduced to C++ in 1993.
Java included boolean
in its first release in 1995 (Java Language Specification 1.0). The earliest language specification I can find is the Oak 0.2 specification (Oak was later renamed to Java). That Oak specification is marked “Copyright 1994”, but the project itself was started in 1991, and apparently had a working demo by the summer of 1992.
Actually, Java is more accurate to history here. The theory of true and false values was invented by George Boole and is commonly referred to as Boolean Algebra in his honor.
bool
is really just a shortcut to avoid a longer name, however, given the auto-completion support of modern IDEs, this is no longer a valid reason (and wasn’t even back in the days when Java decided to go for boolean
).
I have not been part of the decision process for Java, but if someone cares for history, then “Boolean algebra” is the relevant historical precedence, and one might as well question the C/C++ decision on why they mutilated Boole’s name by cutting off the e
.
5
I can’t address the consistency issue, but there’s a long history here.
As far as I recall, Algol 60 was the first language to refer to its logical types as ‘Boolean’. Algol 60 also had types like ‘integer’, ‘procedure’, etc.
Along came Algol 68, and abbreviations seemed to be in vogue: ‘bool’, ‘int’, ‘proc’, etc.
So, language designers can pick whichever style they like, and there’s a precedent for it.