How computers work (part 1)
A while back, one of my nephews asked me how computers work. During our recent sailing trip, I spent some time with him to answer that question. I will share the introduction I gave him over the next few posts.
Feel free to drop a comment if something needs elaborating. A later post will list technical references for further reading.
"How do computers work?" can be answered at many levels, just like "How does biological life work?". For life, you can explain that there is an ecosystem of plants and animals, the interaction of animals, the physical and behavioral attributes of individuals of a specie, the function of different organs in their body, the cellular structure of each organ, or the atomic structure of different types of cells.
For computers, there is a similar hierarchy of abstractions: ecosystem of computers (networks), individual computers formed of large components (screen, keyboard, proceesor, memory) and software, circuits forming processors and memory, and the atomic-size elements (transistors, wires) forming those circuits. At a high level, you plug the power, keyboard and screen. At a low level, electrons flow through circuits and light up the display.
I will mainly focus on the hardware part, starting from the bottom (transistor, see next post). We'll build up to a processor by assembling simple and small components into more advanced and larger components. I won't discuss the software part much (maybe later).
It is useful if you have been exposed to basics of software programming (mathematical primitives, conditionals, loops, variables, functions/modules), as the computer we will "build" will implement those instructions. I will also assume that you are familiar with logic (booleans, AND/OR/NOT operations) and binary representation of numbers (base-2/binary 110 is base-10/decimal 6; in binary 110 + 1010 = 10000 just like 6 + 10 = 16 in decimal).
Before laying the first brick, let me give an overview of what we are going to build. The processor is the central component of a computer. At every tick of the clock, it reads an instruction and executes it. In a sense, the processor is like a dull but diligent factory worker who follows a detailed recipe or script (1- "take a screw from shelf A", 2- "take a part from shelf B", 3- "attach the screw to the part", 4- "put the result in a bin", 5- "if no screws are left, call the supervisor", and 6- "start over at step 1").
The processor can execute different types of instructions, such as "read input number from memory A", "add two numbers", and "write output number into memory B". The processor normally follows the instructions in order, but it can be instructed to jump to a different instruction ("jump to step X", or "if number is zero, then jump to step Y, otherwise proceed to next instruction").
Recipes are called algorithms. You can solve complex problems with a long list of such simple instructions, just like you can manufacture a car with a worker following a long list of small steps.
Next time, we'll start our pyramid by looking at transistors. We'll then assemble transistors to make simple logical components (AND, OR, NOT), followed by slightly more advanced arithmetic components (ADD). After that we'll look at stateful components (used to store information) and build a simple processor and finally computer.
Getting videos out of iTunes U
I wanted to get a video out of iTunes U for viewing offline without iTunes or special apps.
The solution I found is to browse the iTunes U app in iOS and share a course by mail (see screenshot below). This sends out a link (like this one) which offers a web preview of the content. Luckily, the source of those preview pages also includes direct links to the media files.
Screenshot of sharing a course from iTunes U:
Screenshot of the email you receive:
Look at the source code to find the video link:
preview-album="Partnership for Urban Health Research - Media" preview-artist="Judea Pearl" preview-title="Theoretical Developments in Causal Inference" video-preview-url="https://itunesu.assets.itunes.com/apple-assets-us-std-000001/CobaltPublic6/v4/28/6b/19/286b19a3-2022-2477-ca6d-8e66edbc86c9/efa4eafb3b64ff58b40bf2aea0f12fb3825e5fc48d00e7545215357de42dcd42-3468512126.mov"
New blog platform
I came back from vacation with a few topics to blog about (in particular, I will start a series on the fundamentals of computing). Being an efficient procrastinator, I naturally decided this would involve moving away from MovableType first ;-)
What tool to use? I don't like set up or administering SQL instances. I appreciate flat files for content, static files for HTML output (easier to backup and migrate to new hosts) and the idea of managing my content in git/GitHub (versioning, access control, Markdown preview). Also, I want to keep continuity with my previous content. I looked at a few flat-file blogging platforms, but none quite fit the bill.
The solution I built yesterday is simple (every tool starts that way, doesn't it): read content in Markdown files, read some metadata about the entry in a YAML file, and run those through Liquid templates to generate the HTML and RSS output files. The editing of content and metadata can be done directly in GitHub. The publishing is done via SFTP.
The code (not counting HTML templates or CSS) stays short by leveraging libraries like MarkdownDeep, YamlDotNet, DotLiquid and System.Net.FtpClient. Dynamic site features such as commenting and searching are outsourced to Disqus and Google. I intend to refresh the design and stylesheets for the site, as they are dating, but that will come later.
The code for the tool and content for this blog are hosted on this GitHub repo.
It is structured as follows:
/content/ index.yml (blog info, list of entries) *.md (body for each blog entry) /templates/ index.liquid, entry.liquid, rss.liquid, archives.liquid /output/ *.html /src/BlogBuilder/ *.cs
Physics experiments to do at home
A few cheap experiments to do at home, some of which we tried with my brother and his children.
Magnet in copper tube
Uses a strong magnet and a copper tube.
Uses a glass and a long and thin chain.
Uses a laser pointer and some pencil leads.
Uses a strawberry, dish soap, salt, a strainer (or coffee filter), and rubbing alcohol (or vodka).
Experiments You Can Do At Home
Thoughts on Newton and Einstein
An old conversation came back to my mind a few days ago about whether Newton's theory of gravity and mechanics is valid or was falsified by Einstein's theory and related evidence. Through an analogy, I'll explore reasons why I see Newton's theory as falsified despite still being useful.