Hacker News new | ask | show | jobs
by qstyk 4495 days ago
At risk of going off-topic, was your migration from Perl to Python a simple factor of the projects you worked on or was there a deliberate effort to proactively switch?

I learned Perl in the CGI days of the mid-90's and never even continued on to PHP. As a network consultant now, I find Perl to be immensely helpful, when it comes time to script some monitoring or automated activity.

That said, a fellow networker had mentioned that many others had been switching. Most of my days are not spent programming, but I do occasionally bust out a project or two. Is it worth my time to make the switch?

1 comments

> At risk of going off-topic, was your migration from Perl to Python a simple factor of the projects you worked on or was there a deliberate effort to proactively switch?

Deliberate. I'll put my story below my advice so as not to bore the masses.

If you're good at Perl, it's probably not worth the time to make the switch until you have to. Python isn't sufficiently "better" to warrant the time investment required. The only caveat to that statement would be in two different cases: 1) your scripts have lifetimes longer than a few dozen months or 2) you have a a larger body of programmers who need to understand and modify your scripts.

WARNING! HORRIBLY BIASED OPINION INCOMING!

Perl 4/5 tended to create a weird problem in programmers in my experience. Everybody "learned" Perl, but everybody "learned" a different ... dialect, for want of a better word. So, when two Perl programmers got together to read a program, at least one of them was learning new corners of the language. Or one of them was remembering pieces that he had long forgotten. I was on all sides of that issue. It was so bad that eventually when I interviewed for VLSI jobs, I would bring along a nice piece of Perl code I had written, so that I would be discussing Perl on my terms instead of that of the interviewer. That cut short a lot of the "do you know Perl?" idiot questions.

So, what I found after I made the Python switch (I won't claim that I was prescient enough to realize beforehand), was that 1) I could come back to my scripts after 2 years and still understand them and 2) all the Python programmers seemed to pretty much wind up programming sort of the same way. For me, that cemented that I would never go back to Perl. Even after not programming in Python for a few months, I could go right back to it. A few months off from programming in Perl and it would take a couple of weeks to get back up to speed. Python just seems to have a smaller mental model--Perl aficionados would cite that as an inferior mental model. Shrug. I'm not a genius so I'll stick with the smaller mental model, thanks.

Back to why I switched. My reasons were both petty and selfish. :)

I wrote a lot of Perl scripts as a VLSI designer. A lot of munging data from this format to that format. Check that thing over there. Merge it with this thing with undocumented formats. Consequently, my scripts tended to have 1) lots of subtle edge cases and 2) lifetimes often measured in years because the effort to do it right is both enormous and highly specialized. (I had someone email me about a script I wrote 14 years ago early this year that reads formats that are over 30 years old!)

The problem was that I kept tripping over bugs--and nobody could explain to me what was going on. About 2/3 or the bugs were mine but required Perl near-gods to diagnose, 1/6 of the bugs were weird grammar edge cases in Perl, and 1/6 were actual bugs in Perl. This was in the 1994 to 1996 timeframe around the Perl 4 to Perl 5 transition (yeah, I've been doing this that long).

The bug which finally convinced me it was time to leave (there were many, but this was the last straw) Perl was when I wrote a program to merge static timing analysis cards from 3 different sites (3 different formats, naturally). 99.9% of the time it worked, but sometimes it would just die. I finally tracked it down to a bug in Perl 4, the Regex engine would do weird things if you fed it a pattern with 512 characters exactly. 511 and it worked. 513 and it worked. I sighed. Pulled down Perl 5 instead knowing things had been pretty much completely rewritten. And tripped over a different bug in the regex engine. Started looking for a new scripting language that day.

Pretty much the only options at that point were Tcl, Scheme, Lisp or Python at that point. I had abandoned Tcl (pretty much the standard for scripting in VLSI/EDA) for Perl originally because it was a similar disaster until the 8.0 rewrite. Scheme and Lisp were just starting to integrate the fact that Unix wasn't just a tiny blip until we got back to a real operating system so they had better start supporting operating system integration.

So, that left Python. Horrible whitespace dependency and all. :)

I'm kind of surprised that almost 20 years later I'm still using the same programming language. I really expected something significantly better to come along. Scala, Erlang, and Clojure all have made a good case--but they don't really bring anything to the table that warrants me switching completely in the general case. Scala was WAY too much mental model inload for me. Erlang didn't handle dynamic hash tables well enough for the amount of time you use them in programming (I tell my classes--70% of the time use a hash table; 30% of the time use a vector). Clojure was quite nice and probably made the best case, but it just wasn't better enough than Python for me to spend the time making it my primary language.

Side note: dynamic hash tables just hit Erlang THIS MONTH. So, that's probably not a good reason anymore.

Now, betcher sorry you asked that question, arn't cha? :)

> Side note: dynamic hash tables just hit Erlang THIS MONTH. So, that's probably not a good reason anymore.

What? Erlang's hashtables are called `ETS` and `DETS` and have been there since at least 1997.

What I believe you are referring to are `maps`, which while they have the syntax of scripting languages' hashes, are nothing but trees. Access is far from constant time. Then again Erlang had these a while ago. They are just adding syntax sugar and pattern matching.

I'm not getting into the maps/records/ets/mnesia debate. Yes, you could do it in Erlang, but it was clunky and verbose.

Maps are what people coming from other languages expect to see, and I wanted to point out that now Erlang has them.