Monday 2 December 2013

Onto the Finals!

I'm pleasantly surprised when I discovered that I pulled off another A+ on the second test, woo hoo!! I think this goes on to say the importance of studying something that you really enjoy --- not only would you enjoy it, but you would also do well in it. I have my fingers crossed that the exam won't be brutal and that everyone could have a nice holiday break.

Too bad I missed the part about how the open protocol created by the government was instrumental in the internet's survival and expansion, but was TCP/IP actually invented by the government? A little research says that yes, it was started by Cerf and Kahn when they were working under DARPA (Defense Advanced Projects Agency) in 1973, and got developed further by a joint effort between DARPA, Stanford University, and University College London. The protocol was adopted as the standard for military computing in 1982, and promoted by the Internet Advisory Board for commercial use in 1985. Hence the government was fundamental in the development and promotion of the open protocols and ultimately in laying the foundation of modern internet. I don't know how I missed it but it's definitely an important bit of knowledge to know.

Moving onto this week, the material covered in class was the concept of Property. It felt a bit abstract and I'm not sure whether I understood everything Danny was trying to convey. Nevertheless, I will read the posted notes and ask Danny should anything remain unclear.

Lastly, as we head into the finals, this would be my last blog post for the SLOG. I had a great time writing it, and I hope my dear readers would have just as much fun reading it! See you all next year!


Me, before the exam.

Sunday 1 December 2013

Internet Privacy

To share or not to share, that is the question. With internet having become an inseparable part of our lives, so has a dilemma: our desire to share some information is as much as our desire to keep others a secret. So, how do we maintain the boundary between things such as our email account password which we'd like to keep a secret of, our personal lives which we'd only like to share with families and friends, and a beautiful painting which we are eager to share with the rest of the world?

Recently NSA caused quite a stir when it was revealed that it had been using supercomputers to crack internet encryption for years, and with the implication of possible infringement on citizens' right to privacy. From my perspective though, I don't consider it to be much of a big deal. The mission of NSA is to safeguard the lives of average good citizens, and in order to discover any potential threat such as a terrorist attack, extraordinary measures such as access to personal communications will be needed. Even though in the process it will undoubtedly breach the privacy of many, its efforts will eventually save countless lives, and therefore making privacy a small price worth paying for. I personally do not mind when my personal information is being used, along with everyone else', by the government for the collective benefit of the society such as in policy making and national security. I can sleep well knowing that those information will not be leaked to commercial entities, and that they'll not be used against me in anyway as long as I remain a law abiding citizen. Dan Missener mentioned in the CBC radio program "Spark", that a policy change requiring transparency over what the NSA does would help with the privacy issue at hands, but he also pondered that such transparency could be counterproductive since it's essentially equivalent to tipping off all the bad guys about how the NSA is going after them. This is certainly true, and I think it would be for the best that the NSA keeps doing what they are doing now, and just make sure the information collected will be used for appropriate purposes only.

However, the collection of personal information by commercial entities without our consent is a totally different matter. I recently noticed that the ads on Youtube began to reflect what I had searched on eBay a few days earlier, and it almost certainly indicates that something is tracking my browsing and searching history and transmitting them to Youtube. This is certainly creepy. It's almost as if someone is stalking you, watching your every move, with god-knows-what going on in his head. Even worse, as we've learned in lectures, they could be distributing these information to other organizations without out knowledge, and selling our private information for their financial gains. This is especially startling considering how our individual identities could be revealed with 87% accuracy, by simply knowing our gender, date of birth, and postal code. I'm completely against such activity in contrast to government surveillance since the possession and distribution of our personal information by commercial entities without our concern could pose many risks: complete strangers could know where we live and what our living habits are, insurance companies and potential employers could know about our health conditions and backgrounds and refuse to provide us with services/jobs, etc. So what could we do about it? Dan Missener said we could encrypt information using widely available encryption software; Danny mentioned that we could regularly update our OS and software to close loopholes, disable cookies to prevent tracking, be careful with whom we share information, and watch out where we click when browsing webpages. The most important part of all however, as both of them have mentioned in unison, is to speak up. We should voice our intolerance of secret acquisition and exchange of our personal information by commercial organizations. Hopefully one day proper policies could be in place to prevent such unbridled behaviors.


Yes, they are watching us, but privacy is a small price to pay for the chance to save hundreds of lives (and possibly those of our own).

Tuesday 26 November 2013

Assignment 2

Similar to assignment 1, when first opening "fx.rkt" and "fractal.rkt" I shamefully blanked out again. Even though I already had an idea from the in-class demonstrations of what the codes do, I still had trouble understanding the codes upon first glance. However, drawing upon experiences from assignment 1, I started reading the function contracts and check-expects. Man, weren't they ever so helpful. The contract gave an overall idea of what the function takes in and what the function churns out, while the check-expects essentially served as examples of the aforementioned inputs and outputs, making the understanding of functions so much easier. In addition, not only did the check-expects promote the understanding of the function, they also served as step-by-step checks as I worked my way through the code, making sure that everything I wrote produced the desired output. Working on the code bit by bit, making sure one part works before proceeding to the next, certainly had its charms. It made bug-hunting so much easier as you know the previous parts you have done definitely work, and that you only need to focus your attention on the newly added stuff. Following this strategy I was able to complete both codes in a matter of few hours, and it was such a huge improvement compared to the days I had to spend on assignment 1 to hunt for bugs.

One aspect of "fx.rkt" and "fractal.rkt" that I really liked was the added capability to respond to user input. This made the program so much more interesting when compared to the completely autonomous simulation we did previously. Pressing a key and seeing the program changes accordingly provided instant gratification and kept me occupied for hours after completing the assignment. I was especially fascinated by the use of "token", which is essentially a structure containing various parameters that take on different values in response to user key strokes. This token would then be fed into another function that specializes in producing certain effects in response to the parameters provided, and these effects were finally drawn onto the screen under the "big-bang" simulation. In some sense, the token was functioning as input for each function, which in turn served like one of those old computers before multitasking were implemented. This is something I'll be sure to use later on if I ever find myself in need of writing programs.

The most difficult part about the assignment, however, was the writing of a recursive function that produced patterns of different depth and size depending on the parameters provided. I had to start from the smallest unit and work my way up, basically figuring out how to draw the pattern when given the smallest input possible first, then figuring out how to draw the second largest pattern from the smallest by calling the function itself, and finally testing out to see if the function works for larger inputs. I had to practice writing simpler recursive functions in a separate program first, before moving onto more difficult ones, and finally integrating the desired function into the desired program. Things worked out very well using this approach in the end.

Demonstrations of the end products:


Fractal: A program that produces patterns of different size and depth depending on user input.


Fx: A program that changes the chameleon into user's desired color.

Sunday 24 November 2013

Computer Architecture

Things have been getting really interesting in class.

I've had an intense interest in computers since I was really small. I still remember how thrilled I was when I first encountered those fantastic DOS games and later the Windows 98 ones which kept me engaged for weeks and months. Those fondness for games soon spread into the domains of computer hardware as development of games necessitated increasingly faster CPUs and larger RAMs. Even now that I no longer have much time to play games I still find myself needing to deal with the nitty-gritty of computers on a daily basis, such as trying to figure out why the heck my internet is down again. However, after years of dealing with computers I was still in the dark with regards to the basic mechanisms by which computer works. Sure, many people of my age nowadays probably have a sound knowledge of what kind of gears to get for their latest gaming machine, which type of CPU goes with which motherboard and which graphics card, but how does computer actually work at the fundamental level? How do hardware run on a binary number system and how does such a simple system transform into the awesome graphics and mechanics of Skyrim or COD? All my knowledge about computers seemed to have been built in the air and that really bothered me.

This is no longer the case! The knowledge about hardware architectures, OS, and network covered in class has really rooted almost everything I've learned about computers in the past years, and that's such a wonderful feeling. We learned that digital computers utilize two states, in this case, ON and OFF states of a tiny capacitor to represent "1" and "0". Strings of these "1"s and "0"s can then be converted into complicated numbers using IEEE floating point scheme; into all kinds of characters using Unicode; into images using the RGBa scheme, and finally into sounds with LPCM. Moreover, we learned about the basic method in which CPU works: the Program Counter of the Control Unit keeps track of the steps of the program, the Instruction Register decodes instructions of the program, while other Registers store temporary information and the Arithmetic Unit carries out the hardwired procedures of arithmetic and logical operations. We also learned about how Bus is a limiting factor for the overall computing speed of a computer (hence why it's a complete waste of money to get a top-notch CPU but only equip it with a cheap motherboard). The lecture also cleared my doubt with regard to how computers store information: magnetic dipoles on concentric tracts of a platter in hard drives, pits on spiral tracts of a compact disc, electron chambers of a flash drive. It also satisfied my curiosity about OS: what actually is a kernel? Well, it's simply a shell that layers between users and hardware, taking care of all the basic level hardware operations needed for running a high level command from the user. It also really surprised me when Danny mentioned how Mac OS actually developed from Linux, and that Linux/Unix are not only running on desktops, but also mainframes. Oh, don't even get me started on the network typologies and communication protocols. How my home Ethernet works have bothered me for years, and now I finally have an idea of what IP addresses, gateways, TCP/IP mean when fixing my crappy internet. Hooray!

After more than a decade of playing this game, I finally have a faint idea of how it's working now... sweet :)

Wednesday 30 October 2013

Assignment 1 and Recursive Functions (Part 2)

I have finally found the root of the error for assignment 1!! Following professor Heap's suggestion I removed all modifications that I made to the original code (at least I thought I did) and started making changes to the code one bit at a time testing those changes out along every step. Soon I noticed that even the base code without any changes yielded the error. This led me to compare the base code that I had to the one posted online, and the bug was finally caught: it was a tiny line "(require racket/list)" that I added earlier to test out some commands but forgot to remove after the fact. It loads an additional module that provides additional functionality for manipulating list, but somehow it interferes with the base code and culminates in an error. The lesson learned? Always clean up after you mess around!

A small demonstration of the completed code that simulates an epidemic:


Also the exercise on recursion we did in lecture today was super helpful. It seems that the best way to predict the result of a recursive function is to work out the smallest unit of output possible, then work your way up through increasingly larger inputs, using what you already know about the output of the previous input, and eventually arriving at the output for your desired input. The previously elusive structures of recursive functions now finally make sense! I think this really shows how tracing codes is instrumental in the understanding of a particular programming language.


P.S. I got an A+ for the term test!! I'm so indulging myself with a few hours of gaming tonight ;)

Saturday 26 October 2013

Assignment 1 and Recursive Functions (Part 1)

Alright, let me just say that the moment I opened sneeze.rkt, I totally blanked out as none of the codes seemed to make any sense to me. However, the function contracts and check-expects have been incredibly helpful since they together give a very good indication of what the function does, what is the input, what is expected, etc. I'm going to follow this practice from now on and I think everyone should get into the habit of doing it as well, as they make reading the code much easier when you come back to it after a while.

The assignment overall wasn't hard. Professor Heap basically has done all the hard parts and we only needed to fill in some holes. Unfortunately when running the program some error appeared and seemed to stem from the original code provided to us. Debugging did not work it's magic, so I'm turning to Professor Heap for help. We'll see what the problem is.



On last thought, one of the things that really amazed me from the 2 weeks of lectures was the concept of recursion: basically a function that calls itself, creating a loop. It seemed such a simple idea and yet is so elegant and powerful. Examples shown in lecture had so few lines of codes yet could achieve such complicated tasks as predicting the folding patterns of a strip of paper after, say, 100 folds.

Friday 25 October 2013

First Blogger Post!

Just finished WikiII and started on assignment 1. Off to bed!

Feeling sleepy....zzzzzz....

This blog will record my journey through my first computer science course at the University of Toronto. The programming language referred to in this blog is Dr.Racket.