:: Re: [DNG] OT: some ancient programm…
Pàgina inicial
Delete this message
Reply to this message
Autor: Didier Kryn
Data:  
A: dng@lists.dyne.org
Assumpte: Re: [DNG] OT: some ancient programming language history
T.J, would you please try to put dyne.org as To instead of CC, in
the destination? I think it would enable the button "reply to the list"
in Thunderbird.

Le 27/07/2015 02:28, T.J. Duchene a écrit :
>
> >      The affectation operator is := instead of = in C, and the
> > comparison are = (instead of ==) and /= instead of != . The bad
> > choice
> > of operators, together with other tricks is probably the main source
> > of
> > bugs in C programs.

>
> I like the fact that Ada is very strict, because it forces new
> programmers to do things right. On the other hand, that comes at the
> cost of flexibility, which makes it useless for certain tasks.
>
> Since C predates Ada by at least a decade, I don't think C is the
> problem. I have never had a problem keeping "==", "=" or "!="
> straight.


     I'm not a teacher and therefore can mostly speak for myself. I 
learned ALGOL in 1972, as already written, and then stopped programming 
for 6 years. Then I learned FORTRAN, which has the same assignment 
symbol as C, '=' . I discovered C in 1981 and used it up to now, which 
makes a honestly long experience, and it still happens to me to type '=' 
instead of '=='.


    The first Ada compiler appeared in 1983. It advertized some 
interesting features and I read a manual, then forgot it because I 
hadn't access to a compiler. This first compiler was running on VMS I 
think. I remember the year very well for other reasons.


     So you cannot believe I was "contaminated" by the use of ALGOL-like 
languages.


     Using C after FORTRAN, was a liberation. I could do a lot of things 
previously impossible. And there was structs and pointers. I loved 
programming in C. Later I wrote multitask and multithreaded DAQ 
programs. And discovered that a large program becomes rapidly 
un-maintainable, unless you work at least weekly on it.


     Around 1994 I had the project of a large multi-host DAQ system and 
I decided to select an appropriate language because C was too low-level. 
I selected Ada after months of enquiry, reading various opinions and 
comparisons, without knowing the language at all. Then I had, by chance, 
the opportunity to follow a one week lecture in 1995 and came out 
thinking I would never write applications in any other language. I had 
the opposite opinion about C++ 5 years before after a one week lecture also.


     C is a universal assembler. It is cast after the hardware. A unique 
feature of C is that an assignment has a value; this is because the 
value which has just been stored into memory is still there in a 
register, ready for use. It can be assigned to another variable (stored 
in another location), which allows instructions like "a=b=c;" while 
"b=c; a=b;" would mean an additional and useless load. C compilers have 
long been able to optimize out the additional load, but the instruction 
is still valid.


     A lot of C features are driven by the will to give the programmer a 
quasi-direct access to machine instructions. This includes the case 
explained above and pre-increment and post-increment instructions. But 
it makes no sense with modern compilers. The compiler now wipes out 
these optimizations the programmer may think xe has done, reorders the 
instructions, bypasses memory access for non-volatile variables and 
optimizes the whole better than you could do. It remains these funny 
features which are the trademark of C but are nothing but a danger.


     If you never make the mistake of using a single = in a comparison, 
then either you have a trick, or you are super-human. Whatever error is 
possible to do, a human will do it for sure. Gcc now gives a warning in 
such cases, but it's enough to enclose in parentheses to avoid the warning.


     When you write "C predates Ada", you probably mean there are more 
people programming in C than Ada. So what? That tells nothing on the 
respective merits of the two languages. The fact is there hasn't been a 
good Ada compiler for a decade, because it is a difficult job to write 
one, while, in the contrary, C had been designed to make it easy to 
write compilers. The lack of good Ada compilers is probably one of the 
reasons for the later success of C++ (which started as a C preprocessor).


     C enables writing little things quickly and easily; for large 
things, it takes an infinite time to erradicate bugs. Ada is just the 
opposite: bad constructs are forbidden and the compiler checks a great 
many things. It takes longer to have your program compile without error, 
but then it works. There still remains a few possible bugs which cannot 
be found at compile time, but they will rather cause a crash than 
produce wrong results. At the end, you save time. Always.


     Sorry for this very long mail. I should better have a web site like 
Steve, and post links.


     Didier