Before understanding why functions are called first-class citizens in some programming languages and not in others, we need to understand what a first-class citizen means in a programming language.


What is a First-Class Citizen?

In programming, a first-class citizen (or first-class object) is an entity that can be treated like any other value in the language.

This means it can:

  1. Be assigned to a variable.
  2. Be passed as an argument to a function.
  3. Be returned from a function.
  4. Be stored in data structures (like lists, maps, etc.).

Example — Functions as First-Class Citizens (Python)

def greet():
    return "Hello"

# 1. Assigned to a variable
say_hello = greet

# 2. Passed as an argument
def call_func(func):
    print(func())

call_func(say_hello)

# 3. Returned from a function
def outer():
    return greet

inner = outer()
print(inner())

Here, functions are first-class citizens because they can be assigned, passed, and returned.


Who Are the First-Class Citizens in Popular Languages?

C

C++