Saturday, May 08, 2021

Scripting: How Do I Learn Something New?

 Learning is different from person-to-person. We all have our own methods and while often we can adopt new methods, there's no guarantee that what works for you will work for me, or what works for me will work for someone else.

What I'm going to try to explain is how I learn scripting languages and systems, including what I used to do, but need to get back to. I believe that age and stress can impact your ability to absorb new information and concepts so if you're having trouble soaking up or adapting, try calming exercises and practices before digging in. 

So, last year I took on a new role that gave me new opportunities to learn Powershell, a Microsoft/Windows-centric, scripting language that's particularly useful in DevOps roles. Now I have a saying that's mostly true, "Anything is possible in software," but this has constraints depending on the language you're trying to work with to get the job done. Often in your career you will need to adapt, for me this was reaching my limits and blowing past my comfort-zone with the batch language in the Windows Command Prompt and needing to build more advanced scripts to automate processes in my role as a Cloud Technical Analyst.

I have had, many years ago, experience with PHP, JavaScript (DHTML), Visual Basic, VBScript and ASP, but I had not kept up. It just wasn't part of my life so I let it slide.

Coming back to last year, I accepted that Powershell, among other languages, would be necessary so I started playing. Challenging myself to re-write my precious batch files (.bat/.cmd) into Powershell scripts.

What a journey!

I'm not a classically trained programmer. I took programming in high-school, then taught myself from there on in. Of course I started with BASIC/BASICA on an IBM PCjr but I quickly moved on to the BASIC Compiler (7.1) and Visual Basic for Windows as this was my realm. I learned what I needed by reading the manual, buying books like Peter Norton's pink shirt book, and many others, then applying the ideas and concepts to personal or work projects. This was before the World Wide Web existed so books, bulletin boards, browsing in libraries was my source of knowledge. I learned what I needed and adapted as necessary.

Adapting is key.

Today, books have become eBooks, the bulletin boards have become the Internet and the sites information is endless... most of the time. 

First, to learn how to code you need a drive to take an idea and pushing yourself to make it real. Whether it's building a website or writing an application for yourself on your PC, come up with a goal and stick to it. It doesn't even matter if it's great, because with software, while anything is possible, you are also, rarely, done. Often you will add features and functions, sometimes you'll rewrite the code better because you've learned how to do something better. Channel Bob Ross and enjoy the happy little accidents because every mistake or rabbit hole leads somewhere.

Chasing rabbit holes is fine, it's knowing when to come back to it later or leave it be forever.

Before I go too far, coding is logical, but it's primarily creative. If you're a creative person you will enjoy the reward of designing a software solution. You don't even need to wait for the paint to dry or finish the work to enjoy a success so relax and just think things through.

So, if you have trouble with logical thinking, coding may seem like a daunting task. Writing an application (app/script/utility) is all about the destination, so just like driving from Toronto to Vancouver, you need to plan out what you need to succeed in your journey. You'll need one or more vehicles, supplies (fuel for you and the transportation options), and you need to know what constraints you have on the journey to completing the trip (or project). The vehicle is your platform on which you want to build the project, the properties of the vehicle (seats, windows, doors, etc.) may be the features and functions of the vehicle, you'll need to know what mode of transport (planes, trains, automobiles), and you'll need to design the route to the destination, this might be considered your programming language choice.

What if there's a road closure? These are part of the journey and you will adapt because, it's only software.

What has this got to do with learning something new?

So, you have this journey, what do you do? You gather information and tools together to help you get where you want to go. Learning to code, or learning a new language even, is about finding information, growing your comprehension of it, then applying it. Rinse and repeat on that.

You can start with small projects, experiments and challenges, And sometimes these are hard to come up with or get behind because you look at them like Grade 11 math and can't see where they might apply in a real world. I want to help you with that by laying out a list of challenges and letting you come up with ideas on how to solve them. There may be more that one answer, but if the destination is reached, safely, you're okay. If there's a better route that's fine, sometimes the fastest route is not the best route.

Challenges

These are only examples, you may find your own cause to develop a scripted solution, a boring or repetitive task that a bit of code can effectively erase. It starts from a need. 

Challenge 1:

    This may seem an archaic task in this world but create a logging journal. This could be used to track your time or comments through the day. We all know that keeping track of how long we've done x or y tasks through our day is tricky, let alone by the end of the week or month. Create a script that writes out a timestamped log of activities to a file in the current directory that it is being executed from. 

Example:

2021-04-01 12:01:00 # 01:15 - researching how to explain how to write a script in Python
2021-04-01 13:43:00 # 00:20 - assisting user on how to restart windows, again.
2021-04-01 14:45:00 # 01:00 - lunch
2021-04-01 17:30:00 # --:-- - end of day

You can write this in any language. Pick a language you want to understand better. This is a simple script but you're going to find out how to write this by breaking down the the steps to deliver the output. It can be something entered from the command line, or through prompts within the script. You could build a GUI for it. You have many options. If you like a pretty interface consider using Electron and JavaScript. 

... I'll add more, soon.


There is no individual ownership when you are part of a team, it's the sum of the parts that makes you the RESILIENT team you need to be.