Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XOR in COBOL: Sample code

557 views
Skip to first unread message

The Magic Friend

unread,
Oct 10, 1994, 3:59:28 PM10/10/94
to
Des Herriott (d...@mfltd.co.uk) wrote:

-> Just what's this suppose to prove, apart from the fact that you
-> can't even write a valid C program, and that you are indeed a
-> clueless git?

Let me add that what it proves is that COBOL is about as
programming-time efficient as it is computationally efficient. It took
me less than a minute to write my C code to do the job. How long did
it take to write that monstrous COBOL routine?

Which is more readable? Which is more maintainable? Which is easier to
debug?

--

Cheers!
Mark

------------------------------------------------------------------------------
ma...@suned.zoo.cs.yale.edu | more info may be found at:
ma...@pmafire.inel.gov (summer) | http://zoo.cs.yale.edu:8000/~markl/home.html
Mark Lindner/SM 1851 (6-1851) | finger ma...@zoo.cs.yale.edu
------------------------------------------------------------------------------

Stephan Zielinski

unread,
Oct 10, 1994, 7:02:03 PM10/10/94
to
YOU'RE STILL NOT FUNNY, MARK. STAY OUT OF REC.HUMOR.

Christ, I should just have a cron job post this.


ObHumor:

1) You have a two-cup measure, a three-cup measure, and a twelve-cup
measure. How can you measure out sixteen cups?

2) You want to boil a three-minute egg. You have a two-minute timer
and a five-minute timer. How do you time the egg correctly?

3) You have to go to a meeting in four minutes. You have six
one-minute timers. How can you be on time, but not early?

4) You want to jump up and startle the librarian in six minutes, but
you only have a two-and-one-half-minute timer and a one-minute timer
that explodes noisily after the second use. You know that the jig
will be up if the timer explodes too early. The librarian is very
pretty. What do you do?

5) You have a shipment of gorillas that needs to be fed in an hour.
You have three 1:01 timers, and a blowhorn that plays just flat of
middle C. What do you do, keeping in mind the strict requirements of
the contract you signed with the Cement Contracting Company last week?

6) In one hour the world will crash into the moon. What in the world
do you do?

7) The window next to you opens and shuts once every seventeen years.
You would like to leave the room through its only entrance, after
being put inside three days before the moment of freedom. You only
have with you a stick of length two meters (exactly), and an inchworm.
How do you explain the metric system in time?

8) The woman sitting next to you knits three rows of wool in a minute.
If the sweater you have you mind set on is nine feet long and red, why
is she using white wool? How long are her knitting needles?

9) You want to bake a potato for four minutes. You have a 3-day timer
with its hands removed and seven-hundred four minute timers. How many
timers do you set?

10) You are driving down a one-way, one-lane highway, going about 115
miles per hour. You are on an uphill slope. It is twilight, just
before dawn, and the sky is streaked in the lower latitudes with deep
purples and magentas. The sides of the road slope sharply down from
the pavement. You are listening to Chuck Mangione on your new
Blaupunkt stereo. You speed your car up to 130 mph. The road no
longer has shoulders; to either side there is underbrush and rocks, on
a hill that dives sharply down into the valley far below. The single
lane narrows. You speed the car up to 145 miles per hour. The razor
blade of a road you are on levels off, and then begins to angle
downwards. The car begins to gain momentum. To either side, you can
barely make out the ground dropping almost vertically away, just a few
inches on either side of your spinning wheels. The downhill slope
becomes more drastic as you light a cigarette and open your window a
bit more.

As the engine dies, you notice the radio and other accesories kick
off and do not come back on again. The steering wheel comes off in
your hand. You sit back and puff on your cigarette, wondering what
life is all about. Question: Do you even TRY to see if the hazard
lights work?

--
Stephan Zielinski szielins%dvl...@us.oracle.com
Pyramid OSx & DC/OSx. Sequent DYNIX/ptx. IBM AIX. HP/UX. SGI IRIX.
My brain hurts.

da...@cc.gatech.edu

unread,
Oct 10, 1994, 7:26:51 PM10/10/94
to
On the subject of "XOR in COBOL: Sample code", szielins%dvl...@us.oracle.com wrote:
>YOU'RE STILL NOT FUNNY, MARK. STAY OUT OF REC.HUMOR.
>
>Christ, I should just have a cron job post this.
>
> <rest deleted>


and you're BOTH f**king clueless. this doesn't belong here.....


d.



--
"If I thought my answer were to one who might ever return to the world,
this flame would shake no more; but since from this depth none have ever
returned alive, I answer you without fear of infamy."
from Dante's _The Inferno_, XXVII, ll. 61-66.

Smile

unread,
Oct 11, 1994, 2:28:40 PM10/11/94
to

In article <37ch5b$8...@dcsun4.us.oracle.com>, szie...@prodhp.us.oracle.com (Stephan Zielinski) writes:
> YOU'RE STILL NOT FUNNY, MARK. STAY OUT OF REC.HUMOR.
>
> Christ, I should just have a cron job post this.
>
>
> ObHumor:
>
> 1) You have a two-cup measure, a three-cup measure, and a twelve-cup
> measure. How can you measure out sixteen cups?
>
Answer: Use the twelve-cup measure once and the two-cup measure twice.

> 2) You want to boil a three-minute egg. You have a two-minute timer
> and a five-minute timer. How do you time the egg correctly?

Answer: Turn both timers on at the same time. When the two-minute timer goes off,
boil the egg.

>
> 3) You have to go to a meeting in four minutes. You have six
> one-minute timers. How can you be on time, but not early?

Answer: Use four of the timers. Start one, and when it goes off start another.

>
> 4) You want to jump up and startle the librarian in six minutes, but
> you only have a two-and-one-half-minute timer and a one-minute timer
> that explodes noisily after the second use. You know that the jig
> will be up if the timer explodes too early. The librarian is very
> pretty. What do you do?

Answer: Use the two-and-a-half-minute timer twice, then the one-minute timer
once. Then you can startle the librarian by yourself, you don't need the
explosion.

>
> 5) You have a shipment of gorillas that needs to be fed in an hour.
> You have three 1:01 timers, and a blowhorn that plays just flat of
> middle C. What do you do, keeping in mind the strict requirements of
> the contract you signed with the Cement Contracting Company last week?
>

Give the gorrillas the horn and go find a new job.



> 6) In one hour the world will crash into the moon. What in the world
> do you do?
>

Start an orgy in the middle of Disney World.


> 7) The window next to you opens and shuts once every seventeen years.
> You would like to leave the room through its only entrance, after
> being put inside three days before the moment of freedom. You only
> have with you a stick of length two meters (exactly), and an inchworm.
> How do you explain the metric system in time?

Why should you? No one else is in there with you, apparently, except for maybe
the inchworm, and the inchworm wouldn't get it anyway.


>
> 8) The woman sitting next to you knits three rows of wool in a minute.
> If the sweater you have you mind set on is nine feet long and red, why
> is she using white wool? How long are her knitting needles?

She is using white wool because she does not know you - someone else is knitting
your sweater. Her knitting needles are long enough to get the job done.

>
> 9) You want to bake a potato for four minutes. You have a 3-day timer
> with its hands removed and seven-hundred four minute timers. How many
> timers do you set?

All you HAVE to do is set ONE four-minute timer. But why be simple? Have fun and
set all seven-hundred four-minute timers at the same time!!!


>
> 10) You are driving down a one-way, one-lane highway, going about 115
> miles per hour. You are on an uphill slope. It is twilight, just
> before dawn, and the sky is streaked in the lower latitudes with deep
> purples and magentas. The sides of the road slope sharply down from
> the pavement. You are listening to Chuck Mangione on your new
> Blaupunkt stereo. You speed your car up to 130 mph. The road no
> longer has shoulders; to either side there is underbrush and rocks, on
> a hill that dives sharply down into the valley far below. The single
> lane narrows. You speed the car up to 145 miles per hour. The razor
> blade of a road you are on levels off, and then begins to angle
> downwards. The car begins to gain momentum. To either side, you can
> barely make out the ground dropping almost vertically away, just a few
> inches on either side of your spinning wheels. The downhill slope
> becomes more drastic as you light a cigarette and open your window a
> bit more.
>
> As the engine dies, you notice the radio and other accesories kick
> off and do not come back on again. The steering wheel comes off in
> your hand. You sit back and puff on your cigarette, wondering what
> life is all about. Question: Do you even TRY to see if the hazard
> lights work?

No. Just pray.


>
> --
> Stephan Zielinski szielins%dvl...@us.oracle.com
> Pyramid OSx & DC/OSx. Sequent DYNIX/ptx. IBM AIX. HP/UX. SGI IRIX.
> My brain hurts.

That was fun!! *grin*


---Little Miss Nitpick


---------------------------------------------------------------------------------
"Would you, could you, in Japan, with Godzilla and Rodan?"
-- Yakko, of the Warner Brothers
(and their sister, Dot)
---------------------------------------------------------------------------------

The Magic Friend

unread,
Oct 11, 1994, 6:22:20 PM10/11/94
to
John William Chambless (cham...@whale.st.usm.edu) wrote:
-> In article <37c6f0$o...@babyblue.cs.yale.edu>,
-> The Magic Friend <ma...@cs.yale.edu> wrote:
->
-> [ code Mark had posted earlier ]
->
-> ]>#include <stdio.h>
-> ]>
-> ]>void main(void) /* input 2 integers & xor them */
-> ]> {
-> ]> int i, j;
-> ]>
-> ]> scanf("%i %i", &i, &j);
-> ]> printf("%i\n", i^j);
-> ]> }
->

-> In four lines of code, you gave us one example of undefined behaviour
-> and one example of careless coding. Can you find them?
-> The careless coding can be overlooked, since it's just an example.
-> But undefined behaviour always sucks.

Sorry....

#include <stdio.h>
#include <unistd.h>

int main(void)
{
int i, j;

scanf("%i %i", &i, &j);
printf("%i\n", i^j);
exit(EXIT_SUCCESS);
}

Better? Or did you want the output in hex?

William J. Evans

unread,
Oct 11, 1994, 8:25:12 PM10/11/94
to
Smile (fr...@ccwf.cc.utexas.edu) wrote:
: That was fun!! *grin*

But didn't you get arrested at Disney World?

-- Captain Nitpick

John William Chambless

unread,
Oct 11, 1994, 10:54:52 AM10/11/94
to
In article <37c6f0$o...@babyblue.cs.yale.edu>,

The Magic Friend <ma...@cs.yale.edu> wrote:

[ code Mark had posted earlier ]

]>#include <stdio.h>
]>


]>void main(void) /* input 2 integers & xor them */

]> {
]> int i, j;


]>
]> scanf("%i %i", &i, &j);
]> printf("%i\n", i^j);

]> }


>Des Herriott (d...@mfltd.co.uk) wrote:
>
>-> Just what's this suppose to prove, apart from the fact that you
>-> can't even write a valid C program, and that you are indeed a
>-> clueless git?
>
>Let me add that what it proves is that COBOL is about as
>programming-time efficient as it is computationally efficient. It took
>me less than a minute to write my C code to do the job. How long did
>it take to write that monstrous COBOL routine?
>

For this example, you're right. There's no question that C is more
efficient than COBOL for this kind of stuff, both in coding time
AND execution time.

>Which is more readable? Which is more maintainable? Which is easier to
>debug?

The C code, of course.

Oh, yeah! Speaking of debugging, did you even wonder what Des was
talking about when he said you can't write valid C code?

In four lines of code, you gave us one example of undefined behaviour

and one example of careless coding. Can you find them?

The careless coding can be overlooked, since it's just an example.

But undefined behaviour always sucks.

I'd hate for some poor COBOL programmer, impressed by your brilliance,
decide to become an incompetent C programmer like you instead.
>


--
* Billy Chambless University of Southern Mississippi
* "IBM is not a necessary evil. IBM is not necessary." -- Ted Nelson

Des Herriott

unread,
Oct 12, 1994, 5:00:43 AM10/12/94
to
In article <37f36t$2...@babyblue.cs.yale.edu>,

The Magic Friend <ma...@cs.yale.edu> wrote:
>
> [ ... fixed C program deleted ... ]

>
>Better? Or did you want the output in hex?

Better. But next time you post one of your flames, at least have the
courtesy to know what you're talking about, or you'll just make a fool
of yourself. (Oh, sorry, too late)

By the way, there's no doubt that C is better than COBOL at performing
bitwise operations (such as XOR) but that doesn't make it a better
language per se. It's like comparing apples and oranges - the two
languages were designed for completely different purposes, and slamming
COBOL for its verbosity or it's inability to XOR in a single machine
instruction is utterly pointless. Maybe one day you'll realise this,
although I don't hold out much hope.

I'm a speaking as a C programmer here, by the way - just a C programmer
who lives in the real world (tm).

--
Des Herriott, Systems Programmer | d...@mfltd.co.uk
Micro Focus, Newbury UK. | +44 01635-565354

Shaun C. Murray

unread,
Oct 12, 1994, 9:37:39 AM10/12/94
to
Using Micro Focus COBOL ( of course ;-) )...

working-storage section.
01 source-item pic x(14) value "THIS IS A TEST".
01 target-item pic x(14) value "THIS IS A TEST".
01 xor-length pic x(4) comp-5 value 14.
procedure division.
call "CBL_XOR" using source-item
target-item
by value xor-length
end-call
stop run.

the XOR`d result ends up in target-item. I believe the original poster
wanted a check digit out of it so you`d probably want to only do one
character at a time using ref mod and keep a count or something.

simple enough?


Don Nelson

unread,
Oct 12, 1994, 12:49:50 PM10/12/94
to
In article <37gor3$h...@icebox.mfltd.co.uk> Shaun C. Murray,

In the next standard, it will as simple and won't rely on any one
vendor's non-standard extensions. You do something like this:

01 source-item PIC X(14) ...
01 source-item-r REDEFINES source-item PIC 1(112).
01 target-item PIC X(14) ...
01 target-item-r REDEFINES target-item PIC 1(112).
01 ind PIC 99 COMP.

PERFORM WITH TEST AFTER VARYING ind FROM 1 BY 8 UNTIL ind = 105
COMPUTE target-item-r (ind: 8) =
source-item-r (ind: 8) B-XOR target-item-r (ind: 8)
END-PERFORM

Don Nelson
COBOL Development, Tandem Computers, Inc.
Member, ANSI X3J4 and ISO/IEC JTC1/SC22 WG4 COBOL Committees
Project Editor, 1997 ISO COBOL Standard
Moderator, COBOL Conference, Bix
nelso...@tandem.com
do...@bix.com
No clever quotes here

Richard Ross-Langley

unread,
Oct 12, 1994, 6:49:21 PM10/12/94
to
In article <37c6f0$o...@babyblue.cs.yale.edu>
ma...@cs.yale.edu "The Magic Friend" writes:
> Newsgroups: alt.cobol,comp.lang.c,rec.humor
> Organization: Yale University Computer Science Dept., New Haven, CT 06520-2158
> Mark Lindner/SM 1851 (6-1851)

Mark Lindner -

Your comments are not humorous and, if anything, belong in
comp.lang.misc. Please do not cross-post to the other groups,
it wastes time, money and bandwidth.

To continue regardless, as you have been doing, is a breach
of Internet etiquette - the postmaster who controls your access
is also partly responsible for allowing this to continue.

--
Richard Ross-Langley <r...@minfo.demon.co.uk> +44(0)1727 852801
Mine of Information Ltd, PO BOX 1000, St Albans AL3 5NY, GB
=== Independent Computer Consultancy * Established in 1977 ===

The Magic Friend

unread,
Oct 13, 1994, 4:18:35 AM10/13/94
to
Richard Plinston (Richard_...@kcbbs.gen.nz) wrote:

-> But the C code, apart from giving undefined effects and being
-> non-standard, did not do the required job. Once again you throw
-> together a few flawed lines to try to 'prove' something, and all
-> you prove is that you cannot meet required specifications, nor
-> even write a correct program.

Just because I didn't explicitly have a return value doesn't mean the
program didn't do its job. It did. If you're such a lameo who cares
about these details, add the return(EXIT_SUCCESS); and change the
first line to int main(void). Regardless of that, it inputs two
numbers and XORs them, whether you want to admit it or not. Did you
try compiling the program and running it, or what evidence do you base
your narrow-minded claim on?

-> As for 'computationally efficient', did you not get my message
-> with the hailmary results where the Cobol version was faster than
-> the C, even though C was compiled with optimise on.

Please repost these "benchmarks;" I haven't seen them. I'd like to
see them. I'm sure there was something flawed in the comparison
(perhaps you used a C compiler written by Microsoft, for example). I
honestly can't believe that the 2 page long COBOL mess would be faster
than an application of C's XOR operator.

-> You are talking beyond your knowledge, [snip]

And certainly beyond yours as well.

Henrik Brameus

unread,
Oct 13, 1994, 4:23:14 AM10/13/94
to

Dear Mark,

I'm quite surprised that you don't do as you preach, but continue to post
this message to rec.humor. I suppose some editing in the followup-to are a
bit too much for you.

Cheers

Henrik
--
No .sig, I've given up smoking.

Maurizio Loreti

unread,
Oct 13, 1994, 5:32:34 AM10/13/94
to
In article <37iqgr$b...@babyblue.cs.yale.edu>, ma...@cs.yale.edu (The Magic Friend) writes:
> Just because I didn't explicitly have a return value doesn't mean the
> program didn't do its job. It did. If you're such a lameo who cares
> about these details, add the return(EXIT_SUCCESS); and change the
> ...

You post _this_ on comp.lang.c and expect not to be flamed :-) ?

> Did you
> try compiling the program and running it, or what evidence do you base
> your narrow-minded claim on?

Who wants to try a C program where integers are printf()'ed with %i ?
I don't care if it has been written by a magic-something, it is _crap_.

> ------------------------------------------------------------------------------
> ma...@suned.zoo.cs.yale.edu | more info may be found at:
> ma...@pmafire.inel.gov (summer) | http://zoo.cs.yale.edu:8000/~markl/home.html
> Mark Lindner/SM 1851 (6-1851) | finger ma...@zoo.cs.yale.edu
> ------------------------------------------------------------------------------

Maurizio Loreti http://mvxpd5.pd.infn.it/wwwcdf/mlo.html
Un. of Padova, Dept. of Physics - Padova, Italy lor...@padova.infn.it

The Magic Friend

unread,
Oct 13, 1994, 12:11:43 PM10/13/94
to
Maurizio Loreti (lor...@fnala.fnal.gov) wrote:

-> Who wants to try a C program where integers are printf()'ed with %i ?
-> I don't care if it has been written by a magic-something, it is _crap_.

What's the matter? Don't wanna run it cuz you're afraid it'll work?

--------------

The conversion characters and their meanings are:

d,i,o,p,u,x,X
The integer arg is converted to signed decimal (d
or i), unsigned octal (o), unsigned decimal (u) ...

--------------

It's a matter of taste. The word "integer" starts with "i" and not "d"
and therefore I like it better.

So what's your next argument going to be? The program was fairly
short, but I don't doubt you'll concoct another ridiculous complaint.
Like maybe my program is "crap" because I indent braces two spaces
from the left? Or maybe I should typecast the calls to scanf() and
printf() to (void) so that everyone knows I *meant* to ignore the
return value? Maybe I should put parentheses around i^j so that COBOL
programmers don't get it confused with the preceding comma?


Mark

Des Herriott

unread,
Oct 14, 1994, 5:18:18 AM10/14/94
to
In article <37iqgr$b...@babyblue.cs.yale.edu>,

The Magic Friend <ma...@cs.yale.edu> wrote:
>Richard Plinston (Richard_...@kcbbs.gen.nz) wrote:
>
>-> But the C code, apart from giving undefined effects and being
>-> non-standard, did not do the required job. Once again you throw
>-> together a few flawed lines to try to 'prove' something, and all
>-> you prove is that you cannot meet required specifications, nor
>-> even write a correct program.
>
>Just because I didn't explicitly have a return value doesn't mean the
>program didn't do its job. It did. If you're such a lameo who cares
>about these details, add the return(EXIT_SUCCESS); and change the
>first line to int main(void). Regardless of that, it inputs two
>numbers and XORs them, whether you want to admit it or not. Did you
>try compiling the program and running it, or what evidence do you base
>your narrow-minded claim on?

Wait a minute. Your original (broken) C XOR example was obviously
intended as an example of how concise C can be at operations of this
nature. But your code was a bit *too* concise, and in trying to
impress folks, you just ended up with a broken, non-standard piece
of code. Yes, it probably produces the right answer on *your*
machine, but there's absolutely no guarantee it'll work on every
machine.

(Oh, people who care about "details" like declaring main() properly,
and returning a value to the invocation environment are not "lameos",
they're C programmers. But I wouldn't expect you to understand that.)

Having seen your perl code, and your C code, and got a good idea
of your attitude, I can only say that it'll be a dumb employer who
ever gives you a job.

>-> As for 'computationally efficient', did you not get my message
>-> with the hailmary results where the Cobol version was faster than
>-> the C, even though C was compiled with optimise on.
>
>Please repost these "benchmarks;" I haven't seen them. I'd like to
>see them. I'm sure there was something flawed in the comparison
>(perhaps you used a C compiler written by Microsoft, for example). I
>honestly can't believe that the 2 page long COBOL mess would be faster
>than an application of C's XOR operator.

Duh! Richard was referring to the 'hailmary' program, not the XOR
example. Read before you blindly flame!

>-> You are talking beyond your knowledge, [snip]
>
>And certainly beyond yours as well.

ROTFL. What else can I say.

The Magic Friend

unread,
Oct 14, 1994, 7:47:44 AM10/14/94
to
Des Herriott (d...@mfltd.co.uk) wrote:

-> Wait a minute. Your original (broken) C XOR example was obviously
-> intended as an example of how concise C can be at operations of this
-> nature. But your code was a bit *too* concise, and in trying to
-> impress folks, you just ended up with a broken, non-standard piece

