Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Java has

  • int and Integer
  • boolean and Boolean

This seems a bit inconsistent, why not either

  • bool vs Boolean to use an established shorter name for primitive type?

or

  • integer vs Integer 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.

share|improve this question
4  
boolean is definitely more explicit than bool. I'd rather ask why int is not called integer. My guess: int and char where too ingrained to be changed to integer and character, but bool was not yet fully established. –  Joachim Sauer Mar 21 '13 at 10:06
    
"I think C++ had decided to use bool quite a bit earlier than Java decided to use boolean" Why do you think that? –  John Bartholomew Mar 21 '13 at 15:23
3  
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, but the Java project itself was started in 1991. Without finding further sources of information, it's not clear to me which came first, or what (if any) influence they had on each other. –  John Bartholomew Mar 21 '13 at 15:29
2  
The Oak language specification (version 0.2, copyrighted 1994) also includes the boolean type. (Oak was later renamed to Java). That pushes the dates even closer, though I still see no definite evidence to show precedence, or influence, in either direction. –  John Bartholomew Mar 21 '13 at 15:48
    
It isn't inconsistent, there are double and Double as well. –  vorrtex Mar 21 '13 at 15:50
show 4 more comments

2 Answers

up vote 12 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
1  
Same reason the POSIX call to create a file is called creat(). –  Blrfl Mar 21 '13 at 12:00
3  
So you're saying int should be integer? –  delnan Mar 21 '13 at 13:27
2  
If you want to be historically accurate, then I think Boolean is kind of bad, considering it can have 3 values (Boolean.FALSE, Boolean.TRUE, null)... Point being, programming language symbols and reserved words are always a compromise of several factors, and historical accuracy is probably pretty low on that list. –  hyde Mar 21 '13 at 16:47
    
I have no intention of being historically accurate, but don't forget, that not all languages allow for that billion-dollar-mistake called null. –  Frank Mar 22 '13 at 6:08
    
@Frank Hey, I'm just converting a specific NullPointerException situation to nicer error reporting and handling, and trying to actively forget LALALAA not hearing what you say LALALAA ;-) –  hyde Mar 22 '13 at 9:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.