Monday, June 04, 2018

World Class Resources for Budding Coders

This one's a blast just for the goofy English :

http://www.comp.nus.edu.sg/~stevenha/myteaching/competitive_programming/cp1.pdf

And, recommended by Alexander Kulikov and friends :

http://www.cs.yale.edu/homes/aspnes/classes/223/notes.pdf

Pg. 90 of the above is a good one to take in after (or while) you do nand2tetris :) :

You usually don’t need to look at assembly language, but it can sometimes be enlightening to see what the compiler is doing with your code. One thing that I find interesting about this particular code (which is for the x86 architecture) is that most of the instructions are movl, the x86 instruction for copying a 32-bit quantity from one location to another: most of what this program is doing is copying data into the places expected by the library functions it is calling. Also noteworthy is that the beautiful compound statements like if and for that so eloquently express the intent of the programmer get turned into a pile of jump (jmp) and conditional jump (jl, je) instructions, the machine code versions of the often dangerous and confusing goto statement. This is because CPUs are dumb: they don’t know how to carry out an if branch or a loop, and all they can do instead is be told to replace the value of their program counter register with some new value instead of just incrementing it as they usually do.

5.3 Abstract data types

One of the hard parts about computer programming is that, in general, programs are bigger than brains. Unless you have an unusally capacious brain, it is unlikely that you will be able to understand even a modestly large program in its entirety. So in order to be able to write and debug large programs, it is important to be able to break it up into pieces, where each piece can be treated as a tool whose use and description is simpler (and therefor fits in your brain better) than its actual code. Then you can forget about what is happening inside that piece, and just treat it as an easily-understood black box from the outside. This process of wrapping functionality up in a box and forgetting about its internals is called abstraction, and it is the single most important concept in computer science.

5.3.2.2 When to build an abstract data type

The short answer: Whenever you can. A better answer: The best heuristic I know for deciding what ADTs to include in a program is to write down a description of how your program is going to work. For each noun or noun phrase in the description, either identify a built-in data type to implement it or design an abstract data type.

No comments: