Scala logo

Scala Plugin

Scala Plugin for IntelliJ IDEA and Android Studio

Interviews

Interview with Shadaj Laddad: Programming Changes the Way You Think

Scala Days is not only a major event for the Scala community, but also a great place to meet amazing people and get inspiration. If you’ve been to Scala Days in Berlin this year, you might have seen a great talk “Serious Fun with Scala” by a 14 years old Shadaj Laddad, Scala enthusiast and wunderkind. We couldn’t miss the chance to catch Shadaj and ask him a few questions for our blog about Scala, learning programming, game development, math and science.

At OSCON 2014 you gave a splendid opening keynote “The Wonders of Programming”. At your age this talk has not only made you famous as one of the youngest programmers, but also made you the youngest enthusiast who encourages other people to program. How did it happen that you got interested in programming?

I started getting into programming when I was around 6 years old. My dad got me the (just released at the time) Lego Mindstorms NXT kit, a robotics platform that uses Lego parts but also has motors and sensors that can be programmed with a simple graphical language. I started out following the directions that came with the kit, but in the process I learned how I can make my own creations. Next, my dad got me Learn to Program by Chris Pine. This book teaches Ruby, but assumes that the reader has no previous knowledge of programming. The book showed many interesting applications of programming concepts such as how a simulation game could use a two-dimensional array to store building locations. I continued to learn new programming languages such as Python through another book, Hello World. Somewhere along the line, I started to learn Scala. As I learned about different ways programming can be used for all sorts of applications my interest in programming grew. This still continues today when I see a tweet or a GitHub project showing some interesting technique.

You’ve programed in Logo, NXT Mindstorms, Ruby, Python, C and Java, but Scala is your favorite. Can you tell us why do you prefer Scala? What makes it special? Is there anything you liked in other programming languages?

Scala is a great programming language for lots of reasons. The most obvious feature is support for functional programming. It made me think about programming in a mathematical sense; for example, instead of thinking of a map as creating a new array by iterating and appending mapped elements I could think of it as passing each element through a transformation function. When I first started programming with Scala, the static typing was a big plus — once I figured out how to decipher compiler errors! Knowing what were the problems with my program before I ran it made coding faster and easier. On top of that, Scala provides type inference. The language I was programming in right before I moved to Scala was Python, and as Python is dynamically typed I was not used to specifying types for everything. With Scala, you can often get away from specifying types and let the compiler do that work for you. The awesome collections library helps too, letting me easily work with many data structures with a uniform API. As I continued to learn, I discovered a plethora of useful features. Implicits let you automatically convert one type to another, which is great when adding additional functionality to existing types. Type aliases (a personal favorite), allow providing alternative names for types and make code easier to understand.

What I found most fascinating about Scala is how it could carry me through all sorts of projects. When I wrote my first game in Scala, it took only a few lines of code thanks to the powerful collection library. Even with complicated algorithms involving dynamic programming, getOrElseUpdate let me write them just as easily as any other program. When I started working on bioinformatics, Scala let me provide clean types that express different biological structures with ease; once I had types for DNA and RNA I could use map, foreach, fold, and friends just as easily as on any collection. Scala.js provides icing on the cake. Being able to use the same language on desktop computers and the web allowed me to focus on what matters most in my projects instead of switching between languages for each platform. That’s just awesome!

While I don’t have a lot of programming experience with other programming languages, I appreciate what each language brings to the table. When writing up simple snippets of code dynamically typed languages like Python and Javascript allow you to pull together code that just works. One thing I would add is once you know one language well, it’s easy to pick up other languages. Although I have never learned Java formally, I could pick it up pretty easily for our high school robotics club.

One of the topics you touched in your talk at OSCON was tools. You’ve said that they helped you a lot to learn programming. I’m sure that among our readers there is a lot of people who’re just getting started with Scala. What tools and MOOCs would you recommend them?

When getting started with Scala, the REPL is going to be your best friend. It lets you quickly test out ideas you have and is great when you want to write a simple program without having to set up a project. If you want to start out with the basics or you are teaching your kids Scala, Kojo is a really simple IDE that’s great for learning Scala. It provides a turtle canvas with which you can write programs that draw pictures while exercising your Scala skills. There are two great MOOCs on Coursera for learning Scala: Functional Programming Principles in Scala and Principles of Reactive Programming. The first mostly uses only the core Scala language and the second introduces reactive programming.

Do you believe that in the future the interactive tools and MOOCs for learning programming can replace or significantly change the learning techniques? Or even maybe it’s already happening as we speak?

I think it’s happening right now! As a high schooler, I can really see the effects MOOCs are having on the way we learn. A few years ago to learn algorithms I would have had to join a local class or buy a book, neither of which are optimal. With MOOCs, I could learn from the best of the best from the comfort of my home with the benefit of discussion forums where my “classmates” (and sometimes instructors) can answer my questions! With MOOCs, now anyone around the world can learn about things that they are interested in. I am interested in bioinformatics, but without MOOCs I would have had to wait until college to learn about it. Now, I can learn from the best in bioinformatics even though I am just in high school. Where else can one learn about Scala from Prof. Martin Odersky, bioinformatics from Prof. Pavel Pevzner, and algorithms from Prof. Tim Roughgarden and Prof. Robert Sedgewick?

What tools do you use for writing code? What affects your choice? What tools do you use when programming to be more productive?

I use a variety of tools in different context. For Scala and Java development, I use IntelliJ IDEA. For our FRC robotics team, I use Eclipse since there is an Eclipse plugin already that handles automated deployment of code to the robot. For pretty much everything else (or when my battery is dying) I use Atom. I jump around different tools for coding, making choices based on what I need at the time. A few things I always look for are speediness (I don’t like staring at progress bars) and integration with other tools.

You started the TechTalks program that brings guest speakers to share their knowledge and enthusiasm with students at your school; and you also was one of the teachers at Silicon Valley Code Camp 2013. Can you tell us more about this experience?

In the 7th grade, I was part of the Leadership class in my school. As part of that class, I needed to plan and execute one new project. As I was interested in technology and wanted to share my interest, I took the idea of user groups, adjusted it to the school environment, and TechTalks was born! I invited Dave Briccetti who spoke about Kojo, followed by Krishna Vedati, the CEO of Tynker, who spoke about how kids can become entrepreneurs, and later Arun Gupta who spoke about how to make modifications to gameplay in Minecraft, a very popular game at our school. With each TechTalk popularity increased and I could see that the kids were really savoring all that was taught.

I believe that every kid has the right to be introduced to coding. It’s not just to get a good job but to change the way you think. Knowing programming makes you approach real life problems in a logical and systematic manner that separates what is necessary and what is not. It starts out in obvious places, like using better planning skills to decide how you do your homework. Then it starts getting a little crazy. I once caught myself writing these notes about DNA in Biology: rna = dna.map(T => U) — compact and precise. Then it continues in other areas too. I play the Sitar, an Indian stringed instrument. I can recognize compositions I play on the Sitar as a sequence of maps, flatMaps, and slidings on other patterns — weird but effective. That helps me grasp the mechanical part, I still have to work on the creative part. ;)

I gave my first Silicon Valley Code Camp talk as a presentation about the variety of awesome projects you can build by learning to code. I hoped to show why one should try to learn to code, and I think my Google Glass and Leap Motion demos did the trick. Just this October, I gave a workshop at Silicon Valley Code Camp 2014 in which I taught the basics of Scala. The great part about this presentation was that I used Li Haoyi’s Scala-JS-Fiddle (http://www.scala-js-fiddle.com/) which allowed the kids who attended to be able to follow along without having to worry about any installation. It’s really inspiring for me to see kids showing so much interest in learning to code and how their creative juices were working in all sorts of ways.

I also know that besides programming you are passionate about math and science. How does it intersect with programming?

I believe that programming is just an extension of Math and Science. Math and Science have had intersections with my coding many times, but there are three that stand out the most to me: Collidium, brainwave analysis, and bioinformatics. At my first Scala Days presentation in London in 2012, I presented a simple desktop physics game called Collidium. At the time, I did not know about physics engines, so I ended up creating my own primitive one. With this project, I needed to know what angle a ball was moving in when it hit an obstacle to calculate effects of the collision. It steered me towards the world of trigonometry way before my school would introduce it. With brainwave analysis, I learned how computers could be used to process brain activity in order to build a mind-controlled version of Snakey. And with bioinformatics, what I am currently working on, I learned about the variety of algorithms that can be used to process the vast amounts biological data that makes us what we are.

Most of the talks you gave at various conferences (including OSCON and Scala Days) were about game development. Do you think it’s important that programming was fun? Did you consider yourself as a video game developer in the future? Do you have any specific career plans?

Having fun when you program is really useful as a source of encouragement, one of the three pillars of learning to code that I presented at OSCON. I enjoy playing video games, so it was really fun to be able to make my own games that my friends and I could play.

I don’t really know what I’ll be when I grow up. When I was younger I had my mind set on either being a roboticist or a video game developer. As I learn more about programming, I am discovering new things that I can be when I grow up and I don’t know anymore what I want to be; there are some many options but I’m pretty sure it will involve computers!

Thank you Shadaj!

Shadaj is an active member of his school community as Student Council President. He loves spreading a love of technology, and started TechTalks—a program that brings guest speakers to share their knowledge and enthusiasm with students at his school. When not doing his school work or programming, he plays the sitar, and games, some of which he created.