rs79.vrx.palo-alto.ca.us

Why Perl Sucks Compared to C


Why Perl Sucks Compared to C

"And I would not include C in a list of languages for writing readable code in."

I can understand how you can feel that way after looking at some of the C code that's out there. But you have to go out of your way to obfuscate C. There's a reason there's no obfuscated Perl contest: "everybody's a winner!".

It's possible to write readable code in C. Not many people do it, I'll agree but this does not mean it cannot be done and you learn for your own beenfit, in time, to write very clear, lots of whitespace, one idea per line code. DMR's "one true brace style" is as much to blame for the obfuscation and unreadability IMO, as anything, and while he and I disagree on this, our understanding we've agreed to is as long as you can read and write both, that's ok. Keep in mind his justification is based on physical limitations of 24 line 80 column crts.

if (thing == that){
  pritnf ("This sucks, Dennis.");
}
or
if (thing == that)
  {
  printf ("My kids can understand this.");
  }

C is a simple langauge with not that many operators, but it requires discilpine to write code you can go back to in 6 months or a year and still tell at a glance what it's doing.

I also do not buy the "perl has more features" argument. If you need to do something often enough you write yourself a set of routines and use them as a black box library. My "web" one is 10 yrs old. Prior to that I carried around the same one for decades and with slight modes it worked from (real) Unix to CP/M to MS-DOS. Things got a bit fuzzy around the edges with Amiga and Windows GUI code, but they did not last long in my world. My one Windows gig was my last, it was too revoting to take seriously; I'm not into masochism.

I would encourage aybody whose written a quick Perl hack to write it again in C as much for the learning experince as for the benefit of crusty farts like me who are sick of 7 levels of dependancies. Grabbing "the needed library" seems to be a recursive loop without end and I've given up many times trying to run some perl thing and found in most cases it's easier just to write it in C, which, once you're used to it you can do very very quickly. I will grant that it take a fair amount of time to overcome the learning curve but IMO it's absolutely worth it.

To address the original point I have no problem with APL, Forth or Poscript. While they take a day to get used to, they're simple, fun and elegant. Parl just makes me hurt all over.

At the risk of being permanently banned fom slashhdot forever I believe 1) Linux is more popular than BSD not because it's better in any sense, but because it's easier to install, and 2) Perl, similarly so, provides an instant gratification at a penalty of readability and to some extent, performance. I prefer "short term pain for long term gain" and shortcuts are just that. My grandmother said it best: "quality is the only economy".