Saturday, January 23, 2021

Learning to Script

 

This morning I attended How I Learn New Scripting Languages, a webinar by Rob Sabourin hosted by the Test Tribe. In it, Rob laid out general principles and specific steps that he recommends for anyone new to scripting, or to a particular language.

His general points included:

  • Don't get tied to a particular language or platform; it'll get in your way at some point.
  • Don't sweat the syntax; you can always look it up.
  • Do learn how to learn; this will serve you well everywhere, not just in picking up a new language.

I don't think I'd argue with any of that but I'm less sure that my specific steps would be the same as his. For example, he recommends several foundational topics be reviewed before opening up a text editor. I wouldn't make that a precursor to starting. It's not that his ideas have no merit — they absolutely do, and to testing in general — just that they can be learned later, and tied to practical programming concepts.

As it happens, I'm learning Kotlin at the moment. My background in coding is that I did a little BASIC as a boy, a little Pascal at college, a little Modula-2 and Prolog at university, and Java, bash, and Perl predominantly at work. I've also tinkered with awk, Tcl, Python, Groovy, and others on odd occasions, usually when trying to debug or repurpose someone else's code. That might sound like a lot but, in all honesty, I have a limited repertoire of pretty basic skills.

Kotlin provides functional and object-oriented paradigms, both of which I'm familiar with more in concept than execution. I did join a lunch club working through the classic SICP in Scheme for a while but the rest of the group were (real) developers and I got quickly out of my depth on the functional side. I have also never used an IDE for any of my programming, so I'm taking the opportunity to become familiar with IntelliJ IDEA at the same time as Kotlin. 

I have approached this learning as I do with most learning: I've leapt in and cycled through different kinds of activities, looking to build on what I already know each time through. I don't worry if I don't get a concept first time, I'll move past it and try it again later. I'll visit the same material more than once because, once my personal context has changed, there's a chance I can see something new in it.

For the record, here's some of the things I did in those cycles:

  • Read and watched background material on Kotlin (e.g. How to Kotlin, Wikipedia, Joyful Kotlin). 
  • Followed along Youtube videos (e.g. Kotlin in Three Hours, Using TDD to Learn Kotlin) pausing the video to type and run whatever the presenter just did, and any variants that occurred to me.
  • Read and/or worked through various online exercises (e.g. Kotlin Examples, Kotlin Koans, Kotlin Hands-on).
  • Used background knowledge I have from elsewhere to find the Kotlin equivalent, for example "switch statement Kotlin" got me to when.
  • Explored the IDE to get some of the common shortcuts into my fingers so that compilation, or running tests, or commenting a block, or reformatting for syntax are all straight from a thought to an action and I don't lose whatever fragmentary flow I've managed to work up.
  • Taken the opportunity to explore the Kotlin doc and Stack Overflow entries when I've got some kind error, so that I build some intuition about what a particular compiler message is really telling me.

If I wasn't doing this alone, at home, I'd also be looking to pair with people who know what they're doing. This can be a major accelerator for learning although in my experience it pays back more handsomely if you can demonstrate that you're putting effort in yourself, and that you're taking notice of what you're being shown, either deliberately or in passing. 

Recently, having built up a thin foundation of knowledge, I've begun working through the 80-odd Kotlin programming puzzles on Exercism. I like these because the material is provided as a set of unit tests and stub functions. My task is to implement functions that pass the tests. Even better, once I've submitted my solution I get access to solutions from other students.

I've done 22 of the exercises so far and each time I've taken three other solutions at random to explore. Looking at other people's code is a major learning opportunity, particularly when using the IDE to show documentation for the built-in functions that someone else has used. I often need to search for examples of those functions online because I don't have enough depth yet to be able to understand quite what the doc is telling me.

Learning is not linear, in my experience. Testing is also not linear, and the skills from both areas overlap significantly and complement each other well.

No comments:

Post a Comment