Not trying to impress folks. Anybody can write a C program to XOR two
numbers. Well, anybody except a COBOL "programmer."

-> of code. Yes, it probably produces the right answer on *your*
-> machine, but there's absolutely no guarantee it'll work on every
-> machine.

There's no guarantee that *anything* will work on every machine,
though I must say that most of the code I've written ports fairly
readily to operating systems I've never used before.

Too bad it might not work on your gold-plated 8088 with 32K RAM. Sorry
about that.

-> Having seen your perl code, and your C code, and got a good idea
-> of your attitude, I can only say that it'll be a dumb employer who
-> ever gives you a job.

You expect me to post production-ready code to illustrate simple
examples on a newsgroup full of losers? Heh. Take a reality pill,
cheeseball.

Show me some of your Perl code.

-> >-> As for 'computationally efficient', did you not get my message
-> >-> with the hailmary results where the Cobol version was faster than
-> >-> the C, even though C was compiled with optimise on.

-> Duh! Richard was referring to the 'hailmary' program, not the XOR
-> example. Read before you blindly flame!

Well then show me *those* benchmarks. The only thing that could
possibly slow down the C version is the allocation and deallocation of
stack frames for each call to Hailmary(). COBOL has a flat structure
and no notion of environment in the C/Pascal/Algol sense and thus
saves some time there.

--

Cheers!

Des Herriott

unread,
Oct 14, 1994, 8:36:58 AM10/14/94
to
In article <37lr50$2...@babyblue.cs.yale.edu>,

The Magic Friend <ma...@cs.yale.edu> wrote:
>-> Having seen your perl code, and your C code, and got a good idea
>-> of your attitude, I can only say that it'll be a dumb employer who
>-> ever gives you a job.
>
>You expect me to post production-ready code to illustrate simple
>examples on a newsgroup full of losers? Heh. Take a reality pill,
>cheeseball.

*plonk*

William J. Evans

unread,
Oct 13, 1994, 12:13:34 PM10/13/94
to
Richard Ross-Langley (r...@minfo.demon.co.uk) wrote:
: Mark Lindner -

: Your comments are not humorous and, if anything, belong in
: comp.lang.misc. Please do not cross-post to the other groups,
: it wastes time, money and bandwidth.

: To continue regardless, as you have been doing, is a breach
: of Internet etiquette - the postmaster who controls your access
: is also partly responsible for allowing this to continue.

Richard, this is rather difficult to say about rec.humor. Humor
means different things to different people. I think Mark's
posts are funny, now that he's mellowed out a little.

I would have posted this on rec.humor.d, but it reminded me of
so many people who _knew_ what wasn't funny and therefore
suitable for rec.humor, that I thought the whole thing was
funny.

Mark's postmaster is more concerned with mail bombing, forged messages,
and other law-and-order issues, not in becoming involved in fascist
judgments about what's funny and what's not funny.

--
Bill Evans (-- Captain Nitpick) Don't _ /| ACK!
P.O. Box 4829 make \'o_O' /
Irvine, CA 92716 Reply-To: lists =( )=
(714)551-2766 w...@acm.org .... U
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

John William Chambless

unread,
Oct 14, 1994, 2:08:23 PM10/14/94
to
In article <37lu1a$s...@icebox.mfltd.co.uk>,
Des Herriott <d...@mfltd.co.uk> wrote:

[ The Magic Wanker had written ]


>>You expect me to post production-ready code to illustrate simple
>>examples on a newsgroup full of losers? Heh. Take a reality pill,
>>cheeseball.

>*plonk*

"plonk"?

Is that the sound of _two_ "newsgroups full of losers" making a note
of a name-to-avoid for the next time they need to hire a programmer?


--
/* you are not expected to understand this */

JOSEPH I. TSATSKIN

unread,
Oct 14, 1994, 10:47:41 PM10/14/94
to
John William Chambless wrote on 14 Oct 1994 13:08:23 -0500:

>In article <37lu1a$s...@icebox.mfltd.co.uk>,
>Des Herriott <d...@mfltd.co.uk> wrote:

>[ The Magic Wanker had written ]
>>>You expect me to post production-ready code to illustrate simple
>>>examples on a newsgroup full of losers? Heh. Take a reality pill,
>>>cheeseball.

>>*plonk*

>"plonk"?

>Is that the sound of _two_ "newsgroups full of losers" making a note
>of a name-to-avoid for the next time they need to hire a programmer?

