Regularity

From Maze

(Difference between revisions)
Jump to: navigation, search
(→Iteration in 10 Print)
(→Iteration Permeating Computing)
Line 25:Line 25:
(tk add variant that rewrites 10 PRINT to manually manage the cursor position by poking specific grid locations using BASIC's built-in iteration structure.)
(tk add variant that rewrites 10 PRINT to manually manage the cursor position by poking specific grid locations using BASIC's built-in iteration structure.)
−
=Iteration Permeating Computing=
+
== Iteration Permeates Computing ==
−
==Iteration – transistors and processors==
+
 +
=== Transistors and processors ===
 +
If you zoom in far enough all a computer ever does is run one iterative loop after another, up to five hundred thousand times per second in the Commodore 64's MOS Technologies 6510 processor and billions of times per second in a modern chip. The iterations are not just restricted to processors though: almost every component in the computer, including memory, input/output controllers, and video adapters are all constantly iterating, no matter what code the programmer writes or the user runs. Digital logic is based on the idea that general-purpose instructions can be modeled using nothing more than ones and zeros, but the ones and zeros must themselves be modeled somehow before they can turn into digits, logic, or characters on a screen.
If you zoom in far enough all a computer ever does is run one iterative loop after another, up to five hundred thousand times per second in the Commodore 64's MOS Technologies 6510 processor and billions of times per second in a modern chip. The iterations are not just restricted to processors though: almost every component in the computer, including memory, input/output controllers, and video adapters are all constantly iterating, no matter what code the programmer writes or the user runs. Digital logic is based on the idea that general-purpose instructions can be modeled using nothing more than ones and zeros, but the ones and zeros must themselves be modeled somehow before they can turn into digits, logic, or characters on a screen.
−
===Computers do one thing well…===
+
 +
=== Computers do one thing well... ===
At a literally nanoscopic level, a computer is little more than a collection of switches. Lots of switches, really: a few hundred per square millimeter in the Commodore 64's day, and millions per square millimeter using today's most advanced lithographic techniques. (tk footnote Moore's Law?) But unlike a light switch, the transistors used as switches in digital devices are not operated by physically flipping a conductor to complete a circuit. Transistors are solid-state electronics made of semiconducting materials that, depending on an input signal, either allow or prevent the flow of current through a junction. The difference between no current and full current is thought of as the difference between a zero and a one, a false and a true, or an off and an on.
At a literally nanoscopic level, a computer is little more than a collection of switches. Lots of switches, really: a few hundred per square millimeter in the Commodore 64's day, and millions per square millimeter using today's most advanced lithographic techniques. (tk footnote Moore's Law?) But unlike a light switch, the transistors used as switches in digital devices are not operated by physically flipping a conductor to complete a circuit. Transistors are solid-state electronics made of semiconducting materials that, depending on an input signal, either allow or prevent the flow of current through a junction. The difference between no current and full current is thought of as the difference between a zero and a one, a false and a true, or an off and an on.
As they are built largely from transistors, computers are devices that do one thing very, very well: they can detect the difference between no current and some current. Despite the power represented by making millions of simple decisions per second, this principle of operation also presents a problem. With no physical components to move and create or break a circuit, a single transistor will not "remember" whether it should be allowing current to flow or not without a constant input signal. Without that bit of memory, a transistor can only ever allow a signal to pass through it; if it is to be useful in logic, it must somehow be made to capture the output of that signal and combine it with the signals coming from other transistors on the chip to perform complex operations.
As they are built largely from transistors, computers are devices that do one thing very, very well: they can detect the difference between no current and some current. Despite the power represented by making millions of simple decisions per second, this principle of operation also presents a problem. With no physical components to move and create or break a circuit, a single transistor will not "remember" whether it should be allowing current to flow or not without a constant input signal. Without that bit of memory, a transistor can only ever allow a signal to pass through it; if it is to be useful in logic, it must somehow be made to capture the output of that signal and combine it with the signals coming from other transistors on the chip to perform complex operations.
−
===Memory and CPUs===
+
=== Memory and CPUs ===
Depending on which is best for the application at hand, there are several ways to construct a circuit around a transistor that will allow it to behave as a useful logical switch. The most basic is to simply offload that responsibility to another part of the integrated circuit. This approach is often taken in parts of a microprocessor that are intended to carry out the actual work of computing, such as the arithmetic logic unit (ALU). An ALU is a series of transistors organized into logic gates – simple circuits that compare two input voltages and produce an output based on comparing them to see if they are the same or different. (tk footnote Boolean logic) The simple logic gates are ganged together to allow multiple inputs to undergo relatively complex operations and produce multiple outputs. Within the gates, though, the data is simply used and then lost, transformed into an output.
Depending on which is best for the application at hand, there are several ways to construct a circuit around a transistor that will allow it to behave as a useful logical switch. The most basic is to simply offload that responsibility to another part of the integrated circuit. This approach is often taken in parts of a microprocessor that are intended to carry out the actual work of computing, such as the arithmetic logic unit (ALU). An ALU is a series of transistors organized into logic gates – simple circuits that compare two input voltages and produce an output based on comparing them to see if they are the same or different. (tk footnote Boolean logic) The simple logic gates are ganged together to allow multiple inputs to undergo relatively complex operations and produce multiple outputs. Within the gates, though, the data is simply used and then lost, transformed into an output.
Line 46:Line 49:
==Iteration – code and structures==
==Iteration – code and structures==
==="Go To Statement Considered Harmful"===
==="Go To Statement Considered Harmful"===
−
 
−
(tk introduce the letter)
 
In the case of 10 Print the GOTO statement avoids most of Dijkstra's complaints. Putting a GOTO statement at the end of a one-line program that simply references itself does not leave much room for unexpected entrances and exits. However, expanding the program to take more than one line demonstrates the potential problems that GOTO introduces:
In the case of 10 Print the GOTO statement avoids most of Dijkstra's complaints. Putting a GOTO statement at the end of a one-line program that simply references itself does not leave much room for unexpected entrances and exits. However, expanding the program to take more than one line demonstrates the potential problems that GOTO introduces:
Line 79:Line 80:
(tk may be clearer with diagram?)
(tk may be clearer with diagram?)
−
===Structured programming===
+
=== Structured programming ===
Dijkstra's comments about GOTO were part of a movement toward programming languages that are designed for structured programming. Dijkstra himself would later take the idea further in his Notes on Structured Programming. Instead of viewing a program as line after line of text, structured programming practices involve seeing a program as an abstract set of tasks to be completed. Each of these tasks can be completed independent of one another; one section of the program can be written without worrying about how it is going to reference other sections because they share a common method of moving data between them. At a high level, programmers do not need to worry about how each function will work, they just know that it will and this knowledge allows them to plan their code strategically. Dijkstra compared this model to a string of pearls:
Dijkstra's comments about GOTO were part of a movement toward programming languages that are designed for structured programming. Dijkstra himself would later take the idea further in his Notes on Structured Programming. Instead of viewing a program as line after line of text, structured programming practices involve seeing a program as an abstract set of tasks to be completed. Each of these tasks can be completed independent of one another; one section of the program can be written without worrying about how it is going to reference other sections because they share a common method of moving data between them. At a high level, programmers do not need to worry about how each function will work, they just know that it will and this knowledge allows them to plan their code strategically. Dijkstra compared this model to a string of pearls:
Line 85:Line 86:
<blockquote>One of the metaphors in which I find myself thinking about the program structure envisaged regards the programs as a necklace, strung from individual pearls. We have described the program in terms of levels and each level contained "refinements" of entities that were assumed available in higher levels. […] I use the term "pearl" for [individual functions].</blockquote>
<blockquote>One of the metaphors in which I find myself thinking about the program structure envisaged regards the programs as a necklace, strung from individual pearls. We have described the program in terms of levels and each level contained "refinements" of entities that were assumed available in higher levels. […] I use the term "pearl" for [individual functions].</blockquote>
−
===OOP===
+
==== OOP ====
−
===Recursion===
+
==== Recursion ====
−
==Iteration – design and feedback==
+
=== Design and feedback ===
−
===Iterative design===
+
==== Iterative design ====
−
===Testing as development===
+
==== Testing as development ====
−
===Agility and reuse===
+
==== Agility and reuse ====
−
==Iteration – software and business==
+
=== Iteration – software and business= ==
−
===Mechanical reproduction===
+
==== Mechanical reproduction ====
−
===Version 1.0===
+
==== Version 1.0 ====
−
===Break===
+
==== Break ====
=Iteration as a Generalized Process=
=Iteration as a Generalized Process=

Revision as of 17:35, 30 March 2011

View this revision of Regularity.

Personal tools