An Old Dog, Scratch, and Python
As a programmer I’m a very old dog – been doing it since 1962. Lately I had to learn some new tricks: Scratch for my grandkids and Python to manipulate some astrophysical data with my son. These days communities grow up around computer languages. When you have a question, you Google it and usually find answers and examples galore. Since both Scratch and Python are popular, there is a great deal of help available for both of them and much contributed code to copy and build on.
This is what Scratch looks like:
You drag the little puzzle pieces around to construct a program. It is particularly good for graphic programs: this one controls a robot in a maze. Grandchildren from 7 up were able to use it quickly. Two out of three had already been exposed to Scratch in public schools. Two of these three budding programmers are girls. You can watch the robot here.
And this is some Python:
Looks much more like what I’m used to in a programming language and was much easier for me to learn than Scratch. In other computer languages this process would have had to loop through the values in the arrays radec and c; Python can process a whole array in a single statement. Very cool if you’re a math nerd. This snippet also shows how you build on other people’s code: numpy is an excellent library of math routines and astropy has special capabilities for astrophysics. They were built by volunteers.
As my graddkids and I create capabilities, we will share them as well. That’s part of the learning. Meanwhile feel free to use our code if you need to control a robot or convert radec coordinates of celestial objects to a cartesian grid.
Comments