# Foo / Foobar in Computer Science

Get FREE domain for 1st year and build your brand new site

Foo or Foobar in Computer Science/ Programming is a commonly used name for variables and functions. It denotes that the concerned variable or function exists to demonstrate a particular concepts and has no specific identify.

We have covered the rich history of foobar involving MIT and DEC in 1959 and its use today in programming and other events like Google FooBar challenge.

Example:

Following is an example use of the terms in C programming language:

void foo(char* bar)
{
printf("%s", bar);
}


## Wide usage

Foo and bar are widely used terms in Programming books. At GitHub, there are:

• 111,056,095 (111M+) files that use foo as a variable name
• 162,716,701 (162M+) files use bar as a variable name
• 15,431,221 (15M+) files use foobar

This results in 288M+ files which is infact as huge number considering that there are 138M repositories at GitHub.

## History of foo bar

Foo Bar has its roots to the word FUBAR from World War 2 which denotes that "things have gone out of control".

2 major organizations are behind the popularization of the terms namely Digital Equipment Corporation (DEC) and Massachusetts Institute of Technology (MIT). The first seen use of the terms date back to 1964 from 3 major projects namely:

• PDP-1 from Digital Equipment Corporation
• LISP by John McCarthy at Massachusetts Institute of Technology (MIT)
• Project on Mathematics and Computation (Project MAC)

PDP-1 was a computational hardware/ system developed by Digital Equipment Corporation in 1959 and was widely used at the time.

LISP is functional programming language and is considered the second oldest high level programming language which is in use even today.

Project on Mathematics and Computation was an effort in the 1960s led by MIT and funded by Defense Advanced Research Projects Agency to create a time sharing computing device.

In fact, the 3 projects have shaped the computing systems we use today and have given us foo and bar as a practice used by them to make these major advancements.

It appeared on the 14th January 1938 edition of The Tech which is MIT's oldest and largest newspaper and the first online newspaper as well:

It came up in later editions of various newspapers as well. It was in 1959 that it made its entry in Computer Science.

## Use in Linux codebase

Linux codebase is a large and widely used codebase in form of an end product. It has been over 30+ years since the project started and this massive codebase also uses foo/ foobar as identify names.

We will give some examples:

### File: linux/lib/test_debug_virtual.c

This file in location "linux/lib/test_debug_virtual.c" uses foo as a struct name and bar as a internal field name.

Following is the section of the file:

struct foo {
unsigned int bar;
};

static struct foo *foo;


### File: linux/tools/testing/selftests/bpf/test_cgroup_attach.c

This file creates temporary folders as a part of its testing procedure. It names its temporary folders as foo and bar.

A small section of the code defining the macros is:

#define FOO		"/foo"
#define BAR		"/foo/bar/"
#define PING_CMD	"ping -q -c1 -w1 127.0.0.1 > /dev/null"

char bpf_log_buf[BPF_LOG_BUF_SIZE];


## Other events inspired by it

There are several things whose name has been inspired by this:

It is a coding challenge which is run by Google to hire engineers and the challenges are provided suddenly when the programmer uses Google Search for a particular topic.

• Foo Camp

It is an annual hacker event (unconference) organized by O'Reilly Media since 2003.

• Bar Camp

Bar Camp is a network of conferences based on Computing and Technology and was created based on the structure of Foo Bar in 2006.

• FooBar2000

It is a free audio player for Windows, Linux and MacOS.

#### OpenGenus Foundation

The official account of OpenGenus IQ backed by GitHub, DigitalOcean and Discourse

Vote for OpenGenus Foundation for Top Writers 2021:

Improved & Reviewed by: