cjsmith: (cjre joe2)
cjsmith ([personal profile] cjsmith) wrote2002-07-23 12:50 pm

Bits of Randomness

I'm getting more motivated at work. I have ONE script that needs debugging... in a language I don't "speak". This is actually fun.

The car place still has my car. Had to skip the gym this morning for lack of car. It @#$ing well better have air conditioning when they're through with it. They replaced nearly every part in the A/C system just weeks ago.

Quote of the day: "WARNING: The consumption of alcohol may leave you wondering what the hell happened to your bra."

[identity profile] mactavish.livejournal.com 2002-07-23 01:17 pm (UTC)(link)
Can I get you some wine? I have some nice beer, here.

[identity profile] mactavish.livejournal.com 2002-07-23 02:56 pm (UTC)(link)
Hey, anything I can do to help . . . :)

[identity profile] deyo.livejournal.com 2002-07-23 03:29 pm (UTC)(link)
I can do amazing things with one hand.

Or with no hands.

[identity profile] deyo.livejournal.com 2002-07-23 01:17 pm (UTC)(link)
More wine? :)

[identity profile] mactavish.livejournal.com 2002-07-23 01:17 pm (UTC)(link)
*snerk*

Okay, I admit I stole it.

[identity profile] wcg.livejournal.com 2002-07-23 01:49 pm (UTC)(link)
GMTA!

[identity profile] cjsmith.livejournal.com 2002-07-23 02:47 pm (UTC)(link)
Mmmm, *hic* shuuuure. :-)

[identity profile] wcg.livejournal.com 2002-07-23 01:36 pm (UTC)(link)
And... how did you come by that little bit of wisdom CJ? Or would you rather I buy you a drink before you tell me the story?

[identity profile] cjsmith.livejournal.com 2002-07-23 02:45 pm (UTC)(link)
Well, I woke up this morning naked in an elevator...

Naah. I wouldn't turn down the drink, but this is just one of those humor tidbits that goes around the net. It was followed by a list of ten more gems, including "...may cause you to think you can sing" and "...may make you think you are whispering when you are not". :-)

[identity profile] wcg.livejournal.com 2002-07-23 03:15 pm (UTC)(link)
Well, I woke up this morning naked in an elevator...

I have got to stop taking the stairs.

[identity profile] yoak.livejournal.com 2002-07-23 02:58 pm (UTC)(link)
The funny thing about that is that I read the first sentence or two, then scanned the rest. When @#$ing caught my eye I had to re-read it more carefully because it looks like Perl and if that was the language in question I could perhaps be of some small assistance. :-)

[identity profile] cjsmith.livejournal.com 2002-07-23 03:48 pm (UTC)(link)
@#$ing ... looks like Perl

I had to laugh! :-)

The script is indeed in Perl. I'm taking this opportunity to learn some of the basics, at long last. I'm surprised at how much I like it. Most of my previous experience with Perl has been of the form "some guy who mistakenly believes he's better than everyone else likes this language", so for a while I was reluctant to learn it.

[identity profile] yoak.livejournal.com 2002-07-23 05:20 pm (UTC)(link)
Yeah, there's a lot of that attitude in Perl culture. There's probably also more bad programming done in Perl than in most other languages. I think the reason for this is how Perl came into prominence.

Though Perl was used for years before the web was around, it was only known by a few crusty Unix people that normal humans probably wouldn't communicate with. (Apologies to those of you who fit this mold who are probably reading this. You know who you are. :-) I claim partial exemption being one of them myself.) Perl was an obvious choice for a lot of web interactivity, particularly with the release of Perl 5, about simultaneous with AOL putting people on the net and the web exploding.

Anyway, Perl is ultimate among languages that let you do a great deal with very little. Because of this, and books like Learn Perl in 8 Seconds Without Thinking, probably by Sams, a lot of non-programmers picked up a little syntax and were actually able to produce sorta-working stuff.

I think most of the thinkers of the thoughts that you've described are people who fall into this category. They're people without a solid grounding in computing, have little experience with other languages and probably lack the skill required to easily pick up other languages and tools. The swagger is a little defensive in most of the people who have it.

Now... that said, Perl does all kinds of rule. If you're actually good at programming, and happen to be working in the problem spaces at which Perl excels (which used to be a smallish space, but now includes mostly things not graphically oriented or very low level where the overhead of Perl becomes important), Perl is in my ever so humble opinion the best choice. It's flexibility, power and speed of development are just hard to rival with any other language.

[identity profile] cjsmith.livejournal.com 2002-07-23 05:37 pm (UTC)(link)
That's pretty much my understanding of Perl's history, too. It's very clear it comes from the Unix side of things (which is a little odd right there -- Windows / DOS have much WORSE existing shellscripting capability, so it's arguable that Perl is needed more on those platforms). It seems that only lately is Perl branching out of its niche as purely a system administrator's tool.

My own theory is that a swagger is almost always defensive whether in a Perl coder or not :-) but that's another topic.

Many many thanks for the offer of help! I'm enjoying tweaking this thing, and I just may take you up on your offer if I get stuck.

[identity profile] yoak.livejournal.com 2002-07-24 03:39 pm (UTC)(link)
I agree with you about the defensive thing. I feel the same way about arguing. Most people only do it when they are unsure of their own views. I mean, if someone at a party asserts that 2+2=5, you'd be amused, and probably egg the person on if they were serious. You wouldn't have an argument about it. But have someone criticize your religious views or morals, and... well you get the idea.

And you're welcome about the offer to help. I have a lot of fun with Perl, and even more fun with people who are new to learning it. I'd be happy to be of any assistance that I can.

[identity profile] hitchhiker.livejournal.com 2002-07-23 06:00 pm (UTC)(link)
Perl is also the most playful language I've seen, though. The true geeks produce esoteric, linenoiselike perl just because they can, and because the results are so beautiful (like (not mine!) $max = [$a=>$b]->[$a<=$b];). It's not an "I know things not meant for mere mortals" swagger, more of a "w00t - see what I got this thing to do!" wardance.

For actual serious coding I've defected to the Ruby camp, though there's still nothing to touch cpan.

[identity profile] yoak.livejournal.com 2002-07-24 04:00 pm (UTC)(link)
$max = [$a=>$b]->[$a<=$b];

This is mildly clever. I'll disect it for the benefit of readers who may not be able to parse it.

Square brackets are an anonymous list constructor in Perl. What results is a scalar value that is a reference to a list. So:

$foo = [1,2];
is the same as:
@foo = (1,2);
$foo = \@foo;

=> is syntactic sugar, and is a synonym for ',' , so what you've done with the first part of the expression is an (anonymous) reference to a list containing $a and $b. It is a cool way to write it because it looks like numeric comparison, but actually does nothing of the sort.

Now, the '->' is the arrow operator used to dereference in Perl. When followed by square brackets, it is expects to dereference a list reference. For instance, with our foo example above, we'd get the first (zeroth, actually) value of @foo with:

$foo->[0];

So... $max = [$a=>$b]->[...];

intends to dereference the anonymous list and access the numerical value indicated by '...'. What is actually contained in that is, this time, an actual numeric comparison is being done with $a<=$b, which if false, will generate 0, the zeroth element, and if it is true, it will be equivalent to 1, giving the other element of the list.

And in more general terms, you are correct... there is more of this in Perl than anywhere else I've ever played, and it is among the multitude of reasons that I love Perl and Perl culture.

If you disliked this bit of fun, you are almost certain to not enjoy the Fun With Perl mailing list, accessible from http://lists.perl.org/ . This list has frequent mailings of things of this sort, along with other things like Perl Golf contests. These last are seeing who can perform a specified task in the fewest number of (key)strokes. You'd be amazed what Perl masters can do in 60 or strokes... I've never seen a problem posed that took more than that. Of course, the winning solution always look like this:

-ni
$_=$#@*(%(#$@#___;eval

so it has little value until you get enough the hang of it to be able to parse those things... but once you have the basics, decoding those and asking questions about them is extremely educational.

I personally suck at these in that I've been programming Perl too long to justify entering those contests in the "beginner" category and yet I can't generally score well even for a beginner, let alone with the main group.

(Anonymous) 2002-07-25 07:17 am (UTC)(link)
mmm, excessively-clever perl. great for personal hacks, or contests... I think I'd slap anyone who checked that in on my current project :-) (now, if it became an established idiom, that'd be another thing, or if it had a comment, or if there was some reason it was actually *clearer* than the classic version.)
perl has made inroads into the dos space, via ActiveState, especially on the web side of things... but vb/vbscript covered a lot of the "needs more scripting" niche, much to the horror of unix geeks :-)
but yeah, you can always ask for help, even "don't tell anyone I asked, but..." form; you just risk getting long digressions about how some feature evolved from perl 3 :-)

"perl is the yiddish of programming languages"
_Mark_

[identity profile] yoak.livejournal.com 2002-07-23 05:21 pm (UTC)(link)
Oh, and since it *is* in Perl, if you get stuck with a language issue and don't have other Perl help at your fingertips, feel free to drop a line or instant message (AIM: jeffyoak)