From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f4fd2,626a0a064b320310 X-Google-Attributes: gidf4fd2,public X-Google-Thread: 103376,ea8ea502d35ca2ce X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-10 22:30:52 PST Path: archiver1.sj.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!193.174.75.178!news-fra1.dfn.de!newsfeed.hanau.net!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail From: Friedrich Dominicus Newsgroups: comp.lang.ada,comp.lang.lisp Subject: Re: Beginner's Language? Date: 11 May 2001 07:29:10 +0200 Organization: Q Software Solutions GmbH Message-ID: <87oft0pi6x.fsf@frown.here> References: <9cukad$nn68@news-dxb> <9d6b6e$1bt$1@nh.pace.co.uk> <87snihxiwc.fsf@frown.here> <9dbi83$sji$1@nh.pace.co.uk> <3AFACCA0.303A79AF@baesystems.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.t-online.com 989558782 06 7855 xzi6SKMSS3-L3- 010511 05:26:22 X-Complaints-To: abuse@t-online.com X-Sender: 320004655587-0001@t-dialin.net User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Capitol Reef) Xref: archiver1.sj.google.com comp.lang.ada:7375 comp.lang.lisp:9807 Date: 2001-05-11T07:29:10+02:00 List-Id: David Gillon writes: > I much prefer the following to the example above and I believe that even > with all comments stripped out it would be inherently easier to > understand for a struggling student: > > procedure Sum_Five_Values is > > -- Description : > -- Example showing clear coding practice, sums five integer inputs > -- and displays result > > -- Input Parameters : > -- None (uses keyboard) > -- Output Parameters : > -- None (uses screen) > > -- Modification History : > -- 10-05-2001, Initial version, DWG > -- ,, > > Total_Count : Integer := 0; > Entered_Value : Integer; > > begin > > -- Sum five inputs from the keyboard > for Loop_Counter := 1 .. 5 do > begin > Put_Line ("Enter an integer value and press return"); > Get (Entered_Value); > Total_Count := Total_Count + Entered_Value; > end; > > -- report the final result to the screen > Put("Total Value = "); > Put_Line(Total_Count); > > end Sum_Five_Values; (defun sum-n-numbers (n) "Read n numbers from the standard input and add them all" (let ((element 0) (total-sum 0)) (loop for i from 1 to n do (format t "Give me a number please : ") (setf element (read)) (setf total-sum (+ total-sum element)) finally (format t "Total Sum = ~A~%" total-sum)))) Now I don't think I ever would write it that way, but hey it's as verbose as you want it to be ;-) Now alternatively one could write: (defun sum-n-numbers (n) (loop for i from 1 to n for prompt = (format t "Give me a number please ") for element = (read) sum element into total-sum finally (format t "Total Sum = ~A~%" total-sum))) or (defun sum-n-numbers (n) (let ((total-sum 0)) (dotimes (i n) (format t "Give me a number please: ") (let ((element (read))) (incf total-sum element))) (format t "Total Sum = ~A~%" total-sum) (values))) or .... I doubt that the Basic solution is easier on the eyes for a beginner than one of the Common Lisp solutions. Anyway programming I would conclude that learning programming is work it can be even very hard. As usual if you start with something completly new you're lost in the details. You do not know what really is important all looks more or less like black magic. So what a beginner needs is either a very good book or a good teacher and he/she must really want to learn programming. What we never should forget is that having fun while learning is a maybe not the worst thing. If you can get nice results fast, it's very encouraging. One can compare programming with a lot of other things. It's like a game, a puzzle or like building a model. Every game has it's rules a puzzle can be build just in one way and you have to follow a order to get a model build. All this holds for programming the rules are what the language asks you for, getting the pieces together will gave the whole picture. If you miss one piece well, your programm like you puzzle will be incomplete. The model is the idea you have while working on you program. I really can't tell what a beginer is looking for, those times are still gone for me and for you. That means if we show "what we think" is understandable or "readable" for a beginner, it's nearly completly irrelevant to them. They have their own idea, there will some which like C, Assembler, Pascal, Modula-2, C++, Java, Lisp, Haskell or whatever and find some other things totally stupid. So I suggest not to put one of the languages down, but assist anyone who wants to learn programming in whatever you like. Let him/her make the choice and fine... Regards Friedrich