No, *plonk* is the sound of a clueless looser dropping to the bottom of
the killfile.
--
+--------------------------+-------------------------------------------+
| Joseph I. Tsatskin | jtsa...@netcom.com |
+--------------------------+-------------------------------------------+

Arjan Kenter

unread,
Oct 14, 1994, 3:37:50 PM10/14/94
to
In article <37jm7v$9...@babyblue.cs.yale.edu>, ma...@cs.yale.edu (The Magic Friend) writes:
> Maurizio Loreti (lor...@fnala.fnal.gov) wrote:
>
> -> Who wants to try a C program where integers are printf()'ed with %i ?
> -> I don't care if it has been written by a magic-something, it is _crap_.
>
> What's the matter? Don't wanna run it cuz you're afraid it'll work?
>
> The conversion characters and their meanings are:
>
> d,i,o,p,u,x,X
> The integer arg is converted to signed decimal (d
> or i), unsigned octal (o), unsigned decimal (u) ...
>
> It's a matter of taste. The word "integer" starts with "i" and not "d"
> and therefore I like it better.

You're right that %i is perfectly valid. Personally, though, I prefer %d
when I want my ints printed in _d_ecimal format. But as you say, it's a
matter of taste :-)

> So what's your next argument going to be? The program was fairly
> short, but I don't doubt you'll concoct another ridiculous complaint.
> Like maybe my program is "crap" because I indent braces two spaces
> from the left? Or maybe I should typecast the calls to scanf() and
> printf() to (void) so that everyone knows I *meant* to ignore the
> return value?

Close: you should check the result from scanf()! I think this is the
point of "carelessness" an earlier poster threw in. Input from human
beings should never be trusted (well, actually, input that was generated
by other programs ought to be checked, too, since those programs were
written by humans, or the programs that generated those programs; in
the end it all comes down to us, mortals. *We* make mistakes, so we
should safeguard our programs from ourselves.)

> Maybe I should put parentheses around i^j so that COBOL
> programmers don't get it confused with the preceding comma?

Might be good advice ;-)

Arjan Kenter

unread,
Oct 14, 1994, 3:41:53 PM10/14/94
to
In article <37lr50$2...@babyblue.cs.yale.edu>, ma...@cs.yale.edu (The Magic Friend) writes:
> Des Herriott (d...@mfltd.co.uk) wrote:
[ warning: apparently some attribs have been lost ]

> -> >-> As for 'computationally efficient', did you not get my message
> -> >-> with the hailmary results where the Cobol version was faster than
> -> >-> the C, even though C was compiled with optimise on.
>
> -> Duh! Richard was referring to the 'hailmary' program, not the XOR
> -> example. Read before you blindly flame!
>
> Well then show me *those* benchmarks. The only thing that could
> possibly slow down the C version is the allocation and deallocation of
> stack frames for each call to Hailmary(). COBOL has a flat structure
> and no notion of environment in the C/Pascal/Algol sense and thus
> saves some time there.

Don't forget the overhead in printf()'s processing of the format string.

KMAN...@bcsc02.gov.bc.ca

unread,
Oct 15, 1994, 12:41:02 AM10/15/94
to
In article <37mmme$f...@utis084.cs.utwente.nl>

ken...@cs.utwente.nl (Arjan Kenter) writes:
>In article <37jm7v$9...@babyblue.cs.yale.edu>, ma...@cs.yale.edu (The Magic
>Friend) writes:
>> So what's your next argument going to be? The program was fairly
>> short, but I don't doubt you'll concoct another ridiculous complaint.
>> Like maybe my program is "crap" because I indent braces two spaces
>> from the left? Or maybe I should typecast the calls to scanf() and
>> printf() to (void) so that everyone knows I *meant* to ignore the
>> return value?
>
>Close: you should check the result from scanf()! I think this is the
>point of "carelessness" an earlier poster threw in. Input from human

A guy named Brian Kernighan who was at UVic this week gave a series
of talks which included one on programming style in C. He seemed to
be quite put off by scanf, saying that it had risks in common with
something done by a person named Robert Morris with gets. Kernighan
said that gets has been deleted from the libraries where he works
and that he only uses scanf with great caution.

Magic Friend also used & expressions at the right side of a function
call where the same variables were also used in parms appearing to
the left of the & expression. Kernighan pointed out that the order
of function parm evaluation is undefined in C. It may be left to right,
right to left, or whatever the compiler decides is optimal. Magic may
not have ended up trying to evaluate addresses before they exist this
time, but I'll bet that this pattern shows up in his code a lot and
that it isn't quite as portable as he imagines it to be.

