Functional Programming

2025/12/27

Type
Learning Resource
Format
Glossary Article
Version
General
Subject Tags
Code
Assets
All else
Copyright 2016-2026, GDQuest
Created
2026/02/16
Updated
2025/12/27

Functional Programming

Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It's often considered a declarative programming paradigm, which means programming is done with expressions or declarations instead of statements.

Functional programming is based on the following principles:

Functional programming is often considered very different from imperative programming and object-oriented programming, but in reality, the same features can be found in both, just expressed differently.

Let's observe some of the features of object-oriented programming and see how they can be expressed in functional programming:

In functional programming, you can use data structures to represent objects. For example, instead of creating a Person class with properties and methods, you can represent a person as a dictionary:

func create_person(name: String, age: int) -> Dictionary:
    return {
        "name": name,
        "age": age
    }

You can also use encapsulated functions to work with this data structure:

func say_name(person: Dictionary) -> String:
    return "I am " + person["name"]

func create_person(name: String, age: int) -> Dictionary:
    var person := {
        "name": name,
        "age": age,
        "say_name": say_name.bind(person)
    }
    return person

Inheritance is also possible:

func create_student(name: String, age: int, grade: int) -> Dictionary:
    var student := create_person(name, age)
    student["grade"] = grade
    return student

As well as composition:

func augment_student(student: Dictionary) -> Dictionary:
    student["study"] = func(subject: String) -> String:
        return student["name"] + " is studying " + subject
    return student

In GDScript, these functions are a bit sub-par because we wouldn't get the benefits of type checking and autocompletion. But in a functional language like Haskell, these functions would be much more powerful.

Become an Indie Gamedev with GDQuest!

Don't stop here. Step-by-step tutorials are fun but they only take you so far.

Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!