Monday 8 July 2019

Thoughts on Learning Computer Science Online

Flashback to the moment before I started applying for university placements through UCAS, about four years ago, I once voiced out my intentions of pursuing a Computer Science (CS) degree. As you'd expect, my proposal to my parents, specifically to my father, didn't work out well, as I ended up with a bachelor's degree in Economics from a renowned university in the UK for that department, University of Warwick.

When I started my degree, each student in our course had to choose one or two optional modules which can be from amongst the options in Economics or from other departments such as the Business School, Language, or Computer Science. I ended up choosing Arabic as I had the goal of improving my fluency in that language, especially in Speaking. Other than that, at that time, Economics wasn't really a subject I'm very passionate about. Even when I was doing the IB Diploma Programme, I wasn't very good at the subject. I even had a moment when I cried in front of my teacher because I was frustrated with my 'weak' understanding and performance in the subject. I was rather afraid that I'd do badly for my Economics core modules that I needed something I'm confident I can score well in to pull up my grades if needed. Until the end of my degree, I let go of my wishes to learn CS until...

I realised that I still have some money left in my UK bank account. Even though I have been living in Malaysia for months, I still have access to my UK Debit Card. I took this opportunity to pay for an online course, something that I can do while I'm job-hunting, something that may enhance my skill sets for the job (though I'm doubting to what extent this is useful). I paid in GBP, so it didn't feel like I was paying much, though if I convert it to MYR, then I'd be bawling my eyes out looking at it.

The course that I'm referring to is Harvard's CS50, Introduction to Computer Science. The online platform I'm using for learning is edX. I've known this website for years, even before I started my degree, when an IB friend of mine introduced it to me. I did enroll in some courses in Literature, Mathematics, Project Management and Health Economics before, but I didn't stick around too long in these course because, over time, I lost the motivation to continue. Furthermore, some courses like the one I took in Literature and Health Economics involved posting opinions on forums and commenting on coursemates' posts, which I'm not really keen on doing, especially, when you're late in joining the course, and you just don't have a fresh idea of your own after reading other people's ideas.

But this course is different. I didn't have to think about my own opinions. I only had to do homework. The homework is basically problem sets, each with different tasks, designed for the learner to apply ideas and functions taught during lectures. I'm not saying that this course doesn't encourage people to think critically, it does, believe me, but in a different way. Not those open-ended discussions on 'why the author used this word to express this and this', or those theoretical discussions on 'whether you think the healthcare insurance system is functioning well or not'. This course encourages me to do something, and I really enjoy it even though it makes me wanna cry at times. You'll see why as you read more.

On the first lecture, the lecturer introduced the main framework of CS. It is mainly focused on algorithms. Put in a simple way, algorithms are defined as the steps you'd take to solve a problem or the steps you'd execute to do something. For example, how do you make a peanut butter and jelly sandwich? What ingredients do you need for it? What instructions should you tell someone if you want them to make a PB&J sandwich? What are the logical orders that the steps should be arranged in to make the sandwich without messing up?

On the first lecture, too, we were assigned to make a programme using MIT's SCRATCH. These programmes should comply with specifications outlined in the problem set, for example, it must have a variable and a loop. Some people made games out of the programme. Mine was very simple (probably too simple) but still fulfilled all the necessary criteria. For the following ones, we use C. Now you must be curious as to how I was graded, right? Simple, we just followed the steps written in the course website (find instructions specifically on that problem set you're working on) to submit our work for grading. The system will then check whether your work complies with the specifications given. It gives green-coloured feedback if you fulfill a criterion, yellow feedback if there are some issues, and a red one if your programme is not working as how it should. As of this point, I've had many instances when I got a lot of red feedbacks. It really makes me sad to know that something is wrong with my codes, but I've also been ensuring that I get full green feedbacks before I move on to the next problem sets.

