Have you considered supplying this to the daily WTF?
Lemme tell you, there is a sense of vindication from seeing some
godawful thing you got stuck messing with on the front page there.
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I've dealt with... code... like that. I don't know what language the
author thought she was writing in, but she didn't know Perl at all,
though had managed to find just enough of the weird stuff to be truly
dangerous.
sub some_sub {
# Arguments with spaces don't work, I don't know why
my(@args)=split(/\s/,"@_");
...
--
"I thought everyone in [TO] ... jumped off the Bloor Street Viaduct? Or
was your Mom a nonconformist?" -- adb about my mother in the Monastery.
"Well, of course she was. Just because everyone *else's* Mom was jumping
off the Bloor Street Viaduct, should *she*?" -- Jonathan's witty retort.
> I'm looking at a "library" I should use to interact with some piece of
> equipment. The 'library' is written in perl. That's good. However it has
> been written by someone that was obviously more accustomed to write in
> PHP. And that's bad.
>
> Some random bits I found in this thing:
>
> sub prompt_processing_crap()
> {
> my ( $prompt1,
> $prompt2,
> $self,
> );
>
> if ( 0 )
> {
> # lots of code
> }
>
> # return 0;
> return $prompt1;
> }
Well, it does say "prompt", and I have no doubt that it finishes promptly.
Why it is pretending to be an object, on the other hand, shall remain a
mystery.
>
> ...
>
> sub get_p
> {
> #this doesn't work
> return 0;
> }
Well, if it is supposed to return 1, then the comment is completely
correct!
>
> sub get_p_work
> {
> ...
> if( $i ) {
> return $i;
> } else {
> return $i;
> }
> }
When you absolutely, positively, have to return $i.
> ...
>
>
> And the incredible thing is all this somehow kind-of does what it's
> supposed to do!
Because half of the WTF code cancels out the WTF of the other half of the
code.
> I'm so glad I'd already decided to junk it and write my own...
Because if you were to try to correct the existing code, once you find a
WTF and fix it, you then have to hunt down and kill all the WTFs which
rely on the original WTF's behaviour to function. Then the WTFs which
rely on them, and so on to infinity.
--
David Cameron Staples | staples AT unimelb DOT edu DOT au
Melbourne University | School of Engineering | IT Support
mac is god compared to microsoft
and linux is the science that disproves god's existence -- bash.org/?47127
If I submitted every bit of Perl that made me shake my head and immediately
want to get drunk to numb the pain, I'd be on the front page every day.
> Lemme tell you, there is a sense of vindication from seeing some godawful
> thing you got stuck messing with on the front page there.
I've recently seen a trading platform written in Perl. All of a sudden, I've
started considering investing in guns and corned beef.
Hmm. Five past noon. I think that's late enough in the day to be
hitting the whiskey, right?
--
Regards,
Ben A L Jemmett.
http://flatpack.microwavepizza.co.uk/
The sun's *always* over the yardarm _somewhere_.
--
" ... a language is just an dialect with an army and a navy."
-- written by someone very perceptive,
used by Paul Tomblin in a.s.r.
The sun is always over the yardarm somewhere.
- Brian
"You can write Fortran in any language."
And, as I believe someone in this august froup once remarked, if you
have a decommissioned sparc and a trebuchet, the Sun is over the yardarm
whenever you want it to be.
Indeed.
And with a sufficiently large[1] trebuchet, just about _any_ Sun can be
over the yardarm whenever you want it to be.
[1] I remember an NPR piece on a Brit who builds trebs; he threw a
600-pound pig carcass some hundreds of yards, evoking from the
NPR reporter a comment that "the pig flies well". He also used his
biggest treb to toss pianos (decommissioned) and Morris Minors
(ditto).
--
It is a source of much embarassment to me that I was distracted
by a combination of Usenet, Western European history, and writing
instead of wine, women and song.
-- Matt McLeod, in the Monastery
I seem to recall a company dropping a large Sun server (E10K, I think)
from a helicopter somewhere in .se 4-5 years ago, as a publicity stunt
when they decided to phase their Suns out (they'd had a lot of trouble
with them). Unfortunately I can't find any references to it now.
And of course the sigmonster picks out an even more deserving victim...
Niklas
--
We've got a SCO box which we've had no complaints over. No maintenance
hassles either.
We might get around to switching it on one day.
-- Peter Gutmann
>He also used his biggest treb to toss pianos (decommissioned) and
>Morris Minors (ditto).
If the former was tossed onto the latter, would it be A Flat Minor?
That's a pretty sharp comment.
--
1 Bryant (B) = 4577 books; 1 Ha'bryant = 2289 books
1 Sitter (or Room) = 1104 books; 1 Dinky = 161 books
1 Wallshelf = 23 books; 1 Bedside = 17 books
-- Robert Uhl, in asr
It could have been accidental...
Well, naturally!
We better stop this cascade before we get into treble.
--
Kenneth Brody
What, you mean this bottle *glug* here that I picked up at the Duty
Free on the way back home?
It's never too soon....
--
"I'm not crazy! My mother had me tested!"
-- Sheldon Cooper
Considering how this group normally behaves, I think that accusation
is a bass libel.
Note: The spelling in the above was carefully measured, which bears
repeating. Anyway, it's only a small cascade; it's not as though there's
a problem of scale, and if there are any problems, surely someone can
beat the servers into submission. Or, at that point, we can give it
a rest. Perhaps we could come up with a variety of favorite whiskeys
and have a circle of fifths?
-s
p.s.: Anyway, no one would dare complain, because the flood of
responses of the form "The world's smallest violin plays" would
overload the servers.
Oh, you've seen the legacy (but still depressingly in production) code
at my current employer then. No 'strict'? Check. No 'warning'?
Check. Untainting with /^(.*)$/? Check. Using the documented least
readable way to de-reference hash of hash references? Check.
<sigh>
Craig
I admire this.
I am not quite sure that's the right word, but it's surprisingly close.
It is a thing to be looked up to, but never achieved. That may even
beat the database with "password" and "encrypted_password" columns
(because he was told to store passwords encrypted...).
>> We better stop this cascade before we get into treble.
>
> Considering how this group normally behaves, I think that accusation
> is a bass libel.
>
> Note: The spelling in the above was carefully measured, which bears
> repeating.
Da Capo wants to talk to you about that. Better resolve your case quickly.
Tebrgwrf,
Maarten Wiltink
Who was it again, that said: "Always code as though the person who ends up
maintaining it will be a violent psychopath who knows where you live."
>>> sub get_p
>>> {
>>> #this doesn't work
>>> return 0;
>>> }
>>
>> Well, if it is supposed to return 1, then the comment is completely
>> correct!
>
> Technically, that code is correct. Whatever calls get_p will get a
> return code that says that get_p failed.
Under one convention, at least.
If you reason that success is singular, but failure modes are legion,
it becomes a different matter.
Tebrgwrf,
Maarten Wiltink
If not before, then after.
Take your tonic first, though. It's being carried by a diminished minor.
--
David Cameron Staples | staples AT unimelb DOT edu DOT au
Melbourne University | School of Engineering | IT Support
"what are you wearing?" "a kilt" "no man thats a skirt.." "its a kilt im
telling you..." "uhhh its pink, has flowers and shoulder straps"
"its a prety kilt" -- bash.org/?36828
You're quite lucky there. One codebase I had the misfortune to try and fix
was very much Perl4 style with just enough Perl5 in it to add a few extra
exciting security holes and stop it compiling on Perl4.
> And to think that I write even my quick-and-dirty scripts as if they were
> full on applications that others may have to maintain...
Given that using strict/warn/etc pays back within about 50 lines, it's worth
doing it as a matter of course. The only "good" reason to omit them is when
playing golf.
In other words, yourself. :-)
--
Kenneth Brody
You mean you should always put in comments claiming that a false home address
is yours? What a weird thing to do.
Doesn't mean I want to come into close contact with it.
Craig
> On Wed, 9 Jun 2010 09:34:11 +0000 (UTC), Roger Burton West
>
> >In my life, the usual answer to the titular question is "oh bugger, I
> >did".
>
> I guess the story about the crap code in BASIC is an urban legend, but
> I'm not going to look because I so want it to be true.
If it's about me writing a load of shite on the Speccy when I was
14-ish, it's true.
Richard
>> I guess the story about the crap code in BASIC is an urban legend, but
>> I'm not going to look because I so want it to be true.
>
>If it's about me writing a load of shite on the Speccy when I was
>14-ish, it's true.
The only person I knew who was a prolific writer of code for the early
micros (TRS-80, BBC and so on) did make something of a name for
himself when he and a friend at Cambridge wrote a game called Elite.
Guy
--
http://www.chapmancentral.co.uk/
The usenet price promise: all opinions offered in newsgroups are guaranteed
to be worth the price paid.
>If I submitted every bit of Perl that made me shake my head and
>immediately want to get drunk to numb the pain, I'd be on the front
>page every day.
Do you believe that it is any different with Ada, Algol 60, C, C#,
C++, COBOL, FORTH, FORTRAN, HLASM, Pascal, Python, Rexx, Ruby or
SNOBOL 4? Some people can write FORTRAN in any language.
--
Shmuel (Seymour J.) Metz <http://patriot.net/~shmuel> ISO position
Reply to domain Patriot dot net user shmuel+bspfh to contact me.
We don't care. We don't have to care, we're Congress.
(S877: The Shut up and Eat Your spam act of 2003)
Perl is one of those languages where any idiot can write a reasonably large
program[0] and it will run and appear to work. A program written in C by a
similarly-incompetent programmer will usually to crash and burn in an
obvious manner and not get as far as deployment.
[0] I initially tyoped "problem" here.
Especially since, given that he _knows_ where you live, the lie will
only anger him.
Seth
>Perl is one of those languages where any idiot can write a reasonably
>large program[0] and it will run and appear to work. A program
>written in C by a similarly-incompetent programmer will usually to
>crash and burn in an obvious manner and not get as far as
>deployment.
Alas, my experience with software written in C is that it does get as
far as deployment. The incompetence manifests in such things as not
checking array bounds because that's what the users are for. The
language is Broken As Designed (BAD).
BTW, I have a simple criterion for judging the qualifications of an
&foo advocate: if he can't tell me of any flaws in his preferred
(?:language|operating system)[1] then he doesn't understand it.
[1] It scares me that I can type such constructs without a sense of
"That can't be right."
Well, if you want me to list flaws in Perl, we'll be here all night.
Discerning which of the 10 ways are in either "wrong" category is left
as an exercise to the reader of the documentation, manpage or tutorial.
Most readers fail the exercise, producing code which is provably
wrong[0].
Identifying the 1% of the time when those wrong ways are actually right
is not to be attempted by mere mortals.
Craig "that is just *wrong*" Miskell
[0] in the "that is completely the wrong way to achieve that result.
<thwap>" sense, not the "the result of executing the code is wrong" sense.
>Well, if you want me to list flaws in Perl, we'll be here all night.
I consider it to be an ugly language, but it has too much expressive
power to ignore, and CPAN definitely is a plus.
Two .sigfiles apply, mutatis mutandis:
[S]tandard complaint. Fish, barrel, tacnuke.
-- Red Drag Diva, in alt.sysadmin.recovery
IMHO WinTelnet is one of those situations in which both fish and firearm
are firmly bracketed to the barrel itself, in perfect alignment, and
actually walking up and pulling the trigger starts to fall into the "Why
Bother?" category. -- A deB, in the Monastery
--
Unfortunately, users are in `unstable' so shouldn't be installed in a
production system.
-- David Richerby
That's not entirely the whole story, mind.
Once you get beyond the code that's clearly cargo-culted with all of the
sanity checks turned off (i.e. most Perl written by sysadmins) you pretty
much get down to the same sort of crap code you find written by anybody who
doesn't really know what they're doing.
For example, today's swearing involves an over-engineered bit of code that
has inconsistent error-handling, all battling each other to hide problems
further. So an error occurs ten-deep inside the code (a hardcoded hostname
not existing in the DNS view presented to the test box, as it happens) which
is carefully handled by writing a diagnostic to stderr and then returning a
half-constructed object. Some other code gets confused by the
half-constructed object and returns zero to indicate error. Its calling code
tries to dereference this and throws an exception. Yay, action at a
distance, so easy to debug! This exception is then caught in a library
elsewhere which throws away the stack trace, prints a cryptic error and does
an exit() to make sure that the debugger doesn't get a crack at the stack
trace either.
That POS happens to be written in Perl, but could have just as easily been
ineptly-written in a variety of languages. The half-constructed object is a
Java favourite, for example, and randomly using 0 to indicate an error which
is then ignored is more C. Unhelpful exception handling is definitely Java
and C++'s strength.
So the real flaw in Perl is that one can write Perl in any language.
PHP is perhaps unusual in that I am genuinely unable to figure out how it
became widely adopted. And this is coming from someone who thinks it is
probably pretty understandable how Windows got to be a monopoly.
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
> CPAN definitely is a plus.
<splutter> CPAN, under limited circumstances, may be a *convenience*,
but on the whole it's debatable whether it's actually a "plus".
--
Steve VanDevender "I ride the big iron" http://hexadecimal.uoregon.edu/
ste...@hexadecimal.uoregon.edu PGP keyprint 4AD7AF61F0B9DE87 522902969C0A7EE8
"bash awk grep perl sed df du, du-du du-du,
vi troff su fsck rm * halt LART LART LART!" -- the Swedish BOFH
PHP had some quite compelling advantages over Perl at the time it was
developed, and thus gained traction that way. Perl's moved on, but PHP is
still rather akin to Perl4. (Sure, it's got a half-arsed object system these
days, but apart from that, it's still Perl4-like.)
I am continually spammed by pimps offering PHP roles for derisory salaries
in unsavoury locations. This might be another reason why PHP is popular:
they're apparently hiring PHP developers for half of what I charge to
unbugger Perl code.
(And it'd be a third of what they'd have to offer me to get me to unbugger
PHP code.)
> Richard Bos <rl...@xs4all.nl> wrote:
> > ab...@mooli.org.uk (Peter Corlett) wrote:
> [...]
> >> Well, if you want me to list flaws in Perl, we'll be here all night.
> > Not really.
> > The flaws in Perl:
> > 1. Perl
> > There, done.
>
> That's not entirely the whole story, mind.
>
> Once you get beyond the code that's clearly cargo-culted with all of the
> sanity checks turned off (i.e. most Perl written by sysadmins) you pretty
> much get down to the same sort of crap code you find written by anybody who
> doesn't really know what they're doing.
IOW, Perl is just as bad as all other languages, but worse.
> So the real flaw in Perl is that one can write Perl in any language.
No. The flaw in all other languages is that one can write Perl in them.
The flaw in Perl is than one can _only_ write Perl in it.
Richard
Nonsense. Many Perl idioms do not translate well into other languages. This
may be considered a feature. However, Perl is flexible enough that you can
cherry-pick the more exciting programming errors from other languages and
use them in your Perl scripts too.
Perl doesn't just give you the rope to hang yourself, it provides the
gallows and the baying crowd too. But you don't *have* to hang yourself with
it.
I wrote a medium-sized project which ended up needing to be done in PHP
for horrible reasons.
Had I known in advance, I would have insisted on hazard pay.
>> Well yes, but criticising PHP is a bit too much like lobbing
>> a handgrenade in a goldfish bowl, even compared to perl.
>
>Two .sigfiles apply, mutatis mutandis:
>
> [S]tandard complaint. Fish, barrel, tacnuke.
> -- Red Drag Diva, in alt.sysadmin.recovery
"I don't dance. I don't sing. I write really crappy code very
quickly." -- Rasmus Lerdorf
Seth
> Richard Bos <rl...@xs4all.nl> wrote:
> [...]
> > No. The flaw in all other languages is that one can write Perl in them.
> > The flaw in Perl is than one can _only_ write Perl in it.
>
> Nonsense.
No. The complete truth. Because:
> Perl doesn't just give you the rope to hang yourself, it provides the
> gallows and the baying crowd too. But you don't *have* to hang yourself with
> it.
...but you _will_. Sooner or later, you will. And your successor, who
will have to maintain the code your dead, dead body left him, will hang
with you.
Perl: There's More Than One Way To Pain (and by God and Larry, we'll be
damned if we don't use them _all_).
You think I'm just trying to be confrontational, don't you? Think again.
Richard
itym dueling banjos.
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Mannheim, Germany | Beginning of Wisdom " | http://www.zugschlus.de/
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fon: *49 621 72739834
It wasn't that many years ago when one of the monks here
muttered about .eu interbank nightly transfers or some such being a 200k
bash shell script... and how he rewrote it into a 5k perl script...
-Tai
--
http://www.vcnet.com/bms/features/serendipities.html
http://www.kenthamilton.net/humor/humor.html
http://www.despair.com/demotivators/cluelessness.html
"What we have done with PCs so far is not natural" - Craig Mundie, CTO Microsoft