Search code examples
cbooleanboolean-logicboolean-operations

Why we have boolean type?


I learned that C does not have the boolean type. When I read "Ocaml from very beginning", I encountered a question in page12 :

Why we cannot just use 0 and 1 to represent the boolean type in camel, like the way C language does?


Solution

  • why some languages have boolean type but others don't?

    Because some languages have a better type system than others. In my opinion, for many (but not all) tasks, Ocaml has a better type system than C.

    (but your question is too broad & matter of opinion)

    The C type system was closely inspired by the hardware (PDP-11) and instruction set available at the time (early 1970s) C was designed.