Path: utzoo!mnetor!uunet!mcvax!ukc!eagle!has From: has@eagle.ukc.ac.uk (H.A.Shaw) Newsgroups: comp.lang.c Subject: Re: Power operator? Message-ID: <4186@eagle.ukc.ac.uk> Date: 17 Jan 88 12:49:13 GMT References: <6982@brl-smoke.ARPA> <326@splut.UUCP> <327@splut.UUCP> <22773@hi.unm.edu> Reply-To: has@ukc.ac.uk (H.A.Shaw) Organization: Computing Lab, University of Kent at Canterbury, UK. Lines: 66 Summary: Expires: Sender: Followup-To: This may look like a flame. It is not supposed to be, but I feel strongly that we are wasting our time with questions that have no relavence to C as a language. What people appear to be forgetting is what C is for. When I started to learn coding, the process of turning an algrothim into a real computer program, I was told that the first thing to do is to chose the language to use. You should not do complex mathematical work in C, in the same way that you don't solve simultainous equations in troff (I have seen this done!) if you want a long life without ulsers. What we need is to reduce C to it's basics. C is one of a nearly infinite group of languages, each is good at only ONE job. We have forgotten that C was originally a system programmers language. Who needs pow() in a pager or line printer demon? If you want maths, use FORTRAN, to teach, use BASIC/PASCAL, to drive a robot, use LOGO, etc., etc. Why do you think we have so many languages? The C language was a radical change from what went before it. There is still very little like it. It has a unique place in the scheme of things because of two very important principles that are buried deep in it. 1) The programmer knows what he is doing and it is none of the language's business to try and stop him. 2) Just because you *MAY* do something does not mean mean that you *SHOULD* do it. Therefore C allows things like: int a[], i; a[i++] = a[i++] + (int)&i + (int)&(a[i++]); or: struct one { int a, b;} var1; struct two { float c, d;} var2; var1.c = var2.b; If you are stupid enough to write such rubbish, then what business is it of the compiler to try and stop your madness. The intermable complaints about compiler dependent constructs are due to people trained on other languages not understanding principle 2) and the trust that a C compiler has in it's users. I was told to think of C as a macro-assemblier for the hardware you are on. It defines do{}while, for(){}, while(){} and switch(){} as macros in terms of "if" and "goto". A struct is just a name, and the elements within it are numeric offsets. Function calls are just JSR instructiuons with a bit of stack work first. (Therefore we get VARARGS etc. for free.) A variable is just a name with some memory behind it, you can reference it in any way you like. C is one of very few languages that has direct access to the addressing modes of the underlieing machine. Things like [i++], * and & are fine if you know the machine, and ALL C programmers are assumed to have infinite knowledge. As a final point, when I was an undergrad in Physics, the Computing Lab refused to teach C, as it was possible to pick up very bad habits from its freedom. We were told that programming was like walking. One should learn in a cushoned, small space before being let out into a big field where if you fall nobody will catch you. I wholeheartedly agree, and hope I write better C programs now for three years of BASIC/PASCAL/FORTRAN/FORTH first. They did teach it to third year Computer Scientists sometimes. PS: If hack had been written in DDL or something similar, would net.sources.bugs have all the traffic it now does? -- UUCP: ...seismo!mcvax!ukc!has | Howard A. Shaw. or : has@ukc.uucp | Room 12, Physics Lab., JANET: has@uk.ac.ukc | The University, Phone: +44 227 764000 Ext. 3282 | Canterbury, England. CT2 7NZ.