Re: [BLACKBOX] Re [BLACKBOX] Seasons Greetings from Linuxland

From: Rene A. Krywult <"Rene>
Date: Tue, 28 Dec 2010 09:31:45 +0100

----boundary-LibPST-iamunique-1138269517_-_-
Content-type: text/plain

Talking about languages "encouraging good or bad code".

First of all, a programming language *is* a language, and thus it is possible to have a good style or a bad style, just as with a natural language.

But second, there are *some* examples I really like to share.

The first two come from PL/1, a language I had to use a lot on IBM3270:

1)
PROCEDURE TEST;
   DCL A,B,C BIN FIXED(31)
   A=0;
   B=1;
   C=1;
   RETURN(A=B=C)
END;

I think this is problem inherent in the language, and not so much a question of bad style. Someone who has PL/I as a first language will, when switching to C, naturally write unreadable code when trying to do the same as above, while a Wirthian language will force him to do better.

2)
IF XY=1 THEN;
ELSE GOTO A;
   .
   .
   .
A:
   .
   .

where A is not used for anything else than the one (!) goto above, and XY is also only set once (but depending on a condition). The points between GOTO A; and A stand for various statements, as do the points after A:

These are real-life examples I encountered myself when working for a supermarket chain about 16 years ago. Example 2 was in a central program. There were about 50 such statements in the program, no procedures and functions at all. The program ran once a month, every month it crashed, and it took the original programmer about 1 week each month (with 10 hour working days!) to "fix" the bug. Then he had a heart attack, and I, a newcomer to PL/I had to take over.....

What I'm saying is: You can write good style and bad style in any language, but with a compiler that forces you to not commit the ugliest style-errors, you do not need so much of a style guide, and you are trained to think and write more clearly.

A friend of mine, chief software engineer in a bank and a very intelligent guy, told me, that it took him 5 years to find a good style for C++, and then he wrote a style guide for the bank, where he hoped that everybody used it.

Rene


 
-------- Original-Nachricht --------
> Datum: Mon, 27 Dec 2010 19:41:56 -0500
> Von: Wojtek Skulski <skulski{([at]})nowhere.xy
> An: BLACKBOX{([at]})nowhere.xy
> Betreff: Re: [BLACKBOX] Re [BLACKBOX] Seasons Greetings from Linuxland

> > The following hypothetical examples are intended to show what a
> programmer
> > could concoct if he has muddled thinking regarding boolean logic [snip]
>
> My own conclusion is that one can write C in any language. One also can
> write reasonable code in C. Some languages encourage good attitude while
> others just the opposite, but at the end of the day it is the attitude,
> which differentiates the masters from their opposites.
>
> Playing devil's advocate, I remember my utter surprise when I read
> statements in Project Oberon like "IF mouse = 1 THEN...". The mouse keys
> were numbered 1,2,3 (or 0,1,2, don't remember) and these numbers were used
> literally in the code published in the book (!!). A bit shameful, was it
> not? In later versions the literal constants we replaced with ML, MM, and
> MR, as they should have been from the beginning.
>
> Even our gurus have had their bad days.
>
> W.
>
>
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
> LISTSERV{([at]})nowhere.xy

-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1138269517_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFRhbGtpbmcgYWJvdXQgbGFuZ3VhZ2VzICJlbmNv
dXJhZ2luZyBnb29kIG9yIGJhZCBjb2RlIi4gXHBhcg0KXHBhcg0KRmlyc3Qgb2YgYWxsLCBhIHBy
b2dyYW1taW5nIGxhbmd1YWdlICppcyogYSBsYW5ndWFnZSwgYW5kIHRodXMgaXQgaXMgcG9zc2li
bGUgdG8gaGF2ZSBhIGdvb2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CB3aXRoIE1MLCBNTSwgYW5kXHBhcg0KPiBNUiwgYXMgdGhleSBzaG91bGQgaGF2ZSBi
ZWVuIGZyb20gdGhlIGJlZ2lubmluZy5ccGFyDQo+IFxwYXINCj4gRXZlbiBvdXIgZ3VydXMgaGF2
ZSBoYWQgdGhlaXIgYmFkIGRheXMuXHBhcg0KPiBccGFyDQo+IFcuXHBhcg0KPiBccGFyDQo+IFxw
YXINCj4gLS0tLVxwYXINCj4gVG8gdW5zdWJzY3JpYmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9k
eSAiU0lHTk9GRiBCTEFDS0JPWCIgdG9ccGFyDQo+IExJU1RTRVJWQExJU1RTLk9CRVJPTi5DSFxw
YXINClxwYXINCi0tIFxwYXINCk5ldTogR01YIERlLU1haWwgLSBFaW5mYWNoIHdpZSBFLU1haWws
IHNpY2hlciB3aWUgZWluIEJyaWVmISAgXHBhcg0KSmV0enQgRGUtTWFpbC1BZHJlc3NlIHJlc2Vy
dmllcmVuOiBodHRwOi8vcG9ydGFsLmdteC5uZXQvZGUvZ28vZGVtYWlsXHBhcg0KXHBhcg0KXHBh
cg0KLS0tLVxwYXINClRvIHVuc3Vic2NyaWJlLCBzZW5kIGEgbWVzc2FnZSB3aXRoIGJvZHkgIlNJ
R05PRkYgQkxBQ0tCT1giIHRvIExJU1RTRVJWQExJU1RTLk99fQBnIHdpdGggdGhlIHM=
----boundary-LibPST-iamunique-1138269517_-_---
Received on Tue Dec 28 2010 - 09:31:45 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:26 UTC