20 December 2015

Computer science, This is CS50


This is CS50

Hello world. I took CS50

This is CS50 is Harvard University’s introduction to the intellectual enterprises of computer science and the art of programming. I took the course via EdX, where the course is know as CS50x. CS50x can be done at your own pace as per a schedule and you can apt for a verified certificate. I think this gives extra motivation and pressure to finish the course in time. The course is demanding, but definitely doable. 2015 was run from January 2015 to December 31, 2015. The course contents then change to 2016 for the next edition of CS50 and so on.

The course can be challenging, but has a lot of sources for learning, consisting of 12 weeks of lecture material  (2 main lectures for each week, session section for each week, shorts for each week as well as walkthroughs for each week). Each week also has a problem set that has to be submitted (well, 9 in total to be specific, and a final project). I started on June 27th  and finished on December 20th,. It took me awhile, doing other tasks at the same time. I felt majority of the learning happened through experimenting and testing, debugging, trying different ways on to run your program; in the end you’ll understand more how computers or programs process information and data. Problem sets cover areas such as Scratch (MIT), C language, PHP, MySQL, Javascript and AJAX, but also in between there are binary numbers, encryption techniques, ASCII, ciphers, questions, objects, data-structures, hexadecimals, pointers, array’s, anything computer science.

My background is more in visual communication, graphics, front-end development, publications and the like, but felt getting more into the art of programming is essential, thus taking the course. It does open more doors to new possibilities and a new way of looking at things from the computer science point of view. I did become more comfortable with the command line and other tools that do not really have nice graphical user interfaces. WYSIWYG is not that necessary anymore, or, now I can build one on my own.  This website is my final project, built with Ruby and Ruby on Rails.

CS50 also has a very social network in most of the social media channels where you can ask questions in case you get stuck, or just general talk on computer science. Most active seem to be the Facebook group, Stackoverflow and Reddit Channels.

I’m going to go through the problem sets and my experience with them.


Problem Set 0:  Scratch

The course starts with Week 0, and the first problem set is on Week 1, though titled as Problem Set 0. Why? In computer science, you’ll start with 0, instead of 1, this is CS50’s way to emphasize the need to start thinking from 0 and up early on. The problem set 0 was to create your own game, animation, art, etc. using MIT’s Scratch program. http://scratch.mit.edu/ Scratch gives an easy introduction, visually, how programming works, without needing to code anything, but the idea is to understand more the logic behind programming. Loops, if-statements, and the like. I had previous experience from using Scratch, so the problem set 0 was quite straightforward. I created an animation-style game, where the main character is called “WufWuf’ and you move him through different scenes to find his missing bons, thus the title: “Wuf Wuf’s Adventures: The Quest of the Missing Bone”.  Link to the game

Scratch Animation Game


Problem Set 1: C

(This is week 2)

Problem set 1 was about getting comfortable using the C-language and Linux. You’ll also install all the necessary appliance and programs in case you didn’t do that before. I felt installing Dropbox to backup all the psets (problem sets) was an excellent and necessary thing to do, even though not 100% required, but I feel this is necessary. You’ll begin with basic hello world programming in C using gedit, then go on further to create a Mario style pyramid and a mini-money-change program called “greedy”. I enjoyed the Mario part most, probably because it is more visual, it was really hard though, having no prior background in C language, but eventually after several tries it worked! Then I ventured on to the hacker edition of Mario to create the double sided pyramid. This was problem set 1.

Mario CS50

Mario Hacker Edition CS50


Problem Set 2:  Crypto

Problem set 2 continued with C language, though this with more focus on loops, functions and command-line arguments. The first task was to create a program that takes the user’s command-argument input, (First Name, Last Name), then outputs the initials of the input to the screen only. The next task was to create a program that prompted the user for a sentence, i.e. “Today is Monday” and then applied Caesar’s cipher encryption to the message by rotating each letter by x positions, wrapping from Z to A as needed. Let’s say I want to use x as 12 for the letter rotation on the sentence: “Today is a Sunny Day”, it will become:

Today is a Sunny Day
Fapmk ue m Egzzk Pmk

After Caesar there is another encryption challenge. This time, using Vigenere’s cipher. This time, instead of using a number as X, you’ll use letters of a keyword instead.

The CS50 appliance also has a check system (for the C programs, not PHP or MySQL) that you can see if your code passes the test.  This was problem set 2.


Problem Set 3: Breakout

In problem set 3 you’ll get some distribution code, this is also another pset with C with the focus on search, sort, shapes, objects, if-statements and more. This time more than just command-line, you’ll actually create a game that uses a graphical interface!  A paddle game, a single-player version of Pong, where the player would volley the ball into a wall that lost a brick whenever it was hit, originally created by Steve Jobs and Steve Wozniak in 1975. Problem set 3 is to implement this game in C with the distribution code, built atop the Stanford Portable Library (SPL). You are also free to design the shapes, colours and thickness of your game’s components, using C. There is a lot of work with initializing objects, what happens if something hits something, velocity, counters and more that you will need to implement, demanding, sure, but when you finish it, and it works, the feeling is just, awesome!

Breakout.c CS50


