A conversation with a C programmer
Anonymous Monk
created: 2006-03-15 04:01:50

CP: the C programmer
me: I'm only thirty percent as arrogant as I come across.

$CP in $irc_network #Perl asked a question about matching files ending in '.xls'. I answered with a regex, and $CP messaged me privately.

Re: A conversation with a C programmer
created: 2006-03-15 09:33:35

Did you need to rock his boat that much? You could have easily answered his question and made him feel good about Perl with

next unless $file =~ /xls$/;
he'd understand that.

-derby
Re^2: A conversation with a C programmer
created: 2006-03-15 14:56:21
Along those lines, it probably would have been a nice gesture to let the C programmer know that
next if($file eq ".");
next if($file eq "..");
can be condensed to
next if $file =~ /^\.{1,2}$/;
Isn't that more Perlish, and help the programmer see more of the usefulness of regexes without making him too lost in what is going on? But now that I think about it, the whole snippet can just be compressed to something like
opendir(TARGET, $target);
while($file = readdir(TARGET))
{
    &process_new_file($file) if $file =~ /\.xls$/;
}
right? Do you think that would rock the boat too much?
Re^3: A conversation with a C programmer
created: 2006-03-15 15:38:51
opendir my $dh, $target;
/\.xls$/ and process_new_file($_) while readdir $dh;

I started out writing this facetiously, but now I kind of like it! It reads very nicely. YMMV =)

Re^3: A conversation with a C programmer
created: 2006-03-15 19:13:56
I think
next if $file =~ /^\.\.?$/;
or even
next if $file =~ /^\.+$/;
is much nicer than
next if $file =~ /^\.{1,2}$/;

But that's just me.

Re^4: A conversation with a C programmer
created: 2006-03-15 21:03:18

But that's just me.

*nod*, I don't at all like your second preference.

Re^4: A conversation with a C programmer
created: 2006-03-25 01:28:41
yes, the second one will also match files named with any quantity of dots as long as that's the entire filename. In practice, I've never seen a file that started with "..", but I agree it's an issue.

I have, but only on a machine that's been broken into. It is, or at least used to be, common to hide malicious software inside directories called ... -- of course, these days all the l33t kiddies are using loadable kernel modules to hide their directory trees anyway, so it may not be as relevant.

--
@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/;
map{y/X_/\n /;print}map{pop@$_}@/for@/
Re: A conversation with a C programmer
created: 2006-03-15 09:56:04

Heh. I've not found comments like "You're not a programmer at all ... " to be particularly helpful.

You might consider jettisoning some of the remaining 30% of your arrogance. Having been on the receiving end of such comments as: "You're not a real programmer because you code in Perl rather than C++", I can't say that I enjoy it much. Too often such 'jesting' or 'teasing' is a socially acceptable veneer covering a deeper, uglier disprespect. Language holy wars are fruitless and they erect barriers to communication and getting work done.

If I need to puff myself up, I try to find a way to do it without tearing someone else down. I much prefer a win/win situation to a zero sum game or (more often) a lose/lose situation.

Perhaps you have a solid relationship with your C-programmer friend, and such banter can be taken positively and constructively. Maybe I'm just patronizing you to make myself feel better ... if so, I should take my own advice. :)


No good deed goes unpunished. -- (attributed to) Oscar Wilde
Re^2: A conversation with a C programmer
created: 2006-03-15 20:21:01

I think the OP was making a learned observation.

I think that someone who does c, and sees that 3rd grade code that supposedly fame from a friend who knows what he's doing- maybe that person would look at it and be asking more questions then the original ones. In fact, a coder would possibly find it quicker to lookup those answers and quickly learn some regex common sense - then to try to get another human being's attention about it.

Especially c, c is not "easier" then perl. Saying you're a programmer carries some punch. I try to take it to mean one of two things, either you're not a programmer, or you're a hard veteran. Personally I am not a coder, It's like being a marine in that movie Jughead- getting branded.

I code. I write some software when I can't find an already existing solution for the problem.

Anyway, the OP came here I think with good intentions, maybe to get some laughs- etc. And yes... He wasn't the most helpful. But - I think it *was* clear that the "c programmer" was not really a coder. And if you're gonna learn, to help your teacher you have to tell them what you don't know. Dude was obviously trying to be helpful until he realized that the "c coder" was not being very honest about what he did and did not know.. That's one way of looking at it.

Re^3: A conversation with a C programmer
created: 2006-03-16 09:14:25

You may be right ... perhaps I was just cranky when I posted that comment yesterday. It is allergy season for me, here. :)

I guess what really busted my chops was the 'at all' part of the "You're not a programmer at all" quote ... I just don't see any way not to take that as an unkind slur, no matter what the self-perceived skill level is. Clearly someone who is 'coding' is at least trying to be some kind of a programmer. Of course, in my rather narrow little world, I assume that everyone wants to be a programmer. :)

But as you say, I would help a programmer differently than I would help a 'normal' person, so it is important to find out with whom one is dealing.

Re: A conversation with a C programmer
created: 2006-03-15 12:33:01

Let us hope his $target directory never contains whitespace, or your replacement would fall down and go boom.

Re^2: A conversation with a C programmer
created: 2006-03-15 13:04:05
Let's also hope that he's not running an old version of perl, either. On old systems, glob() (and the diamond glob operator) called the external shell program csh, which overzealous sysadmins were prone to deleting when they "upgraded" to their favourite shell.

As I understand it, glob() still calls File::Glob; and a bug in the handling of tags is why I can't make debug mode work with the old perl5.6.1 scripts we have on our system. *sigh*. In other words, using glob() has always been a risky proposition.

--
Ytrew

Re: A conversation with a C programmer
created: 2006-03-16 19:45:18

I have to scratch my head about the C programmer who is not already familiar with glob().

Re^2: A conversation with a C programmer
created: 2006-03-16 19:57:20

I've been using C for best part of 25 years, but I'd never encountered glob() until I used Perl.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: A conversation with a C programmer
created: 2006-03-19 21:50:28

Guilty. I just did a man glob and discovered it's right there in the libraries. Wow. I'd always used the findfirst and findnext functions before.

I used C from 1981 regularly till about 1998, when I moved over to Perl, and during that time I'd never seen a glob function in the C run time libraries I used

So, go ahead, scratch away.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

perlmonks.org content © perlmonks.org and Anonymous Monk, BrowserUk, derby, dynamo, fizbin, leocharre, ptum, revdiablo, Steve_p, talexb

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03