Pergunta

Why do we use "&&" instead of "and" in so many languages? I get that it has sort of become the standard for programmers, but how did that originally happen?

Foi útil?

Solução

It is up to the language designer to make these decisions, but one reason is that there is two types of and - regular and bitwise (&& vs &)

It's harder to succinctly express the bitwise version using English words

Outras dicas

Why did programming languages originally use “&&” instead of “and”?

You have it back to front. Originally they used and: Fortran, Cobol, Algol, Pascal, PL/1, all the varieties of Basic, ...

It was the BCPL series of languages (B, C, C++) that introduced & and && as far as I know, and Java and C# followed suit. You would have to ask the BCPL designers why, if they are still around.

APL used the set-theoretic symbols ^ and its inversion.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top