Send
Close Add comments:
(status displays here)
Got it! This site "robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website. Note: This appears on each machine/browser from which this site is accessed.
Some ways to think about programming a computer without thinking like a computer
1. Some ways to think about programming a computer without thinking like a computer
Some ways to think about programming a computer without thinking like a computer
There were too many ways to include all of them.
Operational: How it works (control issues)
Functional: What it does (logic issues)
Algebra: transform and refactor without thinking
Abstraction: similarities and differences
Code-driven or code-flow to data-driven or data-flow
2. Code and data
Bad programmers worry about the code. Good programmers worry about data structures and their relationships. Linus Torvalds (Finnish-American software engineer who created what is called Linux)
Do not think in Java, Python, etc. Think about data, data flow and the problem being solved.
3. ASCUE publications
ASCUE years and papers |
|
|
|
1994 [2] |
1995 [1] |
1996 [2] |
|
1998 [2] |
1999 [2] |
2000 [2] |
2001 [2] |
2002 [3] |
|
2004 [2] |
2005 [2] |
2006 [2] |
2007 [3] |
|
|
2010 [2] |
2011 [2] |
2012 [2] |
2013 [2] |
2014 [2] |
2015 [2] |
|
2017 [1] |
|
|
|
2021 [2] |
2022 [2] |
|
|
|
Years attended: 21. Presentations: 42. |
4. Teaching
[chairs, computer science vs. business]
5. Translation
Automatic translation still has certain issues.
6. Definitions
The purpose of a computer is to perform computations. A computer is a calculator that can push it's own buttons.
A programming language is a notation for describing a computation.
People need to think about problems.
Computers need to perform computations.
Can people think like a computer? Can computers "
think"?
7. Thinking
The question of whether computers can think is like the question of whether submarines can swim. Edsger Dijkstra (computer scientist)
8. Abstract
There are many ways to think about programming a computer. Unfortunately, the beginning programming course tends to overemphasize operational semantics such as thinking like a computer, thinking in a particular language, etc., with an over-emphasis on traditional mathematical expertise. No matter how smart the person, there is a limit to what a human can do when programming is based primarily on operational semantics. Other ways of thinking about programming and the programming process will be presented that are not based on thinking like a computer and which allow one to more easily create larger and more complicated software systems. Ways to incorporate these ideas into the beginning programming course will be covered (as done by the author). The (now retired) author, with a PhD in computer science in the area of applied programming language theory, has spent many years teaching in academia, doing software research and development in industry, and, in the process, writing about a thousand pages of code each year for useful programs, small and large, in many different programming languages.
9. Thinking
One wants to abstract to think about the problem being solved and not about the machine details of how it is being done.
Thinking like a machine is implementation-oriented.
Thinking like a human is solution-oriented.
To some, computer science is the same as coding.
Is computer science about computers?
10. Astronomy and telescopes
Computer science is no more about computers than astronomy is about telescopes. Edsger Dijkstra (computer scientist)
A similar comparison could be made about music being about musical instruments.
11. Big picture
Can you provide a reasonable definition of each of the following?
Computer science
Software engineering
Business
Education
Can you provide a reasonable
objective function (goal) for each of the above? [perceptions]
Does the definition have a connection to the objective function.
12. Computer science
Computer science is the search for
finite representations of (potentially)
infinite objects.
More finite time: computation runs faster
More finite space: computation takes less space
Computer science is mostly at the logic level of truth involving symbol manipulation.
Software engineering (and data science and business) is mostly at the reality level of truth.
13. Finite representations of infinite objects
1. How many dots are red?
2. Ratio of integers as counts
3. Infinite rational approximation
4. Finite rational approximation
5. Finite representation
Computer/Information science can be defined as the search for finite representations of (potentially) infinite objects.
Is this possible? Does it make sense?
14. Simplified definition
Simplified definition:
The goal of "computer science" is to order events and objects in space and time according to some efficiency constraints.
More simplified definition: Can you bag groceries?
This is a description as a constraint logic problem.
15. Software engineering
The goal of
software engineering is to develop software on-time, on-budget and that meets the needs of the customer.
fast (development time)
cheap (overall cost)
good (customer needs)
You can only get, at most, two of the three. You may get less.
The more math or computer science oriented a person is, the more difficult it is to make software engineering and business trade-offs. [CS SE vs. IS SAD]
16. Amazon
The Amazon slogan about "
pick two" between "
low prices" and "
fast delivery", reminds one of the software engineering definition and trade-offs. Who at Amazon came up with this idea?
17. Business
What is the purpose of
business?
The goal of business is to provide value to the customer - whoever those customers are. The customer is willing to contribute for that value.
Applies to business for profit and to non-profit, political,
educational organizations, etc.
BPR = Business Process Reengineering defined business, for the first time, in the 1990's. "
Do more with less".
18. BPR
Business process reengineering is the fundamental rethinking and radical redesign of business processes to achieve dramatic improvements in critical, contemporary measures of performance, such as cost, quality, service, and speed. Hammer, M., & Champy, J. (1993).
Reengineering the corporation. New York: HarperBusiness., p. 32.
Interestingly, Michael Hammer had a Ph.D. in computer science and applied
OOP (Object Oriented Programming) ideas to business processes. James Champy helped fill in the human-management perspective.
19. Education
What is a reasonable definition of the goal of the educational system? Assume college level.
It is a business. The goal of business is to provide value to the customer.
Is there only one customer - the student? For those who get confused by the word "customer" the word "stakeholder" is used.
[customer segmentation, supply and demand, quality]
20. Theory and practice
In computer science, software engineering and business, one has to often deal with trade-offs between theory and practice.
In theory, there is no difference between theory and practice. But, in practice, there is. Jan L. A. van de Snepscheut.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time. Linus Torvalds.
21. Business-technical trade-offs
An important trade-off between theory and practice in business and software engineering is called a business-technical trade-off.
Technical considerations dictate one solution.
Business considerations dictate a different solution.
This must be recognized and a trade-off determined. This needs to be presented to a manager for an informed decision.
22. Issues
Two types of issues arise in business-technical trade-offs.
IT (Information Technology) , software engineers, etc., making inappropriate business decisions.
Managers making inappropriate technical decisions.
23. Vocational training
I fear - as far as I can tell - that most undergraduate degrees in computer science these days are basically Java vocational training. Alan Kay (American computer scientist)
That is, many computer science programs are coding camps but often without teachers who really understand coding and sometimes without teachers who understand computer science.
24. Program semantics
In thinking about problem solving and programming, semantics and meaning are important.
Semantics and meaning:
functional - Church lambda calculus (LISP)
operational - Turing machine (C)
The Church-Turing hypothesis/thesis is that these ways of thinking can compute the same functions.
Each way may not be as beneficial as the way for a human to think about computing.
25. Assignment statement and swaps
26. Assignment statement and swaps
1. Assignment statement
2. Evaluate expression to a value
3. Replace variable with value
The
assignment statement, with the
destructive update as a
side-effect of
execution, causes many problems in programming.
27. Assignment statement
v = e;
Command execution of an assignment statement is a two step process.
1. Evaluate the expression e on the RHS (Right Hand Side) to a value.
2. Replace the previous value of variable v on the LHS (Left Hand Side) with the new value.
Whatever value was in variable
v before is lost (forever).
28. Step 1
1. Evaluate the expression e on the RHS to a value.
29. Step 2
2. Replace the previous value of variable v on the LHS with the new value.
Whatever value was in variable
v before is lost (forever).
30. Swapping values
Will the following code fragment correctly swap the values that are in integer variables
x and
y? Why or why not?
x = y;
y = x;
Explain your reasoning.
31. Explanation
Did you think like a machine to reason about your answer?
x = y;
y = x;
Thinking like a machine is thinking operationally.
How would you explain your reasoning to a student learning programming?
32. Testing
How could you test your program to make sure it is correct?
x = y;
y = x;
Would a flow chart help?
It is only
two assignment statements. How hard could that be?
33. Testing
Fallacy:
One can test a program to insure it is correct.
Let us adapt Dijkstra's argument from 1972 to this problem.
For two
64 bit integers, there are
2128 possible ways to do the swap code.
There are only about
280 microseconds in
16 billion years.
So it would take about
250,000,000,000,000(about
250 trillion) computers about
16 billion years to go through all the ways of swapping two
64 bit values.
Testing (brute-force) only helps find errors! It does not show that program code is correct.
34. Computer bugs
As I have now said many times and written in many places: program testing can be quite effective for showing the presence of bugs, but is hopelessly inadequate for showing their absence. Edsger Dijkstra (computer scientist)
Dijkstra, E. (1976).
A discipline of programming. Englewood Cliffs, NJ: Prentice-Hall., 20.
35. Quantum computing in brief
Quantum computing:
much faster than conventional computers
best for problems that allow probabilistic solutions
cannot solve all problems - despite the hype
[exponential speedup not clearly defined, like entanglement]qc-11
36. Quantum computing analogies
Quantum computing analogies: pick the best way
walk on foot: pencil and paper
drive by car : conventional computer (go most anywhere)
fly by jet : quantum computers (does not go anywhere, sometimes impractical)
no way to get to Mars, nearest star, etc.
37. Correctness
Let us show/use
program verification techniques to determine correctness.
The precondition and postcondition are as follows.
// { pre: (x = a) and (y = b) }
... code to swap values ...
// { post: (x = b) and (y = a) }
38. Apply the rules
Apply the
axiomatic semantics proof rule by working backwards in a top-down backward-chaining manner.
// { pre: 5: (x = a) and (y = b) }
// Meet in the middle (are there contradictions at this point?)
//{ 4: y = b = a = x }
// { 3: (x = a) and (y = b) and (y = a) }
// { 2: (y = b) and (y = a) }
x = y;
// { 1: (x = b) and (x = a) }
y = x;
// { post: 0: (x = b) and (y = a) }
Algebra is critical to proving program fragments correct. Is knowing algebra important to learning programming?
39. Work backwards
Many students have trouble working backwards, using algebra, and realizing when the proof is done.
1. Substitute
2. Simplify
Stair analogy:
Top-down: work backward from top step (last statement): 5 if 4 if 3 if 2 if 1
Bottom-up: work forward from bottom step (first statement): 1 then 2 then 3 then 4 then 5
40. When is it done?
Many students tend to be very used to thinking like a machine and not algebraically using symbol manipulation.
They may spin their wheels confused. It is like climbing the Penrose steps.
Aside: When is the program (or software) done? Think laser eye surgery.
41. Penrose steps: how it is done
1. Penrose steps 1
2. Penrose steps 2
3. Penrose steps 3
4. Penrose steps 4
5. Penrose steps 5
6. Penrose steps 6
The Penrose never-ending steps illusion, also called the stairs illusion, cannot exist in reality as depicted.
How is the Penrose steps illusion created?
Interpretation: The statements
x = y;
y = x;
will correctly swap the values in
x and
y if and only if x and
y have the same initial values.
This result follows without thinking operationally (like a machine). We only have to apply the rules and interpret the results.
42. Algebra
From the axiomatic rules used to prove program code correct, one should see that algebra is an integral part of that process.
Thus, the ability to algebra, as in substitute and simplify, is an important and implicit part of the programming process.
43. Programming
Much of programming reduces to learning
code invariant transformation rules and
abstraction rules and applying them in a
iterative refinement process - often without thinking about what they mean.
That is the purpose of
algebra. That is, to transform mathematical expressions
without thinking about what they mean (in an operational sense).
1. Substitute
2. Simplify
44. Miller's Law
Remember Miller's Law that one can only keep about up to 7 things in memory at once.
Programmers who rigidly enforce this force you to go through many screens, each of which has only a few choices. One can quickly lose track of where things are in the interface.
45. Viewpoint
Viewpoints:
Most users: How can I get the software to do this.
Some programmers: How can I make the software do this.
46. Changing code
Moving code around using invariant transformations is to a programmer who has memorized that code and thinks like a computer, like moving things around in a house where a cat lives. The cat's memory map of where everything is located needs to get relearned.
47. Problem types
1. Think like a computer:
Here is some code using loop, if, etc. What is the output?
2. Thinking like a computer not required:
Here are four code fragments. Which one can compute a different output?
48. Problem comparison
Think like a computer:
Yes: What is the output of each code fragment?
No: Which code fragment can compute a different output?
Assume all variables are integers and declared (omitted).
|
i = 0;
while (i != 8) {
i += 1;
print(i);
}
|
h = 0;
while (h != 8) {
print(h);
h += 1;
}
|
k = 1;
while (k != 8) {
print(k);
k += 1;
}
|
The
for loop has very subtle semantics that vary from language to language. Best to avoid except for
1 to
n or
0 to
n-1. Python does not have a
for loop.
49. Assignment statements
What do the following assignment statements do? That is, what is their effect.
x = y - x;
y = y - x;
x = x + y;
Explain how you arrived at your conclusion.
The exclusive or operation can be used for the same effect.
50. Swapping values
Parallel assignment: (syntax varies)
x, y = y, x
Lua
JavaScript (since 1.7)
PHP
Python
PowerShell
Ruby
51. Procedures
A procedure can be used to swap values.
This handles the noncomputer-checked redundancy.
Reference parameters are needed. Some languages do not have reference parameters.
52. Procedure using reference parameters
Here is the C code [#1]
53. Output
Here is the output of the C code.
54. Macro expansion
A procedure can be considered a textual macro that is expanded in-line with the parameters.
Macro expansion can be used such as is found in C, C++, Julia, etc.
Redundancy is generated but is handled by the computer.
55. Macro expansion
Here is the C code [#2]
Note: Due to the replacement of swap(x1,y2) with a block (delimited by curly braces), a terminating semicolon can be used or not used.
56. Output
Here is the output of the C code.
57. Text formatter
A text formatter approach uses macros to expand text in-line. Somewhat like
AOP = Aspect Oriented Computing
@ MACRO(swap(a,b)=[a, b = b, a;])
Another way:
@ MACRO(swap(a,b,t)=[t = a;
a = b;
b = t;])
Combined way:
@ MACRO(swap(a,b,t)=[@ IFDEF(t,y [t = a;
a = b;
b = t;]
,n [a, b = b, a;])])
58. Code and data
Code and data are two views of the same phenomena.
Code can be data.
Data con be code.
Von Neumann first noticed this in the 1950's though it is assumed by
Turing in his limits of computation work involving the
Halting Problem in the 1930's.
59. Redundancy
Redundancy is repetition. This can be good or bad.
Noncomputer-checked redundancy is bad. Human error.
Computer-checked redundancy is good. Backup systems, type-checkers, spell-checkers, etc.
Not to be overly repetitive and redundant: Have you tired of the global worldwide pandemic that is everywhere?
60. Noncomputer-checked redundancy
Noncomputer-checked redundancy is the primary problem in software systems.
Design goal: Every important aspect of a program should be changeable in one and only one place. To make a change, find that one place.
Design goal: In general, every block of code should have one entry point and one exit point.
As with all rules: unless you have a really good reason.
61. Data world
62. Code world
Code redundancy issues: Solved (in part) with
OOP = Object Oriented Programming.
Top-down: object-oriented design
Bottom-up: structured programming, modular programming, classes and objects.
Still present in
non-OOP systems (Go, Julia, etc.)
Text (and code) world involves text formatting using macros, etc.
63. Programming
It is almost always better to move "
code-driven programming" to "
data-driven programming".
Code driven: Long if-then-else for each day of the week.
Data driven: Array indexed lookup of result.
This should be covered in the first programming course so students learn both ways and which is better.
Code flow: control flow charts (avoid)
Data flow: data flow charts (use)
Better to transform the data to new data without changing the data in-place (assignment statement issues), the idea of
XSLT.
64. Code and data
Bad programmers worry about the code. Good programmers worry about data structures and their relationships. Linus Torvalds (Finnish-American software engineer who created what is called Linux)
Do not think in Java, Python, etc. Think about data, data flow and the problem being solved.
65. Program facing aspects
Two aspects of programs that follow from specifications are the following.
What does the customer see? This is customer-facing or functional specification requirements. Provides direct value to the customer.
What does the programmer see? This is programmer-facing or nonfunctional specification requirements. Necessary but no direct value to customer.
66. Customer facing output
Functional requirement: Customer-facing output is to be "Hello. How is you today.".
Nonfunctional requirement: Use the Go (or golang) programming language.
67. Code example
Here is a code example in Go.
If you change the output text in any way, you lose points.
The customer specifies the customer-facing requirements.
The company (teacher) will specify the programmer-facing requirements.
The only way to determine if the code has an error is to compare it to a specification.
68. Errors and changes
The definition of an error and a desired change is very similar.
Both an
error and a
change are a difference between the observed behavior and the expected or desired behavior.
To identify an error requires a
specification and one should not use the operational code (in programming, or reality in general) as a specification.
69. Fallacy
Fallacy:
The programmer is allowed to change the customer-facing specifications when they think it will make a better program.
The customer gets what they requested and approved. In real situations, one goes to the manager, the manager goes to the client, and a change to the specification is worked out.
70. Customer facing
In a beginning programming course, the customer-facing parts of the program are the input and output statements.
Customers can be very particular about the output. Every character and space must be what they want.
The same goes for input prompts and input echo - text for this course, but the graphical user interface in general.
71. Grading
Statistics analogy:
Small (Bayesian) sample to estimate population mean (opportunity to learn)
Complete sample to determine population mean (educate)
72. Correctness semantics
operational
declarative
axiomatic
73. Constants
... more to be added ...
74. Variables
... more to be added ...
75. Loop unrolling
... more to be added ...
76. Abstraction
To
abstract is to
take away from the essentials and thereby to ignore certain differences.
The
similarity is what is the same. The
difference is what is different.
Human brains are built for complex abstraction.
The Latin word
"abstractus" ≈ "take away from". In abstract art, something is taken away, something remains, one needs to then interpret what is meant or intended.
77. Abstraction and psychological chunking
Part of the process of abstraction is what Hofstadter calls "psychological chunking". Hofstadter, D. (1979).
Gödel, Escher, Bach: An eternal golden braid. New York: Vintage Books., p. 285-287.
Hofstadter relates how Adriaan de Groot performed studies of
expert and
novice chess players in the 1940's.
78. Procedural abstraction introduction
79. Procedural abstraction introduction
Let us look at a abstraction example for the first programming course using the children's song "
Mary had a little lamb".
There is no input.
The output is known to everyone.
String rewriting concepts are used.
Procedural abstraction is used.
No math is used (as most students think of math).
Another song, such as "
Old MacDonald had a farm" is used for labs and assignments based in the following example.
Let us look at procedure abstraction using a children's nursery rhyme as an example.
Note: Using a simple song has the advantage that the output is known and easily recognizable while one is programming the abstractions.
80. Music
Here are the lyrics to the song, "
Mary had a little lamb" as music.
The image was created with a LilyPond script. (omitted)
81. Lyrics
Here are the lyrics to the song, "
Mary had a little lamb" as text.
Mary had a little lamb,
little lamb, little lamb
Mary had a little lamb,
it's fleece was white as snow.
And everywhere that Mary went,
Mary went, Mary went.
Everywhere that Mary went,
the lamb was sure to go.
Functional requirements: customer facing (do not change)
Nonfunctional requirements: code style according to company policy
82. Print statements
Obviously, we could output this text using print statements as follows.
printf("Mary had a little lamb,\n");
printf("little lamb, little lamb\n");
printf("Mary had a little lamb,\n");
printf("it's fleece was white as snow.\n");
printf("\n");
printf("And everywhere that Mary went,\n");
printf("Mary went, Mary went.\n");
printf("Everywhere that Mary went,\n");
printf("the lamb was sure to go.\n");
The student is shown how to use editor shortcuts to not type code. Just copy and paste such as
printf(" ... "):.
83. Program
Here is a program to do just that.
The output is as expected.
Regression testing can be used to check the output with the specification.
84. Code development
1. Code dev 1
2. Code dev 2
3. Code dev 3
4. Code dev 4
5. Code dev 5
In order to develop code, a code development process is needed.
Most students write lots of code and then try to get it working.
This does not work very well.
85. New requirements
Mary had a little lamb,
little lamb, little lamb
Mary had a little lamb,
it's fleece was white as snow.
And everywhere that Mary went,
Mary went, Mary went.
Everywhere that Mary went,
the lamb was sure to go.
|
Johnny had a tiny pig,
tiny pig, tiny pig
Johnny had a tiny pig,
it's hide was black as coal.
And everywhere that Johnny went,
Johnny went, Johnny went.
Everywhere that Johnny went,
the pig was sure to go.
|
Original and new requirements.
There may be new similar requirements in the future.
|
Susan had a hopping rabbit,
hopping rabbit, hopping rabbit
Susan had a hopping rabbit,
it's fur was brown as earth.
And everywhere that Susan went,
Susan went, Susan went.
Everywhere that Susan went,
the rabbit was sure to go.
|
86. Color-coded differences
Mary had a little lamb ,
little lamb , little lamb
Mary had a little lamb ,
it's fleece was white as snow .
And everywhere that Mary went,
Mary went, Mary went.
Everywhere that Mary went,
the lamb was sure to go.
|
Johnny had a tiny pig ,
tiny pig , tiny pig
Johnny had a tiny pig ,
it's hide was black as coal .
And everywhere that Johnny went,
Johnny went, Johnny went.
Everywhere that Johnny went,
the pig was sure to go.
|
Colors help one see similarities and differences.
Similarities: procedure body
Differences: actual/formal parameters.
|
Susan had a hopping rabbit ,
hopping rabbit , hopping rabbit
Susan had a hopping rabbit ,
it's fur was brown as earth .
And everywhere that Susan went,
Susan went, Susan went.
Everywhere that Susan went,
the rabbit was sure to go.
|
87. Comparison
A program such as WinMerge can help see the similarities and differences. Here is a comparison of Mary (#1) and Susan (#3).
One still has to see differences between "
little lamb" and "
hopping rabbit" in the overall context.
88. Abstractions
Do you see that there are similarities and differences? If not, you may have a difficult time in computer science.
Some appropriate abstractions are needed.
A common example of such requirements are a web page system that must generate certain output or reports based on data in a database. The method is similar to the mail merge process in the document world.
89. Mail merge
A mail-merge process using, say, a template in Microsoft Word and a database of differences in an Excel worksheet is another example.
Abstract: separate into differences and similarities
Reduce: fill in the differences with the similarities
In the mail merge process, the differences (fields from each database record) are merged into the similarities (document with fill-in fields) to create the collection of documents merged documents
90. Color-coded differences
Here is a color-coded table of differences.
Go: Procedural abstraction introduction |
Name |
v. 1 |
v. 2 |
v. 3 |
NAME |
Mary |
Johnny |
Susan |
SIZE |
little |
tiny |
hopping |
ANIMAL |
lamb |
pig |
rabbit |
FUR |
fleece |
hide |
fur |
COLOR |
white |
black |
brown |
OBJECT |
snow |
coal |
earth |
|
Susan had a hopping rabbit ,
hopping rabbit , hopping rabbit
Susan had a hopping rabbit ,
it's fur was brown as earth .
And everywhere that Susan went,
Susan went, Susan went.
Everywhere that Susan went,
the rabbit was sure to go.
|
Similarities become the body of a procedure/function.
Differences become actual/formal parameters.
91. Differences
Here is a table of differences without color.
Go: Procedural abstraction introduction |
Name |
v. 1 |
v. 2 |
v. 3 |
NAME |
Mary |
Johnny |
Susan |
SIZE |
little |
tiny |
hopping |
ANIMAL |
lamb |
pig |
rabbit |
FUR |
fleece |
hide |
fur |
COLOR |
white |
black |
brown |
OBJECT |
snow |
coal |
earth |
|
Susan had a hopping rabbit,
hopping rabbit, hopping rabbit
Susan had a hopping rabbit,
it's fur was brown as earth.
And everywhere that Susan went,
Susan went, Susan went.
Everywhere that Susan went,
the rabbit was sure to go.
|
Similarities become the body of a procedure/function.
Differences become actual/formal parameters.
92. Color-coded input data
Here are color-coded input data sets.
Input set #1
|
Input set #2
|
Input set #3
|
Output #3
|
Mary
little
lamb
fleece
white
snow
|
Johnny
tiny
pig
hide
black
coal
|
Susan
hopping
rabbit
fur
brown
earth
|
Susan had a hopping rabbit ,
hopping rabbit , hopping rabbit
Susan had a hopping rabbit ,
it's fur was brown as earth .
And everywhere that Susan went,
Susan went, Susan went.
Everywhere that Susan went,
the rabbit was sure to go.
|
93. Input data without color
Here are input data sets without color.
Input set #1
|
Input set #2
|
Input set #3
|
Output #3
|
Mary
little
lamb
fleece
white
snow
|
Johnny
tiny
pig
hide
black
coal
|
Susan
hopping
rabbit
fur
brown
earth
|
Susan had a hopping rabbit,
hopping rabbit, hopping rabbit
Susan had a hopping rabbit,
it's fur was brown as earth.
And everywhere that Susan went,
Susan went, Susan went.
Everywhere that Susan went,
the rabbit was sure to go.
|
94. Actual input
For physical input, some decisions need to be made. How is the above data recognized?
Is it separate variables?
Is it a counter loop?
Is it a header loop?
Is it a trailer loop? What is the trailer value?
Is it an endfile loop?
Is it some other way?
Are there other data in the input, such as a debug output setting?
95. Solutions
96. Observation
Fallacy:
If you are good at math, you will be good at computer science.
In the above development, and in the solutions, what is often thought of as mathematics - using addition, subtraction, multiplication, division, formulas, etc., is not needed.
The math needed is abstraction and symbol manipulation and algebra as in lambda calculus.
97. Textual abstraction
The core of computer science and programming involves abstraction. Many students who are good at "
math" have trouble with these programs. How many students who are not good at "
math" can do this type of abstraction?
Most students have problems with abstraction in that they want to think like a machine rather than doing textual pattern matching and algebraic code transformations.
98. Engineering efficiency
Although mathematics is very important to the computer scientist, there is much more than mathematics to computer science.
Programming is as much a mathematical discipline as an engineering discipline; correctness is as much our concern as, say, efficiency. Dijkstra, E. (1976).
A discipline of programming. Englewood Cliffs, NJ: Prentice-Hall., p. 54-55.
Edsger Dijkstra (computer scientist)
99. Summary
Some ways of programming without thinking like a machine have been presented. Many more were omitted.
Operational: How it works (control)
Functional: What it does (logic)
Algebra: transform without thinking
Abstraction: similarities and differences
Code-driven to data-driven
Code flow to data flow (avoid update in place)
100. Questions, comments
101. End of page