Implementing strstr

T

Tim Streater

spinoza1111 said:
What's wrong with truth? The problem is the authorized replacement of
the will to a collective truth by the celebration of a power which
only one person will get, and news flash: because none of you losers
will get any real power, you're damned fools for not rededicating
yourself to truth.

The truth of structured programming is that you can construct complex
devices in an understandable way with simple elements, scaling up.
"Power" has nothing to do with this. "Power" is getting other people
and machines to do your bidding against their will, and a gentleman is
bored with this type of "power".

Clap, clap. Another content-free post from Spinny. Tell me, have you
always had attention deficit disorder?
 
S

Seebs

I think Nilges' response is reminder enough :

Yeah, pretty much.

This seems to be pretty much par for the course. It's entirely possible
that in some of his attempts to open a private channel, he used more
temperate language... But he has never, at any point, done anything
involving me that did not lead immediately to, if I showed any sign
of thinking he was anything but batshit insane, asserting that the right
thing for me to do is remove my page about C:TCR.

Why?

Because that page is why the Wikipedia people finally said "no, there isn't
any more citation needed for the thing saying Schildt's writings are not
well regarded among the technical community."

I would dearly love to know the *actual* reasons for which Nilges is so
incredibly obsessive on this topic. Did he get fired from a job for owning
a Schildt book, or for something he did which relied on information he
derived from one of Schildt's books? Did he lose some political battle
in which the ostensible subject was something to do with the stack, which
seems to be a particular point of obsession? I have no idea, but I've
always been curious. The reasons Nilges provides are consistently obviously
fake -- the mere fact that he switches from one to another with no hiccups
as soon as he realizes a given one won't play with a particular audience
makes it clear that they're all just excuses and rationalizations.

I'd love to know the real reason.

.... The interesting thing, BTW, is that I've been having multiple fascinating
discussions with people who disagree with me, while Nilges is the one who
calls someone an "asshole" for correcting him, then insists that he's not
being insulting.
Seebach displayed a saintly restraint in his responses to Nilges'
paranoid accusations for months before filtering him out.

I responded to him about twice before concluding that he was good only
for laughs. That said, there's a substantial point here -- Nilges has
never figured out how to view the entirety of long posts through Google
Groups, so far as I can tell, so substantive questions which are near
the end of a longish post are invisible to him. (This is why you sometimes
see Google's text for "and there's more to this post" quoted in his
replies.)

But I have no interest in privately communicating with someone who appears
to habitually lie about what he or other people said. I'd rather keep
the record out in the open. Not because this will prevent him from
blatantly misrepresenting things, but because it will prevent him from
fooling anyone*.

-s
[*] Obviously, Kenny is taken in by anything anyone writes which criticizes
people he considers "regs", but I don't think that counts.
 
S

Seebs

Clap, clap. Another content-free post from Spinny. Tell me, have you
always had attention deficit disorder?

I would point out that his behavior is not particularly consistent with
attention deficit disorder. What he's showing is much too specialized;
he only loses interest in things when it starts looking like it won't make
him look good. His babbling about structured programming looked like a
great way to assert dominance over poor lil' uneducated me, but he forgot
that there are other posters here, some of whom have done a lot of formal
study of computer science. :)

-s
 
W

Willem

Seebs wrote:
)> Clap, clap. Another content-free post from Spinny. Tell me, have you
)> always had attention deficit disorder?
)
) I would point out that his behavior is not particularly consistent with
) attention deficit disorder. What he's showing is much too specialized;
) he only loses interest in things when it starts looking like it won't make
) him look good. His babbling about structured programming looked like a
) great way to assert dominance over poor lil' uneducated me, but he forgot
) that there are other posters here, some of whom have done a lot of formal
) study of computer science. :)

Narcissism perhaps ? I think that term came up before in this froup.


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
 
T

Tim Streater

Seebs said:
I would point out that his behavior is not particularly consistent with
attention deficit disorder.

Yes, quite possibly. What I was observing was his inability to respond
in a way that is germane to the issue.
 
B

blmblm

[ snip ]
No, I stopped there, and said, this guy is doing TOO MUCH unnecessary
copying. Like I said, I'm having fun and will find at this rate many
more problems, some of which have already been found by Ben.

If you think you've invented a clever new algorithm for strstr...well,
aux d'autres, ma vielle. While I'm not through with your crap code,
and expect to find many new gems of idiocy, you don't copy bytes to do
a strstr.

Correct -- he doesn't. (The copying takes place in the *test harness*,
where there appears to be at least a marginally good reason for it.)

[ snip ]
 
B

blmblm

[ snip ]
A new excuse for poor workmanship!

I'm not up to speed on Linux: but for some time on .Net we've known
all about just in time compilation.

How does that solve the problem Seebs mentions? JIT compilation
works pretty well for longish programs, where the time cost of
the compilation is small compared to the overall running time.
For short programs, however, my experience [*] is that precompiled
code can be noticeably faster.

[*] Comparing C code (compiled with gcc and optimization) with Java
(compiled to byte code and run with a runtime system that *supposedly*
does JIT compilation).
Most "script interpreters" have APIs to circumvent the "loading" time.

Maybe I'm overlooking something obvious here, but I'm not imagining
how this is possible. I mean, either the code is interpreted,
or it's compiled at *some* point, either as part of startup cost
or -- what?
Furthermore, I'd have to ask why you are replacing a pattern in a
directory "hundreds of thousands of times". You see, in any reasonable
scenario, that pattern is a device for the user to abstract the name.
I think this is therefore an instance of incredibly poor workmanship,
in which you are REPEATEDLY changing %s (and any other %c pattern, at
least in the first version) in the same places and in the same string
because all other evidence (off by one strlen, reversal of conditions,
and your queue.c horror) shows you don't know your job.

[ snip ]
 
B

blmblm

