Functional Programming
2025/12/27
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Created
- Updated
- 2026/02/16
- 2025/12/27
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 personInheritance is also possible:
func create_student(name: String, age: int, grade: int) -> Dictionary:
var student := create_person(name, age)
student["grade"] = grade
return studentAs well as composition:
func augment_student(student: Dictionary) -> Dictionary:
student["study"] = func(subject: String) -> String:
return student["name"] + " is studying " + subject
return studentIn 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.
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.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…