Pages

Monday, November 13, 2023

Using MIT's Scratch for the First Time

This week, I wrote a simple program using MIT’s Scratch programming language. In contrast to most popular programming languages, Scratch programs are coded using visual “blocks” of commands instead of by manual input. Commands can be dragged and dropped from a sidebar into one’s program, making it an effective way to teach a beginner the basic tenets of programming. Here, I will discuss my experience using Scratch for the first time and the details of my first program, and contrast Scratch with my understanding of low- and high-level programming languages and explain how a language like Scratch could be a stepping stone for novice and aspiring programmers.

Using the built-in tutorials as inspiration, I devised my first program in the Scratch language: a rudimentary game where a ball bounces freely around the screen, the object being to click the ball to score. Each time the ball is clicked, it changes color, a “boing” sound plays, and a score counter increases by 1; additionally, the ball moves marginally faster. This process continues until you successfully click the ball four times, at which point the ball disappears and is replaced by a sprite announcing that you have won the game.

Having never used or heard of Scratch before this week, I was intrigued by its ease of use. On a personal note, I had tried to teach myself a handful of languages (such as BASIC and HTML) when I was much younger and would have loved using something like Scratch if it had existed when I was coming of age. I did find the tutorials a little clunky, and considering it had been many years since I had last used a programming language, I was slow to start acclimating to the interface and the functionalities of each block. However, I found a wealth of knowledge on the Scratch message boards, and was able to successfully jump between the tutorials and the boards the handful of times I hit a wall in a piece of code. The program I conceived is incredibly basic, and there are elements of it that I may go back & attempt to simplify (for example, I am not sure if I needed a separate group of blocks for each succession in score or if there is any way to repeat and incrementally increase such instructions). Still, I found using Scratch a valuable exercise in readapting myself to the basics of programming.

Though Scratch’s visual, block-based structure is likely to be incredibly helpful to someone with no programming experience, there were times when I would have preferred just being able to type the code out rather than having to scroll through the categories & manually drag and drop them. Still, this makes Scratch a great precursor to another high-level language such as Python. A significant benefit of a language like Python is that it is a powerful, pliable language while still being relatively simple to learn, considering it uses easy-to-understand commands. To contrast the two, Scratch’s coding sidebar has a “variables” option, where variables can be set and then dragged & dropped into various commands. In Python, there is no command for setting a variable – you simply declare the value of a character in a line of code (i.e., “x =5”). Both functions accomplish the same thing in their respective languages – only one is controlled using a graphical interface, and the other is typed manually.

High-level languages like Python and Scratch stand in stark contrast to low-level languages, such as machine and assembly code. Machine language is what your computer’s central processing unit (CPU) understands, which is only a mixture of 1’s and 0’s; assembly language can be used to convert plain language commands to something your machine will understand. High-level languages simplify the commands of assembly language even further. The code using these languages can be compiled into a working program with no need for knowledge of assembly or machine language. Nowadays, high-level languages are used predominantly, and there are very few applications where a programmer would use a low-level language.

Of the languages discussed here, Scratch’s graphical interface made it the easiest to use and learn. However, given that I already held a basic understanding of programming, I enjoyed digging into Python slightly more, as I vastly preferred being able to write the code out manually. Again, Scratch is a great way to learn the core principles of programming, but its power is restricted by the fact that a relatively small number of total commands can be used. Of course, this is by design, given that it is geared towards younger users and is primarily not intended for commercial or public purposes. Other high-level languages, such as Python or C++, are far more adaptable and can be used for seemingly endless purposes. Still, the commands within such languages are more accessible to understand than in machine or assembly language, and their ability to be compiled & converted into machine code ensures that they are principally used among professional programmers.

Overall, I appreciated my experience with creating a simple game in the Scratch language this week. Using a language as simple as Scratch re-taught me the essential elements of programming, and it was gratifying to overcome roadblocks and end the week with a working, albeit elementary, program. I look forward to using this experience as a jumping-off point to immerse myself deeper in more intensive and powerful high-level languages, including Python.

No comments:

Post a Comment