[ snip ]
Which is fine. But in the case of ack and nak in queue.c, you
fallthrough over code which at the time you wrote it contains no valid
case handling, but could easily be changed by someone who doesn't
realize that ack and nak are invalid for the client, as you say you
state in the documentation. The implicit rule is that the maintainer
may NOT put actually valid cases under ack and nak!
The reason why we avoid unstructured code (which is what a fallthrough
switch() is, being irreducible to the Bohm Jacopini primitives unlike
other switch() statements

I must be misunderstanding something, because I thought the point of
those primitives was that any program could be expressed using them.
If that's the case, surely any program, even an ill-structured one [*],
can be so expressed? What does "irreducible" mean in context?

You are misunderstanding something.

And the subsequent discussion does not clear up the misunderstanding.
Ah well. No surprise, I guess.
Sure, nothing's "irreducible"
since any unstructured program can be automatically structured (that
results from Turing equivalence). But as I indicate elsethread,
Dijkstra, like Confucius, was looking for the type of person who would
prefer not to be unstructured even as Confucius looked for the
gentleman, and would grow out of wanting to fall through, as I did in
1972 at the ripe age of 22.

His "elegance" was a moral category which recognized that the ultimate
source of value is the Other Person, Levinas, "the other whose face is
the face of God removed from the world", the other who people so
readily call a "troll" (where becoming familiar with the particular
other's personality and actual skills and lack of decency towards
others, and calling him a fraudulent motherfucker, is quite
different).

Because for Dijkstra people and their human culture is infinitely more
important that machines or software, programming is the moral act of
documenting precisely your intentions as to use a computer to an
Other.

Anyone who would prefer to be cute and write a fallthrough case
because he think's its cute and shows that he should be writing OS
code and not scripts is a cad on this account, and because, as TW
Adorno showed, "intelligence is a moral category", a stupid cad.
[*] Not that I necessarily think the code in question is ill-structured.

Oh we must be "objective". I'm afraid that Adorno showed that being
"objective" for low level people in an administered world, which is
what we are, which is what you are, is to be blinded as were Odysseus'
men to most of reality. The code is ill-structured, dear heart.

I find this usage of "dear heart" rather patronizing. Just sayin'.

And I have *NO* idea what my comment has to do with being
objective. I was attempting to avoid giving the impression that
I agreed with your assessment of Seebs's code as ill-structured.
As is true for any number of subjects, I don't really have an
opinion about that one way or another.

(It occurs to me to wonder, by the way, why we're having this
discussion of Seebs's code in threads other than the one in which
he posted the URL for it. But, you know -- whatever.)

[ snip ]
 
B

blmblm

Hey, B. L. Barneby, why don't you get a clue?

"Barneby"?
What exactly are you
trying to extract from spinoza? By republishing his nonsense, you
just lure weak-willed saps to respond indirectly, and further pollute
this newsgroup. If you somehow get something out of reading his
tripe, then I suggest you check the archives; you'll find enough to
keep you pacified for a year or two. If you simply can't resist
taking your little shots at spinoza, then I suggest sticking to email
(CC Seebs if you like).

Your opinion is duly noted and will probably result in fewer responses
from me. However, sometimes he raises a somewhat-on-topic question
to which I would like an answer as well, and other times the temptation
to reply to some particular casting of aspersions is too much.
 
B

blmblm

[ snip ]
This pompous statement, while true, has nothing whatsoever to do with,
and in no way dignifies, Dweebach's code. I doubt that anyone here
besides myself, Willem, and perhaps you have ever done anything like a
"rigorous proof".

I strongly suspect that you are wrong about that, though I suppose it
might depend on what you mean by "rigorous proof".

If you include purely-mathematical (i.e., non-CS) proofs, then that
would seem to imply that no one else here has much in the way of
mathematical training, which I strongly suspect is not true. To name
the first example (other than myself [*]) who comes to mind, Ben
Bacarisse comes across, to me anyway, as someone who knows some math.

[*] And I am just not going to engage in some sort of competitive
brandishing of educational credentials.

If you mean that the proofs in question have to have something
to do with CS, well, still you would seem to be implying that no
one else here has taken the sort of CS course in which proofs are
required, and that also seems to me to be a pretty strong claim,
one unlikely to be true.

[ snip ]
 
S

Seebs

Narcissism perhaps ? I think that term came up before in this froup.

Obviously, it would be impossible to perform a proper clinical diagnosis
over the internet, but:

* Exaggerated sense of own skills and accomplishments -- tends to believe
self substantially better-qualified than other people.
* Proudly claims about connections to people whose contributions are more
widely recognized, such as famous experts or Nobel prize winners.
* Theorizes that all lack of recognition of his superior qualities is due
to conspiracies or jealousy among obviously-inferior people.
* Invents idiosyncratic standards to show that other people are not "special".
* Regards any correction or criticism as a personal attack.
* Attacks people with unusual ferocity, then turns around and treats them
normally the next day; doesn't see anything wrong with this.

Basically, yeah, he sweeps the category. The thing where he'll totally lose
it and spew obscenities at someone, then treat them nicely the next day when
he thinks they have something he wants, is pretty much stereotypical; he
doesn't show any signs of having an awareness of other people except in terms
of how they presently are useful to him or failing to meet his needs.
Similarly, the obsessive trolling seems to be a classic way to try to obtain
narcissistic supply.

The kindest thing to do is probably to completely ignore him. It won't
actually help, but it may slow the decay down some. With one exception
(a guy with a badly-formatted but very insightful page on "malignant
self-love"), most therapists view clinical narcissism as very close to
untreatable, because fundamentally, you can't treat a mental disorder when
the patient cannot conceive of any form of acceptable life not rooted in
that set of behaviors.

.... Relevance to comp.lang.c, you ask? If we want the group to be useful,
we have to recognize that we have a Grade A Troll, and we're going to have
to develop coping strategies. Go look at what happened to soc.religion.quaker
to see why -- the group has essentially no content but an extreme narcissist
and a few people who obsessively attack his posts on the off chance that
anyone doesn't realize he's full of crap.

-s
 
S

Seebs

Yes, quite possibly. What I was observing was his inability to respond
in a way that is germane to the issue.

True.

Well, consider. His actual claim was stupid. He can't win it. Since he
can't use it to make himself look good, there's no reason for him to respond
to it.

-s
 
S

Seebs

Where on earth did I suggest anything of the sort?

I'd guess that my algorithm is extremely similar to the one in BSD
libc. Maybe slightly more complicated with the attempt to stash
the next location worth checking.
Correct -- he doesn't. (The copying takes place in the *test harness*,
where there appears to be at least a marginally good reason for it.)

Yeah.

I think I see the problem: I picked the name "my_strstr()" for my strstr()
implementation, and "test_strstr()" for the function which tests a strstr()
implementation by comparing its results to those of the library one.

I'm guessing that, with his typical complete inattention to detail, Nilges
just saw a function named "something_strstr()" with two arguments and assumed
that it was my implementation. I sometimes forget just how far below the
norm his reading comprehension is when it comes to code. I had not realized
until just now that his behavior actually made sense if you assumed a mistake
that was actually stunningly incomprehensible, rather than merely laughable.

-s
 
S

Seebs

How does that solve the problem Seebs mentions?

It doesn't.

But in his defense, I don't think he has any comprehension of Unix-like
environments. The big difference (only marginally topical, but bear with
me) is that Unix-like environments have INCREDIBLY low cost of process
spawning compared to Windows. So Windows systems tend to evolve large
programs which run for a long time, Unix systems tend to evolve tiny programs
which run often.
Maybe I'm overlooking something obvious here, but I'm not imagining
how this is possible. I mean, either the code is interpreted,
or it's compiled at *some* point, either as part of startup cost
or -- what?

Well, a typical thing would be, say you want to run the same script hundreds
of times, you'd load the script once and then execute it hundreds of times.
(This is how any performance-oriented implementation of Ruby on Rails will
do it, for instance.)

Why, yes.

I'm not particularly sure the design was a good one, but I wasn't asked
for an opinion on that, merely presented with a very specific problem
and asked to make it work.

The scenario is as follows: We maintain a build system in which a number
of components are built once on a single machine and then shared out to
many other machines. Possibly stored in different locations on each machine.
There is a tool which, at build time, compiles in particular paths that
it will use for certain lookups. (It is beyond the scope of our project
to change this tool.) To run a prebuilt version of this tool on another
machine, you need to override that. You can override that by finding out
what directory the program is *actually* installed in, and shoving certain
values into the environment to override the compiled-in values.

So the task at hand was: Build a program which figures out the path it
lives in, then alters particular path values to contain that path (instead
of some other path), and put those path values into the environment.

This is done every time that other tool gets invoked, and that other tool
gets invoked hundreds of thousands of times. We can't do it by modifying
the binary of the other tool, as multiple systems could be sharing a single
binary copy of that other tool, but mounting it in different paths, so the
path computation has to be done "live".

As is usually the case, Nilges has chosen to invent a theory of what would
have been happening had I been an idiot, rather than asking questions to find
out what the circumstances were. :)

