Bool vs boolean - What's the difference?

621    Asked by AndrewJenkins in Java , Asked on Oct 10, 2022

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 rounds), so it'd be nice to know the rationale behind the current state of affairs.

If someone remembers (a part of) the story,Java has

int and Integer

boolean and Boolean

This seems a bit inconsistent, why not either

 or can even find and link to relevant historical discussion on the net, that would be great.

Answered by Amit jaisawal

Bool vs Boolean

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 of 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.



Your Answer

Interviews

Parent Categories