Perhaps our Magic Friend should read The Elements of Programming Style.

Kernighan remarked that it is important to get it right before you
get it fast. Magic seems to have the contrary view. This comment
is also applicable to the side debate about assembler vs compilers.

Kernighan's advice not to sacrifice clarity in the quest for
conciseness seems very applicable to Magic's fascination with 1 liners.

Kernighan also observed that if someone really outdoes themself
working at their limit to produce cute code then by definition they
aren't smart enough to debug it.

By the way, although I've had a copy of K&R for the better part of a
decade I've never found any jobs around here programming in C that
paid me nearly enough to pay off my mortgage by the time I was 35.
On the other hand the job I got out of University in the late 70s
that required me to learn COBOL, write programs in it, and port them
to 4 different IBM machines(3 IBM OSs) and a couple of Honeywell's
did exactly that. This weekend I'll get my first hands on with an
IBM 9762 highly parallel machine, which may give MVS and the associated
legacy what they need to go head to head with unix/c workstations.

Magic may discover that the qualities that make a good programmer
who can find and keep well paying jobs, have little to do with what
language he knows, and a lot more to do with generic qualities of mind.

Magic also inquired about programming disasters in C++. Sanctuary Woods
here seems to be in major financial grief. One of their head programmers
told a spring meeting of IEEE Victoria Section that they gave up on C++
after finding out that it was impossible to combine separately developed
components because the developers of the various components had created
incompatible code. This was several months ago so the details are vague
but I think that it had something to do with language extenstions.

The Magic Friend

unread,
Oct 15, 1994, 8:40:12 AM10/15/94
to
KMAN...@bcsc02.gov.bc.ca wrote:

-> A guy named Brian Kernighan who was at UVic this week gave a series
-> of talks which included one on programming style in C. He seemed to
-> be quite put off by scanf, saying that it had risks in common with
-> something done by a person named Robert Morris with gets. Kernighan
-> said that gets has been deleted from the libraries where he works
-> and that he only uses scanf with great caution.

What alternative does he propose for someone who just quickly wants to
read in two integers for the point of making a demonstration? Sure I
have my own input routines that address the issues of memory leaks and
buffer overflow, but for a simple example, I don't really *care.*

-> Magic Friend also used & expressions at the right side of a function
-> call where the same variables were also used in parms appearing to
-> the left of the & expression.

*What?* I'm afraid I don't understand the statement, most likely
because it makes no sense. I'm passing two integer pointers to scanf,
in this case pointers which point to allocated integers. These are not
interrelated, and thus the evaluation order doesn't matter. It has
nothing to do with "evaluating addresses before they exist" which is
in itself a meaningless statement. I think you meant 'dereferencing an
invalid pointer' which doesn't happen in the program in question.

-> Kernighan pointed out that the order
-> of function parm evaluation is undefined in C. It may be left to right,
-> right to left, or whatever the compiler decides is optimal.

Wow? Really? <smack> I'm afraid I already knew that, but thanks for
the refresher course.

-> Magic may
-> not have ended up trying to evaluate addresses before they exist this
-> time, but I'll bet that this pattern shows up in his code a lot and
^^^^^^^^

Never play Poker, buddy.

-> Perhaps our Magic Friend should read The Elements of Programming Style.

Perhaps you should learn C, cuz obviously you don't know what the hell
you're talking about.

-> Kernighan remarked that it is important to get it right before you
-> get it fast. Magic seems to have the contrary view. This comment
-> is also applicable to the side debate about assembler vs compilers.

You're a total *IDIOT.* I wasn't writing an operating system kernel! I was
demonstrating the use of the XOR operator. GET THAT THROUGH YOUR IDIOT HEAD!

-> Kernighan's advice not to sacrifice clarity in the quest for
-> conciseness seems very applicable to Magic's fascination with 1 liners.

Clarity? How can you make my program any more clear? Turn it into a
bloated sloppy mess like the typical COBOL program?

-> Kernighan also observed that if someone really outdoes themself
-> working at their limit to produce cute code then by definition they
-> aren't smart enough to debug it.

As if I spent hours tinkering on that two-liner just to impress you! <smack>

-> Magic also inquired about programming disasters in C++.

I did? That's news to me.


Cheers!
Mark

------------------------------------------------------------------------------
ma...@zoo.cs.yale.edu | http://zoo.cs.yale.edu:8000/~markl/home.html
Mark Lindner / SM 1851 | finger ma...@zoo.cs.yale.edu
------------------------------------------------------------------------------

0 new messages