Simon Painter
Down the Oregon Trail with Functional C#
#1about 5 minutes
Core principles of the functional programming paradigm
Functional programming is a declarative style emphasizing immutability, pure functions, and expressions over statements to write more testable and robust code.
#2about 2 minutes
Applying the umbra and penumbra metaphor to C#
Achieve nearly pure functional code by isolating necessary compromises, like I/O, to the outer edges (penumbra) of the application.
#3about 3 minutes
The historical context behind the Oregon Trail game
The game is based on the 19th-century migration of settlers in covered wagons from the US East Coast to Oregon.
#4about 7 minutes
How BASIC and time-sharing enabled interactive games
The creation of the user-friendly BASIC language and time-sharing terminals at Dartmouth University led to a boom in early computer games.
#5about 4 minutes
Analyzing the original 1975 Oregon Trail BASIC code
The original game's logic is built on line numbers, GOTO statements, and reversed IF conditions, which requires careful translation.
#6about 11 minutes
Handling impure user input with discriminated unions
Manage the side effects of console input by wrapping results in a `Maybe` type, a discriminated union representing `Something`, `Nothing`, or `Error` states.
#7about 5 minutes
Replacing indefinite loops with a functional helper
Avoid imperative `while` loops for input validation by using a recursive `iterate until` helper function that encapsulates the looping logic.
#8about 2 minutes
Structuring the main game loop with a monadic flow
Chain game events together using a `continue game` extension method that checks the game state before executing the next function, simplifying the main loop.
#9about 1 minute
Recreating the time-based hunting mini-game functionally
Implement the time-sensitive "type BANG" mechanic by injecting a time service to enable pure, testable functions for calculating shot accuracy.
#10about 3 minutes
Refactoring complex conditional logic with switch expressions
Replace the original game's convoluted, nested IF statements for rider encounters with a clean and readable C# switch expression.
#11about 3 minutes
Exploring other classic text-based games to remake
Consider other classic text-based games like Star Trek, Doctor Who, and Zork as potential future projects for functional programming exercises.
Related jobs
Jobs that call for the skills explored in this talk.
MARKT-PILOT GmbH
Stuttgart, Germany
Remote
€75-90K
Senior
Java
TypeScript
+1
Matching moments
02:18 MIN
Shifting from object-oriented to functional programming
F#, path to functional enlightenment
02:00 MIN
Real-world applications of functional programming
A Guide To Functional Programming
05:28 MIN
Legacy code, BASIC, and modern scrollytelling UIs
WeAreDevelopers LIVE - 50 years Microsoft, Web Readiness Report, The German Web Community and more
02:36 MIN
Understanding functional programming principles in C++
Functional Programming in C++
02:13 MIN
Core principles of functional programming
A Guide To Functional Programming
06:04 MIN
Audience Q&A on functional programming concepts
A Guide To Functional Programming
07:21 MIN
Contrasting minimalist code with modernizing legacy applications
The weekly developer show: Boosting Python with CUDA, CSS Updates & Navigating New Tech Stacks
00:31 MIN
Comparing functional and object-oriented paradigms
Phel, a native Lisp for PHP
Featured Partners
Related Videos
Exploring the Latest Features of .NET and C# by Building a Game
Rainer Stropek
Hacking C# from the inside - how to do anything in NET
Adam Furmanek
C# 13 Unleashed: Live Demos of my Top 10 Cutting-Edge Features!
Ambesh Singh & Sachin Kumar
Building a Compiler with C#
Florian Rappl
F#, path to functional enlightenment
Onur Gumus
A Guide To Functional Programming
Jemima Abu
Tips, tricks and quirks in .NET
Paweł Łukaszuk
Modern C#: A Dive into the Community's Most Loved new Features.
Louëlla Creemers
Related Articles
View all articles



From learning to earning
Jobs that call for the skills explored in this talk.

Code Healers LLC
Hinesville, United States of America
Remote
€30-40K
Intermediate
Senior
.NET
React
JavaScript
+2

Visonum GmbH
Remote
Junior
Intermediate
React
Redux
TypeScript

Universally Speaking
Wyboston, Chawston and Colesden, United Kingdom
JIRA
Microsoft Office

Datascope Recruitment
Remote
Intermediate
C++
Unreal Engine
Adobe Analytics

Frontier Developments plc
Cambridge, United Kingdom
API
C++
Adobe Analytics
Continuous Integration

Datascope Recruitment
Remote
Intermediate
C++
Unreal Engine
Adobe Analytics



TechNET IT Recruitment
Senior
API
WebGL
Docker
Node.js
TypeScript
+2