-s
 
S

Seebs

If you include purely-mathematical (i.e., non-CS) proofs, then that
would seem to imply that no one else here has much in the way of
mathematical training, which I strongly suspect is not true.

It seems deeply implausible to me. Both of my parents taught college
mathematics, and I retain to this day an instinctive distrust of empirical
methods as unreliable and shoddy.

-s
 
K

Keith Thompson

(It occurs to me to wonder, by the way, why we're having this
discussion of Seebs's code in threads other than the one in which
he posted the URL for it. But, you know -- whatever.)

It's at least partly because *you* keep discussing it with him.
 
C

Colonel Harlan Sanders

I would dearly love to know the *actual* reasons for which Nilges is so
incredibly obsessive on this topic. Did he get fired from a job for owning
a Schildt book, or for something he did which relied on information he
derived from one of Schildt's books? Did he lose some political battle
in which the ostensible subject was something to do with the stack, which
seems to be a particular point of obsession? I have no idea, but I've
always been curious. The reasons Nilges provides are consistently obviously
fake -- the mere fact that he switches from one to another with no hiccups
as soon as he realizes a given one won't play with a particular audience
makes it clear that they're all just excuses and rationalizations.

I'd love to know the real reason.


My guess (we'll never know the "real" reason) based on some hints in
various posts, is that he was pontificating in a programming
newsgroup about 10 years ago and Heathfield contradicted/corrected or
otherwise bruised his ego. So he set out to "take him down" As he is
now trying to do with you. At some point of this Schildt's name came
up, and Heathfield disparaged him or his book. And so Nilges took the
opposite tack..... He has been sparring with Heathfield ever since.

A year or so ago, Nilges discovers Wikipedia, and Schildt's page
therein. He decides that this is all part of the conspiracy. The
criticisms of Schildt there cite you and Feather, and his attempts to
delete this are reversed, over and over. He decides you're the
instigator of the conspiracy, and attacks you both here.....

But behind all that, he sees you as a symbol of Korporate Amerikka,
which has rejected him, despite his obvious genius, as they're all
jealous of his ability to write poetry and run marathons while coding
in assembly on his laptop. Since you get paid to program, while he can
only do it as a hobby, you remind him of his failure. So you must be
destroyed.

Well, it's a bit more plausible than Nilges' conspiracy theories, at
least.
 
S

Seebs

My guess (we'll never know the "real" reason) based on some hints in
various posts, is that he was pontificating in a programming
newsgroup about 10 years ago and Heathfield contradicted/corrected or
otherwise bruised his ego. So he set out to "take him down" As he is
now trying to do with you. At some point of this Schildt's name came
up, and Heathfield disparaged him or his book. And so Nilges took the
opposite tack..... He has been sparring with Heathfield ever since.

This is plausible. He's certainly very consistent in adopting the opposite
of anything someone he dislikes says, without any regard to whether the
resulting position is consistent with his other claims.
Since you get paid to program, while he can
only do it as a hobby, you remind him of his failure. So you must be
destroyed.

This would explain his obsession with claiming that I don't program, and
then his revised obsession with claiming that I do it very badly.

Thanks. That makes a lot more sense. Also, now that I've found out that
he's not just *a* usenet kook, but *the* Usenet kook (hint: He's part
of the events from which we got "Godwin's Law"), up there in the company
of people like Archimedes Plutonium, I'm a lot more ready to accept that
his behavior is comprehensible. Loosely speaking.

-s
 
T

Tim Streater

Seebs said:
True.

Well, consider. His actual claim was stupid. He can't win it. Since he
can't use it to make himself look good, there's no reason for him to respond
to it.


I know, I know. I shouldn't do it really. I picture an 18th century me,
with powdered wig and dressed like a fop, visiting Bedlam and seeing
Spinny behind bars, drooling. Very unkindly I then poke him with a
pointed stick.
 
S

spinoza1111

It doesn't.

But in his defense, I don't think he has any comprehension of Unix-like
environments.  The big difference (only marginally topical, but bear with
me) is that Unix-like environments have INCREDIBLY low cost of process
spawning compared to Windows.  So Windows systems tend to evolve large
programs which run for a long time, Unix systems tend to evolve tiny programs
which run often.

And this excuses an incorrect program how?
Well, a typical thing would be, say you want to run the same script hundreds
of times, you'd load the script once and then execute it hundreds of times.
(This is how any performance-oriented implementation of Ruby on Rails will
do it, for instance.)

(Yawn) Terminate and stay resident IS, unlike the heap, an MS-DOS term
from way back, and there's nothing special with it here.

And this excuses an incorrect program how?

Why, yes.

Hold that thought
I'm not particularly sure the design was a good one, but I wasn't asked
for an opinion on that, merely presented with a very specific problem
and asked to make it work.

"I was only following orders, so my code sucks". Nuremburg defense is
not allowed here, Hermann.
The scenario is as follows:  We maintain a build system in which a number
of components are built once on a single machine and then shared out to
many other machines.  Possibly stored in different locations on each machine.
There is a tool which, at build time, compiles in particular paths that
it will use for certain lookups.  (It is beyond the scope of our project
to change this tool.)  To run a prebuilt version of this tool on another
machine, you need to override that.  You can override that by finding out
what directory the program is *actually* installed in, and shoving certain
values into the environment to override the compiled-in values.

I created a compiler build system. Fortunately, I was able to rewrite
anything I wanted. These constraints "it is beyond the scope" are mind-
forg'd manacles.

However, I don't think you should rewrite anything until you've
completed first year computer science.

So the task at hand was:  Build a program which figures out the path it
lives in, then alters particular path values to contain that path (instead
of some other path), and put those path values into the environment.

This is done every time that other tool gets invoked, and that other tool
gets invoked hundreds of thousands of times.  We can't do it by modifying
the binary of the other tool, as multiple systems could be sharing a single
binary copy of that other tool, but mounting it in different paths, so the
path computation has to be done "live".

As is usually the case, Nilges has chosen to invent a theory of what would
have been happening had I been an idiot, rather than asking questions to find
out what the circumstances were.  :)

Incompetent programmers like to be asked questions: it makes them feel
important. Nothing wrong with that. I felt important when important
faculty at Princeton (and Nash) asked me questions.

However, I get a sense here that you're working in The Ass End of a
Botched Situation, created by the nonexistence of people in your work
group competent to change what seems to be the path compiler.

Sure, if the "path compiler" (if that's an accurate description)
generates only %s, then % is a sufficient condition in your idiomatic
situation.

But why post this code?

The situation in which you wrote it is barbaric. Basically, a complex
piece of code (the "path compiler") was written offsite but your
employer, as usual, is too cheap to retain the best programmers to
maintain it, perhaps for the same reason Bell Northern Research
destroyed its compiler group in 1980.

The code if correct in your environment was not in any way exemplary.

Commencing with the election of Reagan, in programming, a deliberate
Kulturkampf was conducted against retaining senior and qualified
programmers and the result? People without computer science education
are hired but not given ability to change things, and develop ugly,
idiomatic approaches. When they see good code they think it's the
worst.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,104
Messages
2,570,643
Members
47,246
Latest member
rangas

Latest Threads

Top