STEM Project Programming Language Choice — Scala
How a father and daughter learned Scala to find the list of words that can be made by combining the symbols of periodic elements.
Join the DZone community and get the full member experience.Join For Free
My daughter Sara who is in 3rd grade and I recently worked together on a school-initiated STEM (Science, Technology, Engineering and Math) project and decided to do a programming challenge. I had recently got the excellent Elements book for her and we wanted to connect the project to the Chemical Elements in some way. An idea that came to us was to try and combine the symbol of the elements and form words from them. So, for example, if you combine Phosphorus(P), Indium(In), Carbon(C), and Hydrogen(H), you get PInCH. On an initial whim this sounded like an interesting and at the same time challenging enough problem for us to attempt.
With the choice of language in place I was able to show her some basics of programming with Scala — declaring variables, simple functions, some basics of data types, basics of collections, and simple ways to map collections.
We then jumped into the program itself. The approach we outlined and wrote was simple enough: we needed a dictionary of words, a list of elements, something to generate the words by combining elements, and to filter them using the dictionary. The final code is fairly easy to navigate. We have avoided concepts like recursion, any complicated data structures to validate words, and stuck to simple iteration to generate the words.
We found about 12,000 words altogether, these are some that caught our eye:
The revelation for me though has been in how easily my daughter picked up on the programming language concepts with a seemingly difficult language like Scala. I know there are more difficult concepts along the way once we get past the basics, however my choice of Scala was to ensure that the foundation is strong enough. I will let her explore more esoteric features by herself when she works on her STEM project for next year!
Published at DZone with permission of Biju Kunjummen, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.