Programming With Scratch
And Other Languages
My Scratch Experience
I chose to create a game. My completed game is here: https://scratch.mit.edu/projects/748271634. (It still could use cosmetic touches.) In the game, you control a girl named Abby with the mouse and lead her around the landscape to collect as many apples as possible. There is also a bear collecting the apples. Abby must avoid the bear while getting the apples faster than the bear. The games ends when all the apples are gone or collected, or when the bear gets Abby.
A Learning Experience
This was a learning process for me. I experimented with different graphical commands to see if they did what I wanted. I found a video online to discover how to make a sprite (apple) disappear. The answer was rather obvious: use the “hide” command (Ucode, 2013).
The Misguided Bear
Another problem was finding how to make the bear skip an apple that Abby already got. The author ended up having to add more variables to track which apples were still available.
The Concurrency Puzzle
My final quandary was correcting a bug where the bear would sometimes skip the first apple at the beginning and head straight to the second or third apple. I finally realized that this game was seven threads or programs running simultaneously, with one thread for each sprite. So, if the first apple thread did not unhide itself (from all the apple sprites being hidden at the end of the previous game) before the bear thread made its decision about which apple to pursue, then the bear would head to the first nonhidden apple. So, the author had the bear wait one second at the beginning of the game so all the apples could initialize properly first.
The author gained an insight into thread concurrency that he usually doesn’t have to worry about at his employment.
Machine Code
In recent reading, I was re-introduced to machine language, assembly language, and Python (Vahid, 2019). The author’s experience with machine language was too long ago. Machine language is not appropriate for most projects. Creating a program with machine language is too tedious and requires extensive knowledge of the hardware. Such code would not work on other types of computers, even if the microprocessor was the same. You also need to know the hardware addresses of the other peripherals on the motherboard and how to operate them from a low level.
Assembly language is more convenient than machine code because you can use most text editors to write it and it usually allows for some shortcuts and constants. However, it still does not shield you from having to know the hardware intimately. I have little experience with assemblers.
High-Level Code
Different high-level languages have different levels of how high or low level they can go. But they all are significantly higher than assembly language. Some high-level languages require compilation, to convert the source code into machine code. For others, the source code can be executed directly with the program that executes such source code. I most frequently Python.
The advantage of high-level languages is that you are not required to know much about the hardware. And the source code you create can likely be run on most types of computers, though it might need to be recompiled.
Scratch is Unique
Scratch has a unique difference in that you use graphical picture commands instead of text code words. I found this refreshing and after learning it, found it easy. But it was limited in what kinds of programs I could make with Scratch.
Favorites
Before, I favored Java because I liked the strict object-oriented concepts it used. I liked C because it produces programs that were fast. Now I prefer Python because that is what I used the most during the last two years. Python seems the easiest to use because it does not require compiling and has features to make it easy to experiment with and has libraries of functionality to do just about anything. From the current perspective of my workplace, their favorites there are C and python.
Another advantage of C is that it is a low-level language compared to other high-level languages. At my place of employment, they need to make a lot of “firmware”. Firmware is like the operating system inside of electronic devices such as SSD drives, and the program is specifically for operating the hardware at a low level. So, C is the obvious choice in that case.
Conclusion
Scratch is a unique language making the purpose and goal of programming more obvious to children and beginners. It also introduces some important general concepts of programming. But it is only a small part of the programming world. There are many more amazing things you can do with programming.

Comments
Post a Comment