* remove "\r" nonsense
[mascara-docs.git] / C / the.ansi.c.programming.language / notes.accompany.ansi.c / sx4.html
blob6ddc1833a8b9f183b9524f0f973bf74ca2675148
1 <!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995, 1996 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
5 <html>
6 <head>
7 <link rev="owner" href="mailto:scs@eskimo.com">
8 <link rev="made" href="mailto:scs@eskimo.com">
9 <title>Chapter 1. A Tutorial Introduction</title>
10 <link href="sx3.html" rev=precedes>
11 <link href="sx4a.html" rel=precedes>
12 <link href="top.html" rev=subdocument>
13 </head>
14 <body>
15 <H1>Chapter 1. A Tutorial Introduction</H1>
17 <p>page 5
18 </p><p>I completely agree with the authors that writing real programs,
19 and soon,
20 is the best way to learn programming.
21 This way,
22 concepts
23 which would otherwise seem abstract
24 make sense,
25 and the positive feedback you get from getting even a small
26 program to work
27 gives you a great incentive to improve it or write the next one.
28 </p><p>Diving in with ``real'' programs right away has
29 another advantage,
30 if only pragmatic:
31 if you're using a conventional compiler,
32 you can't run a fragment of a program and see what it does;
33 nothing will run until you have a complete
34 (if tiny or trivial) program.
35 You can't learn everything you'd need to write a complete
36 program all at once,
37 so you'll have to take some things ``on faith'' and
38 parrot them in your first programs before you begin to
39 understand them.
40 (You can't learn to program just one expression or statement at
41 a time any more than you can learn to speak a foreign language
42 one word at a time.
43 If all you know is a handful of words,
44 you can't actually <em>say</em> anything:
45 you also need to know something about the language's word order
46 and grammar and sentence structure and declension of articles
47 and verbs.)
48 </p><p>The authors list a few drawbacks of this ``dive in and
49 program'' approach,
50 and
51 I must add
52 one more.
53 It's a small step from learning-by-doing
54 to learning-by-trial-and-error,
55 and when you learn programming by trial-and-error,
56 you can very easily learn many errors.
57 When you're not sure whether something will work,
58 or you're not even sure what you could use that might work,
59 and you try something,
60 and it does work,
61 you do <em>not</em> have any guarantee that what you tried
62 worked for the right reason.
63 You might just have ``learned'' something that works only by
64 accident
65 or only on your compiler,
66 and it may be very hard to un-learn it later,
67 when it stops working.
68 (Also, if what you tried didn't work,
69 it may have been due to a bug in the compiler,
70 such that it should have worked.)
71 </p><p>Therefore,
72 whenever you're not sure of something,
73 be very careful before you go off and try it
74 ``just to see if it will work.''
75 Of course, you can never be absolutely sure that something is
76 going to work before you try it,
77 otherwise we'd never have to try things.
78 But
79 you should
80 have an expectation that something is going
81 to work before you try it,
82 and if you can't predict how to do something or whether
83 something would work and find yourself having to determine it
84 experimentally,
85 make a note in your mind that whatever you've just learned
86 (based on the outcome of the experiment)
87 is suspect.
88 </p><p><a href="sx4a.html" rel=subdocument>section 1.1: Getting Started</a></p>
89 <p><a href="sx4b.html" rel=subdocument>section 1.2: Variables and Arithmetic Expressions</a></p>
90 <p><a href="sx4c.html" rel=subdocument>section 1.3: The For Statement</a></p>
91 <p><a href="sx4d.html" rel=subdocument>section 1.4: Symbolic Constants</a></p>
92 <p><a href="sx4e.html" rel=subdocument>section 1.5: Character Input and Output</a></p>
93 <p><a href="sx4f.html" rel=subdocument>section 1.5.1: File Copying</a></p>
94 <p><a href="sx4g.html" rel=subdocument>section 1.5.2: Character Counting</a></p>
95 <p><a href="sx4h.html" rel=subdocument>section 1.5.3: Line Counting</a></p>
96 <p><a href="sx4i.html" rel=subdocument>section 1.5.4: Word Counting</a></p>
97 <p><a href="sx4j.html" rel=subdocument>section 1.6: Arrays</a></p>
98 <p><a href="sx4k.html" rel=subdocument>section 1.7: Functions</a></p>
99 <p><a href="sx4l.html" rel=subdocument>section 1.8: Arguments--Call by Value</a></p>
100 <p><a href="sx4m.html" rel=subdocument>section 1.9: Character Arrays</a></p>
101 <p><a href="sx4n.html" rel=subdocument>section 1.10: External Variables and Scope</a></p>
102 <hr>
104 Read sequentially:
105 <a href="sx3.html" rev=precedes>prev</a>
106 <a href="sx4a.html" rel=precedes>next</a>
107 <a href="top.html" rev=subdocument>up</a>
108 <a href="top.html">top</a>
109 </p>
111 This page by <a href="http://www.eskimo.com/~scs/">Steve Summit</a>
112 // <a href="copyright.html">Copyright</a> 1995, 1996
113 // <a href="mailto:scs@eskimo.com">mail feedback</a>
114 </p>
115 </body>
116 </html>