beanz Magazine

What’s the Point?!

Bastian Greshake Tzovaras on Flickr

Exploring the relationship between operators, negation, and exclamation points!

Years ago, when I first discovered that an exclamation point in computer code is called a bang, I decided to have some fun with it. While signing up for online software coding communities to ask for help solving difficult problems, I created an online name called fred!head…fred bang head… me, on my keyboard or desk, trying to solve coding problems. Get it?

I recently happened upon a question posted on Stack Exchange asking why ! was chosen to represent negation. That’s a terrific question about an obscure but critical part of programming: the operator.

What’s an operator? In programming, an operator is a symbol that indicates a math, relational, or logical action or process to be executed in code. Operators are everywhere in software code. They’re used to perform operations like evaluating data.

The ! operator is really interesting because it indicates negation. For example, this code would test whether or not a variable has been assigned a value:

if !$variable
    do something

In English, this code reads, if $variable is empty do something.

More common, though, the ! operator is used to test whether or not two values are equal:

if $variableA != $variableB
    do something

The != operator reads as not equal if the exclamation point means not in computing. In other words, the code above reads, if $variableA is not equal to $variableB do something.

However, how the exclamation point became an operator in programming isn’t obvious: why not use some other character?

The Stack Exchange article, Why was ! chosen for negation?, claims the earliest use was in an early programming language, B, which used a compiler language, BCPL as a model for its operators. The B language needed a character to indicate the concept of not equal but the BCPL compiler language didn’t have a usable operator.

The creators of B chose != because the exclamation point was one of only a few characters not used in programming languages at that point in time. Once they agreed to use != to indicate not equal, it was a small step to use the exclamation point by itself to indicate not, or negation. Other languages picked up this notation.

Is this really how the ! operator came to mean not in programming?

Reading the responses in the Stack Exchange article and other online research, the only clear truth is that when software programming languages were first created and defined in the 1950s and 1960s, no one documented how they decided what to use. They only documented how to use their language. And most perhaps all languages borrowed heavily from existing languages to solve common problems.

Learn More

Why was ! chosen for negation?

https://retrocomputing.stackexchange.com/questions/20085/why-was-chosen-for-negation

Operators in Computer Programming

https://en.wikipedia.org/wiki/Operator_(computer_programming)

Why is an exclamation mark called a bang?

https://english.stackexchange.com/questions/62918/why-is-the-exclamation-mark-called-a-bang

Why punctuation is important while coding

https://wecancodeit.org/coding-bootcamp-code-hints-why-punctuation-is-important-while-coding/
Exclamation point

https://www.techopedia.com/definition/7089/exclamation-point

Also In The October 2021 Issue

30+ ideas for STEAM-theme gifts for kids of all ages!

Everyone knows the difference between saying, “Let’s eat, grandma!” and “Let’s eat grandma!” Computers don't.

Join us as we weave together how looms and binary data are comparable!

Time for lesson two on how to make a fairy tale in Scratch!

Meet a 'Colossus' in the world of early encryption!

We all use fonts yet rarely notice they are designed. Here are some interesting details to help you notice fonts.

Looking to put your programming skills to the test? It may be time to join an open-source project!

Exploring the relationship between operators, negation, and exclamation points!

What is a G and why do we have 5 of them now? Find out through this quick history of cellular data!

Links from the bottom of all the October 2021 articles, collected in one place for you to print, share, or bookmark.

A collection of fun and inspiring stories from October 2021.