From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.8 required=3.0 tests=BAYES_50,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: Why "Hello World" as a first exercise? Date: Sat, 31 Jul 2021 19:37:11 -0700 Organization: None to speak of Message-ID: <87mtq1ao14.fsf@nosuchdomain.example.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="45c31737cfd44125daaf4223bdb9fd61"; logging-data="9506"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19L2p1tnFCovvpa4i2eTvCv" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:Egea7Hze0TF/EOPESFdt9qe2y3A= sha1:vOiK9pcnWBsw3Vv4euomkVACrAY= Xref: reader02.eternal-september.org comp.lang.ada:62470 List-Id: Richard Iswara writes: > Why is it most of the courses of introduction to programming or > programming language use a "Hello World" kind of program as a demo or > first exercise? > Why not do a proper input loop as a showcase or a first exercise? With > an input loop procedure you get: > 1. How to read and output an input. > 2. Show the if-then-else structure. > 3. Show the loop structure. > 4. Show error messages and how to properly handle it. > 5. On Ada in particular you are showing the type system. > 6. If it is a subprogram then input loop shows how to do and call the > subprograms. > And last but not least it teaches and reinforces to the student how to > think about safety in programming. > So why a useless look at me, ain't I cool "Hello World"? > > Sorry I had to vent after an unsatisfying exchange over at arstechnica. All those things you listed absolutely should be covered -- but only *after* the "Hello World" exercise. The first time someone with no programming experience tries to write, compile, and run a program, *something* will very likely go wrong. Maybe they'll omit a semicolon, or misspell an identifier, or invoke the compiler without a required option. And they're likely to be shown a terse error message that might not direct them to the right way to fix it. By making the first program something trivial that can reasonably be entered verbatim, you eliminate several sources of errors. If the student double checks that the source file exactly matches what's in the textbook and it doesn't run, it's substantially easier to diagnose the problem. Once the student gets "Hello, World" working correctly, if the second program uses some of the features you mention and *that* doesn't work, they'll know that the problem is something in the difference between the first and second programs. You might try a more ambitious first program if you're an experienced programmer trying out a new language, but even then I'll probably try "Hello World" before I try FizzBuzz. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */