user-1: There is a special, non-standard Arduino data type called "boolean".
How does it compare with the standard C++ data type "bool", and what are the reasons to use one or the other?
If they are identical in usage, why do both exist, and which one is preferred in Arduino code?

user27653: A Boolean variable type is one that has only 2 possible values, true or false.
Internally, it is created as an int (16-bit integer) or a uint8_t type (8-bit integer).
You can assign the "values" of true or false using the assignment operator:
bool foo;
foo = true;
if (foo) {
  do_something();
}

Internally, a true is a 1 and a false is a 0, and the number values could be equally substituted. 
Boolean types in Arduino and C++ mostly exist for readability, and not for any particular efficiency over int type.

user31105: The official reference can be found here
It is best to always use true and false, and not use numbers.
Below some examples are given
Assign false resp true to a Boolean:
bool a = true;
bool b = false;

Check the Boolean value:
if (b)
{
   // Executed when b is true
}
else
{
   // Executed when b is false
}

if (a && b)
{
   // Executed when a is true and b is true
}

if (a || b)
{
   // Executed when a is true or b is true
}

If b is false, a will be false, otherwise a will stay as it was
a &= b;

If b is true, a will be true, otherwise a will stay as it was
a |= b;

// If a is true it will be false and vice versa.
a = !a;


user26916: While the other answers give generally useful information, the authors seem to have not read the question very carefully because they are talking about the bool type rather than the boolean type. In the Arduino API, boolean is a type alias for bool, as defined in Arduino.h:
https://github.com/arduino/Arduino/blob/1.8.3/hardware/arduino/avr/cores/arduino/Arduino.h#L125
typedef bool boolean;

So you can use the boolean type just as you would bool and any standard C++ programming reference will instruct you in the use of bool. For this reason the other answers which mistakenly refer to bool are still somewhat useful.
Apparently at some point in the past the Arduino folks decided the name boolean would be more beginner friendly than bool, perhaps to be consistent with the Processing language. However, as discussed here:
https://github.com/arduino/Arduino/issues/4673
the unnecessary use of a non-standard type is now considered by some to be a poor decision as its use makes code less portable and really doesn't provide any clear advantage over bool. A proposal is in the works to remove the use of boolean from all official Arduino code and document bool in the Arduino reference and some even wish to formally deprecate boolean. Therefore my advice is to use bool instead of boolean in your code.

-1: <p>There is a special, non-standard Arduino data type called &quot;boolean&quot;.</p>
<p>How does it compare with the standard C++ data type &quot;bool&quot;, and what are the reasons to use one or the other?</p>
<p>If they are identical in usage, why do both exist, and which one is preferred in Arduino code?</p>
 27653: <p>A Boolean variable type is one that has only 2 possible values, <code>true</code> or <code>false</code>.
Internally, it is created as an <code>int</code> (16-bit integer) or a <code>uint8_t</code> type (8-bit integer).</p>

<p>You can assign the "values" of <code>true</code> or <code>false</code> using the assignment operator:</p>

<pre><code>bool foo;
foo = true;
if (foo) {
  do_something();
}
</code></pre>

<p>Internally, a <code>true</code> is a <code>1</code> and a <code>false</code> is a <code>0</code>, and the number values could be equally substituted. </p>

<p>Boolean types in Arduino and C++ mostly exist for readability, and not for any particular efficiency over <code>int</code> type.</p>
 31105: <p>The official reference can be found <a href="https://www.arduino.cc/en/Reference/BooleanVariables" rel="nofollow noreferrer">here</a></p>

<p>It is best to always use true and false, and not use numbers.</p>

<p>Below some examples are given</p>

<p>Assign false resp true to a Boolean:</p>

<pre><code>bool a = true;
bool b = false;
</code></pre>

<p>Check the Boolean value:</p>

<pre><code>if (b)
{
   // Executed when b is true
}
else
{
   // Executed when b is false
}

if (a &amp;&amp; b)
{
   // Executed when a is true and b is true
}

if (a || b)
{
   // Executed when a is true or b is true
}
</code></pre>

<p>If b is false, a will be false, otherwise a will stay as it was</p>

<pre><code>a &amp;= b;
</code></pre>

<p>If b is true, a will be true, otherwise a will stay as it was</p>

<pre><code>a |= b;
</code></pre>

<p>// If a is true it will be false and vice versa.</p>

<pre><code>a = !a;
</code></pre>
 26916: <p>While the other answers give generally useful information, the authors seem to have not read the question very carefully because they are talking about the <strong>bool</strong> type rather than the <strong>boolean</strong> type. In the Arduino API, <code>boolean</code> is a type alias for <code>bool</code>, as defined in Arduino.h:</p>

<p><a href="https://github.com/arduino/Arduino/blob/1.8.3/hardware/arduino/avr/cores/arduino/Arduino.h#L125" rel="noreferrer">https://github.com/arduino/Arduino/blob/1.8.3/hardware/arduino/avr/cores/arduino/Arduino.h#L125</a></p>

<pre><code>typedef bool boolean;
</code></pre>

<p>So you can use the <code>boolean</code> type just as you would <code>bool</code> and any standard C++ programming reference will instruct you in the use of <code>bool</code>. For this reason the other answers which mistakenly refer to <code>bool</code> are still somewhat useful.</p>

<p>Apparently at some point in the past the Arduino folks decided the name <code>boolean</code> would be more beginner friendly than <code>bool</code>, perhaps to be <a href="https://processing.org/reference/boolean.html" rel="noreferrer">consistent with the Processing language</a>. However, as discussed here:</p>

<p><a href="https://github.com/arduino/Arduino/issues/4673" rel="noreferrer">https://github.com/arduino/Arduino/issues/4673</a></p>

<p>the unnecessary use of a non-standard type is now considered by some to be a poor decision as its use makes code less portable and really doesn't provide any clear advantage over <code>bool</code>. A proposal is in the works to remove the use of <code>boolean</code> from all official Arduino code and document <code>bool</code> in the Arduino reference and some even wish to formally deprecate <code>boolean</code>. Therefore my advice is to use <code>bool</code> instead of <code>boolean</code> in your code.</p>
