Hello Nostalgia: (Re)discover the Joy of Programming on the Steam Deck (Part 2)
In our modern era of computing and gaming where big budget AAA games and closed console ecosystems dominate, there’s a longing for the simpler, more open times, where kids and adults alike were encouraged to code.
In the previous article we covered:
- The resurgence of real open handheld computing in the form of Valve’s Steam Deck which runs Arch Linux
- A journey back to a time when coding was a first class citizen on our devices.
- How we can begin coding using the Steam Deck by coding using online tools.
See:
Be Prepared to Solve Problems!
Coding purely online is fun for a while and should be part of your toolkit but has limitations. If you want to gain real serious experience and use the power of your Steam Deck, setting up your own environments and running outside of the browser is where the greater challenge is to be had and something you will need to understand.
Just bear in mind that code doesn’t always do what you may want it to do the first time. Or at times even the second, third, or forth. Don’t give up! Much of the joy comes in overcoming those challenges. You’re choosing the path of a problem solver, so get strapped in for the ride. You’re effectively saying:
The good news is that you’re not alone on the journey and there’s guidance in more places and made more accessible today than ever before.
My advice? The same that I would give to professional software engineers. Keep an engineering day book! This is a pragmatic (practical) approach to engineering that was described in “The Pragmatic Programmer” (I also recommend this book makes it to your bookshelf or audiobook list if you continue to pursue an engineering career in life).
The goal? A daybook / journal will help coders and engineers of all levels to record daily lessons, progress, and reflections, much like the journaling process used by many electrical or mechanical engineers for years.
Key Benefits Explained:
- “[Keeping a daybook/journal] is more reliable than memory.”
- “[Keeping a daybook/journal] gives you a place to store ideas that aren’t immediately relevant to the task at hand.”
- “[Keeping a daybook/journal] acts as a kind of rubber duck.” (explaining a problem to someone else, possibly even to someone who knows nothing about programming — like your coding journal effectively helps you to discover the solution in the process of explaining the problem.)
Keep a detailed journal to record your coding experiences, including the challenges you face, solutions you come up with, and any obstacles you encounter. Be open about the difficulties you encounter so you can learn from them. Write down any “aha” moments, clever ideas, or new perspectives that come to you while coding, as they could be useful in the future. Take time to think about your daily decisions, both good and bad, to improve your skills. Use your journal to store useful bits of code, algorithms, and design patterns for easy reference. Lastly, track your personal growth and celebrate your achievements, while also identifying areas where you can improve.
You can use digital journals, plain notebooks, or more focused and specialized ones like those from The Hot Company (shameless plug).
Let’s continue to cover how to get started coding offline on the Steam Deck.
Setting Up the Development Environment (Continued):
Part 2: Coding Offline
- Open Discover — it’s a small blue folder in the menu bar.
- Search for “pycharm” and install PyCharm-Community edition
- Once installed you can either Launch it directly from Discover or find and open it from the Steam Deck menu.
- If you’re given an option to “Open in Project” select Open in Project rather than LightEdit as it will be far more useful.
- In the Choose Project Root Directory navigate to /home/deck/Desktop and create a folder (using the folder icon with a + sign) called hello (or another suitable name), and select Ok. This should create a new project in the location /home/deck/Desktop/hello.
- In the Trust and Open Project ‘hello’? dialog, select Trust Project.
- This will create a sample project and open main.py.
8. Press play to execute the program. It will output something similar to the below:
/usr/bin/python3.10 /home/deck/Desktop/hello/main.py
Hi, PyCharm
Process finished with exit code 0
Tip: Increase the font size if using the steam deck screen by:
- Double-tapping the shift key
- Type “Change font size” and toggle the Change font size with Ctrl+Mouse Scroll Wheel in: option on.
- Using Ctrl + the mouse scroll wheel adjust the font size to a comfortable size (If you struggle to do this double-tap the shift key and select Increase Font Size)
- Overview of development tools available on the Steam Deck.
The console (or rather Konsole) is another essential tool to become familiar with. It will enable you to run your programs whether PyCharm is open or not.
- Open the Steam Deck menu (in the bottom left corner).
- Run the program called Konsole (it has a square icon with > in it).
3. Type cd /home/deck/Desktop/hello [enter] to ‘cd’ into (or change directory to) your project.
4. Type python -V [enter] to see the version of python running in the Konsole (which may, or may not, be the same one as in PyCharm).
5. Now run your program from the Konsole by typing python main.py. If successful, your program should execute and output:
Hi, PyCharm
- You can experiment with python syntax (code) by running the python shell. Simply type python [enter] in the Konsole window.
2. Type quit() [enter] whilst in the Python interpreter to exit back to the regular Konsole shell.
Be Adventurous and Explore
For example you could replace the code in main.py with the code from PyGame: Hello World, and see what happens when you press play.
import pygame, sys
pygame.init()
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption("Hello World")
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
/usr/bin/python3.10 /home/deck/Desktop/hello/main.py
Traceback (most recent call last):
File "/home/deck/Desktop/hello/main.py", line 1, in <module>
import pygame, sys
ModuleNotFoundError: No module named 'pygame'
Process finished with exit code 1
You should at this point have been taking good notes! As we said just earlier:
Bear in mind that code doesn’t always do what you may want it to do the first time. Or at times even the second, third, or forth. Don’t give up! Much of the joy comes in overcoming those challenges. You’re choosing the path of a problem solver, so get strapped in for the ride.
Right now your IDE has no AI assistant to make you 10X faster, so it’s you an error and the internet — just like it used to be. Thankfully, though, this is a common issue with a simple fix.
- Hover the mouse cursor over the red-underlined package pygame. Pycharm understands the issue and offers a resolution.
2. Selecting Install package pygame or selecting Alt-Shift-Enter will install the missing pygame module. ‘Module’ is often used to mean the same thing as ‘Package’
In simple terms, we can consider a module to be the same as a code library or a file that contains a set of functions that you want to include in your application.
Pygame is a set of Python modules designed for writing video games.
3. If prompted with an Administrator Privileges Required window, choose to Configure a per-project virtual environment.
4. Select the Python 3.10 interpreter (or whichever version it displays on your device)
5. If that still fails to work take the easy way out open the Terminal window in PyCharm (Alt-F12 or double-tap shift and type Terminal [enter] or click the suare icon inside of PyCharm with the >_ ).
6. Type pip install pygame [enter] to install the package manually using the python interpreter PyCharm is using. If you do install it this ‘hacky’ way you may have to restart you PyCharm for the error to clear, and to get some peace of mind.
7. After the package has been successfully installed, you can run it successfully in PyCharm by pressing play.
8. A pygame window will pop up with “Hello World” in the title bar. Once, ready you can close the window or press the stop button in PyCharm to shut it down.
Congratulations you’re solving real problems, you’re an engineer!
Below are some additional links to resources below to further your journey. Why not try go through some tutorials, courses, or jump right in and try some more code listings out in your IDE?
Additional Resources
IDEs
Projects / Code Listings
Learning
References
Steam Deck
In the next article we will we will cover some other programming languages, push the boundaries a bit further, build communities and connect, and the joy of exploration!
Happy Coding on Deck!