Problem Set 4: Forensics

Problem set 4 is in general about images (binary), Data-structures, hexadecimal, and pointers, you’ll also have questions about different formats and color support, i.e. what is lossless compression? You’ll need to use C to create a program, ‘whodunit?’ that reveals an original image underneath image distorted with red noise. Then go on to create a program that automatically resizes other images (based on command-line arguments) and then as a last task to create a recovery program that recovers deleted images from a CF-card. Interesting

Red Noise CS50


Problem Set 5: Mispellings

Implementing and designing your own data structure to work as a spell checker and dictionary, among them the script from Austin Powers: International Man of Mystery. You’ll need to implement check, load, size and unload and to make the program to find all the misspelled words, how long it took to execute, load, check and how big is the file size. You’ll also learn about tries, hash tables, nodes and inked lists.


Problem Set 6: Web Server

Objectives of becoming familiar with HTTP, and transition from C to web programming, although, this pset is still mainly about using C, but touches a very crucial part for websites to work, the web server and its functionalities. I.e. what to do about when not finding a file, what errors, what output to create,etc. You’ll need to implement validate request-line, extract queries from the request target, concatenate paths, ensure path is readable and more server functionality, not 100% from scratch, but the main functionality.

HTTP/1.1 200 OK

Connection: close

Content-Length: 127

X-Powered-By: PHP/5.5.9-1ubuntu4.4

Content-type: text/html


Problem Set 7:C$50 Finance

Problem set 7 dives into HTML, CSS, PHP and MySQL. Your goal is to create a web service where users can manage portfolios of stocks, log in, check real stocks’ actual prices and portfolios (based on Yahoo Finance), and buy and sell their stocks (though not actually buying and selling). These actions need to be linked with the MySQL database as well, and the transactions, buying and selling have to be recorded to the database, and shown to the user via transaction history (with a timestamp) and to show the updated balance on portfolio page after any transactions. You can customize your site using HTML and CSS. You’ll also get a chance to learn about MySQL and manage the data via phpMyAdmin.

CS50 Finance


Problem Set 8: Mashup

For the last pset (pset 8) you’ll be using Google Maps API as well as Google News API together, mashup of real-world API’s and libraries, utilizing HTML, CSS, Javascript, AJAX and JSON. Also getting exposure to objects and method and using scripts such as JQuery and typeahead.js library from Twitter. The idea is to allow the user to search for news based on location. Google maps works as a way to show a map, show the location graphically, and user can change their location, or search another location based on address or postal code in a search field, and a marker will appear on all places that have a postal code, when user clicks the marker, he/she will be prompted with a pop-up window showing recent news headlines from that specific location (postal code), provided by Google News, there might be no news from a specific place, but user can still get a notice “slow nows day” or the alike. You’ll then also need to add your personal touch to the mashup, I decided to go with some aesthetics changes. That was pset8, the last one of the psets!

Mashup CS50


Final Project & Conclusion

The final project specification is as follows:  The final project is your opportunity to take your newfound savvy with programming out for a spin and develop your very own piece of software. So long as your project draws upon this course’s lessons, the nature of your project is entirely up to you. You may implement your project in any language(s). You are welcome to utilize infrastructure other than the CS50 Appliance. All that we ask is that you build something of interest to you, that you solve an actual problem, that you impact your community, or that you change the world. Strive to create something that outlives this course.

I thought for some time what my final project should be about, then decided I want to learn more about Ruby and Ruby on Rails, then decided I was going to make a new portfolio site for myself using Ruby on Rails.  I think this way the final project will be of true value and I’d have the motivation to create the best possible outcome. This website is created in Ruby on Rails and it is my final project for This is CS50.  It took me awhile to catch up on Rails, but found there are a lot of material and sources out there to learn. In my opinion and among all the sources I used for learning Rails, this was the most valuable to me: https://www.railstutorial.org by Michael Hartl.

I then went on to implement this site, with it’s very own simple CMS created from scratch, I didn’t use gem(s) for a CMS, or scaffolding for the resources/controllers, as I think it doesn’t need that much functionality and I should know “everything” on how the site is build, works and how to extend it if needed, and it is a good learning opportunity. I can then also customize ithe site according to my needs, functions and the looks. After learning Ruby and Rails extensively for about 2 months and several apps later I built the final project in about month’s time. Constantly learning and discovering new Ruby and Rails things. Majority is just Rails, but there are also some Ruby blocks here and there. 


I feel I have become more confident in Rails and will continue to use it in the future as well. After doing the course, I can see that even though there are different languages, the general logic is pretty much the same, similar logic and syntax apply across the languages. I think the course is a great introduction to computer science and anything that evolves around computer science. I had a lot of struggles, I had times when I was going to quit and not do it, but I did continue and now when it is finished, I feel very happy that I didn’t quit midway even though it was hard, nothing was working, segment fault dump, errors, everything, joy of finishing beats all that struggle, and now to the next steps! Thank you CS50, it has been an interesting and educational experience I feel I cannot find anywhere else.

Info on the course This is CS50: https://cs50.harvard.edu

HarvardX x EdX This is CS50x: