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?

有帮助吗?

解决方案

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

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top