All the submissions I've done as of now
Up to date, I've done 5 problem sets. Some problem sets only have one assignment, while the rest have at least two different assignments to work on. Accumulating all the work I've done and all the files I've uploaded for submission, it looks like I've done a lot, but I haven't even crossed the half-way line yet. Looks like my CS50 journey is still a long way to go. Still means that I'm going to be having more moments of talking to myself whenever my programme is buggy, drawing graphical representations of my programme until I have a solid idea on the steps I need the computer to do for it to work properly, and more reading forums on StackExchange.

Normally, when I want to start on a problem set, I'd watch the lecture first, followed by the 'Shorts'. The Shorts are actually additional videos that explain ideas and functions in a more deeper approach. They also introduce some advanced syntaxes that may be helpful to solve the problem sets. However, for me, I sometimes think that some materials in Shorts are suitable for those who are more comfortable in learning more complex programming styles. For me, I'd rather stick to the easier syntaxes and functions, as long as I understand how they work and it gets my programme running. But most of the time, I don't know which Shorts would be useful for me, until I literally do the problem sets, so I'd end up watching everything anyways.

(From an economics perspective, CS does have that cost-minimisation criterion when constructing an algorithm i.e. make a programme that minimises running time/time needed to execute a programme, but because I'm a layman programmer, I don't really put much focus on this aspect. I'm entirely happy with a functioning programme even if it's not the fastest one around)

To work on the problem sets, the course provides walkthroughs for each assignment. The instructor in charge will offer a sample of pseudocodes. They are lines of instructions or word-formatted codes that should help the students develop their own codes to run the programme. Remember that PB&J sandwich situation earlier? Well, an example of pseudocode for making the sandwich would be:
  1. Open the bread's wrapper and the PB&J jar lid.
  2. Using a butter knife or a spreader, for each slice of bread:
    1. Scoop out some PB&J and place it on the bread
    2. Spread the PB&J evenly so that it covers the bread's surface
  3. Take two slices of bread that are already spread with the condiments and stack them together. Repeat until we used all our desired amount of bread.
  4. Cut the stack into half, whichever way you like.
(This is assuming that your PB&J spread is a literal PB&J spread, and not the one where you bought all the elements of PB&J separately)

Understanding the steps is one thing. At least it helps you to have some ideas on what you are working on. But this is obviously not enough. Even with pseudocodes, I sometimes can't imagine what I am telling the computer to do, so taking on the advice from one of the CS50 staff members, I'd normally write down and sketch the process on a piece of paper. For example, when I was working on the problem set on MUSIC, I had to learn the musical notes of the piano and complete a programme that plays a music sheet. I had to sketch out the piano tiles to decide whether I should be moving up a key or down if I wanted a certain note to be played. Another example was when I was doing the recent problem set on SPELLCHECKER. I wanted to load the dictionary using a specific data structure (a trie), and so I had to draw how a trie works in order to fully understand what possible questions I should let the computer ask at each node of the trie.

Notes on MUSIC Problem Set

Notes on SPELLCHECKER Problem Set
There would always be a time when I thought that my codes were perfect, but when I execute the programme, it won't just work. That was frustrating and made my head blank. Heavy sighs accompany my blank head and sometimes, I'd lie on the floor, thinking "What went wrong?". Fortunately, the site that we use for programming (developed by the instructors) are user-friendly, so it has user-friendly functions that could help layman programmers like me find where my codes went wrong by just typing a few words.

Example of the codes I've written (my codes are normally long because I write lots and lots of notes in it)
Some of the concepts that I worked on were quite challenging for me. In particular, I found the topics on Memory Spaces and Strings a little hard to grasp. I'd always have to read up more on it from online lecture notes or watch videos by other authors. When doing the problem sets, I'd have difficulties in understanding what is required of me. I'd have to look at examples first, to get an idea of what I needed to do. I feel like I cheated by doing this (hehehe~) but is it considered cheating if I still face problems even after looking at examples? I am pretty sure I did the same thing for the Econometrics group assignments I did during my second year of uni.

Will I continue until I finish this course? Yup, bring it on, CS50!!!