How RuneScape Helped Me Understand Scope
Stephen Nerby
Posted on March 27, 2022
Prior to starting at the Flatiron School, I was heavily into gaming. I played games my whole life of every variety and I’m so familiar with the rich world of gaming that it helps me to understand other things by providing context for learning new concepts. When I’m having difficulty understanding a new concept or grasping at something difficult to learn, I like to try to use my experience with games, particularly strategy and RPG games, to simplify new ideas.
This blog post, my very first, is about how my experience with games, both eclectic and popular, has served me well. I’m pumped to be able to use this as my first blog post because coding and gaming are so similar even in the most general sense: the application of new, complex concepts in coding requires building off rudimentary ones. I believe that this is an apt (even meta) analogy because I’m using gaming just to understand the rudimentary building blocks of coding. A good analogy requires a pretty snug fit of concepts into each other so I’d like to lead you through how years of playing RuneScape helped me to understand the technical concept of Scope–and I do believe they are a snuggly fit analogy. Let me know what you think!
Okay, so as I kind of hinted at just before: one of the ideas that I had struggled with understanding in coding is Scope. Scope at first seemed difficult to understand even in all of its simplicity. On its face, I felt I never encountered this concept before–but realized that RuneScape was far more helpful than the analogies provided by my instruction because of my intense familiarity with the game. Now as I’m thinking about how to understand Scope in terms that will allow me to fully understand and explain it others, I’d like to lead you through RuneScape–and if you already have an understanding of Scope but have never played RuneScape, you’ll end up getting a basic understanding of how RuneScape works in the process!
RuneScape is an open world fantasy MMO RPG (massive multiplayer online role playing game) where the entire goal of the game is to master a set of inherent skills: attacking, mining, cooking, fishing etc… All of your inherent skills in your skill tree start out at level 1 and depending on the version of the game you start out with 20-30ish skills. As you play and gain experience, you gain the ability to increase the level of your skill set according to how you want to play the game. Your goal in the game is to increase skill levels by gaining experience playing the game via exploring, attacking, completing “quests”, and really just putting the time in to explore the world.
Without getting into the nitty gritty of all of the game, let’s use the fishing skill tree as a very specific example in RuneScape to understand Scope and how it works. When I start playing RuneScape with a fresh character, I have a fishing skill at level 1. As I gain experience, I can level up my fishing skill if I’d like. What that means in the context of the game, is that with a higher fishing skill, I can now access new types of fish, equipment, and new areas of the map that were previously level-locked to inferior fishing skill levels.
For example: with a default fishing skill at level 1, I am only able to catch crayfish with a net in the sea… As I fish and play, I gain enough experience to increase a skill level. Now, at a fishing skill level 5, I can catch trout with a fishing rod up river… in addition to catching crayfish with a net. This kind of makes sense intuitively–someone who is a more experienced fisherman should be able to catch everything they were able to catch before, in addition to new types of fish that require more skill. As I increase in level, of course it would make sense that I am able to use more advanced tools in addition to tools I started with. Cool. Cool, cool, cool. By the way, if anyone I knew that played RuneScape heard me leveling up fishing before any other skill tree, they’d laugh. Because this is basically a skill that you clearly AFK. Don’t get it? No worries. Ignore me. I’m having fun here.
Okay, back to RuneScape and Scope… I think gaining experience in RuneScape is a lot like performing a new execution context. Every execution context creates a new scope and every experience gained is creating the ability to access a new level. So now that I have leveled up in my fishing skill, I can access new parts of the map, new tools, new quests, and new fish. Each level in a scope is like when you level your character’s skill… because once you level your skill you can access things that you couldn’t access before, and the higher level your skill, you have access to everything the previous levels had access to in addition to new accesses provided by your current level.
As mentioned, at a level 5 fishing skill in RuneScape, I can access all my previous fishing skills from level 1 (catching crayfish with a net), and I can now access all level 5 fishing skills (catching trout with a pole up river). Note that I still can’t access anything at higher levels (e.g., ≥ level 6). (That makes sense, I don’t have the experience or skill yet to catch shark or fish that would be considered more technically difficult to catch with more advanced fishing tools.) Similarly, when you create a new execution context, you increase your scope such that you can access everything encompassed by that context including prior contexts like global scope. Global scope, by the way, is akin to level 1 of a skill in RuneScape. Simply put:
(RS) Gaining experience == (JS) creating new execution context
(RS) Skill trees == (JS) Global scope
(RS) Fishing skill tree == (JS) Scope chain
(RS) Leveling up a skill == (JS) Scope access increases
(RS) Fishing level 5 == (JS) new execution context created scope access that encompasses global scope (RS level 1) and new execution contexts (RS up to level 5)
Now that I think of it as I’m writing, this may be a needlessly complicated analogy for someone who has not played RuneScape, but I’ll never forget how scope works with this analogy and I’ve successfully been able to explain scope to friends with no context for coding who do understand RuneScape. But I hope to continue to make analogies through nostalgic experiences–I think it’s fun and has been pretty useful for me. Though my instructors have been absolutely incredible at using analogies to explain concepts both simple and complex, I would recommend to anyone learning something new to form their own analogies so they forever stick, and so that you can easily access them when you attempt to explain your code or useful concepts to colleagues and others in general.
Posted on March 27, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.