“Perl is too low level” and wackyness I’ve heard.

So, I’m working on a little side project. This side project is a website / mobile website that has to care about time. So, a human being wants to set a time and a place, for example, “The movie theatre at address X at 9:00 pm”.

Well, the fact of the matter is that 9:00 pm is a lie. There is no such thing as 9:00 pm. There is 9:00 pm in a certain time zone on a certain date. So, I was at a hackaton, worrying about how to implement this properly. You see, it’s possible that a person would have multiple locations within a block. It’s possible even that within a block, one of those location/time tuples may be in a different time zone than the next location/time tuple. It’s also possible that the person *entering* the time is themselves in a different time zone than the person who is supposed to fulfill the location/time tuples intent. It’s also possible that the server who fulfills the location/time tuple action is in a totally different timezone.  And it’s further possible that the very next location/time tuple action is handled by a totally different server in a totally different timezone.

Real software problems. Hard software problems. Time is a challenging abstraction, and handling time properly is hard. Handling time properly with an understanding of timezone spanning and 3rd party oberservers of time, is even harder.  So, I reach for CPAN and start assembling the modules I need to do things properly.

I bust out Time::Piece, DateTimeDBIx::Class::InflateColumn::DateTime, Date::Parse, and one or two other ones I’m thinking about. I step outside to talk clear my mind, and start talking to another hackathon participant. He asks me, “so what are you coding in?” and I tell him Perl. He mentions that I must be very old, it hurts my feelings. I invest about 45 seconds to let him know that Perl has experienced one heck of a renaissance! But they weren’t even listening, and I wasn’t in the mood to waste my breath. He proceeds to tell me that I’m wasting my time, and that I should really be programming in Ruby.

“You see, there’s this thing called gems, man. And everyone is putting their code in these gems, and it’s incredible. You don’t have to do any of that shit any more. Perl is too low level, I can’t solve any real problems in it.” He said. Young. So young. More importantly, clearly someone who hasn’t actually developed software that has to run 24/7. Software that if it fails, someone may lose an arm. The kind of software that powers multi-million dollar enterprises. Not to say that people using his stack *couldn’t* do so… but this young kid clearly hadn’t done it.

So I ask him: “ok, so I have to track multiple sets of time/location tuples in a way which is completely timezone agnostic, messaging needs to happen to people in those timezones in real time, an external person in a different timezone may require completely different messages at different times but calculated off of offsets of of their timezones, it’s possible that these sets themselves span multiple timezones, and it’s further possible that the servers are themselves in multiple different timezones. How would you solve it?”

I expected him to tell me an answer that made sense, something like: “don’t store timezones, convert everything to UTC and make your tuple consumer logic do timezone transformations in real time” or something even more clever than I could have come up with. I waited, and took a deep breath of the crisp fresh air.

He replied: “Perl is just too low level. I’d find a ruby gem that handled that.”

Thanks kid, I appreciate it.

UPDATE: If there is a ruby gem that handles this, I’d love to hear about it.

This entry was posted in tech and tagged , , , , , , , . Bookmark the permalink.

5 Responses to “Perl is too low level” and wackyness I’ve heard.

  1. Something similar happend to me one year ago. A greenhorn almost grown up was complaining our choice for Perl and PostgreSQL and permanently suggested to use Java and Oracle Database products instead without having any knowledge about our organization and our projects so far. He tried to make several attempts to blame us for our decision but was not able to find a single argument. After the first day he did not show up any more.

  2. Sounds like at least this Ruby-er, if not the majority of them, view Gems as a new concept that makes Ruby more awesome than many other languages, including Perl. I hale this high-level thinking that the tools available to you is more important than the syntax. But, I’m disappointed by the misunderstanding that Ruby is somehow unique in this feature of having libraries that are distributed and available for all to easily install. I was always under the impression that Perl was the king in this area with CPAN, and is one of the main reasons why I stick with Perl. CPAN is an absolutely mind-boggeling huge network of easy to install Modules (just like a Ruby Gem) that solve many every day problems, including Date/Time/Zone handling, and just about anything else you can think of. I’m pretty sure Ruby is playing catch-up right now and it will take years for it to provide the same usefulness to Ruby developers that CPAN provides to Perl developers.

    All aside, if you like Ruby, use it. Perl and Ruby both have young vibrant communities with smart people. Perl has been around longer and is more proven, and has vastly larger repository of re-useable code (CPAN). Personally I like the feeling of the Perl community – it is very anti-establishment. It feels like being in a community of gritty rebels. And I like the fact that perl does have “low-level” qualities, but for me that’s a very useful feature – it allows me to simply drop down to the low-level if I please, unlike some other languages that make this painfully difficult (/me looks at Java). But, that doesn’t mean perl isn’t as “high-level” as something like Ruby.

    Ah, misguided people. Its been the bane of human existence and always will be.

  3. bleargh45 says:

    So…. *did* you ever figure out how to handle this w/Perl+PostgreSQL?

    I ask as I’ve got _exactly_ the same issue right now and I’m wrangling my own head around it and am looking for insights from others who’ve been down this road before.

    Like yourself, am building an application that needs to send out messages to Users at particular times of the day, in *their* timezone (not mine). While the “TIME WITH TIME ZONE” date time in PostgreSQL looked useful at first, its not recommended and I didn’t see an obvious way to have it always query it with respect to the current date (so that Daylight Savings changes would be taken into consideration).

    Even more fun, I’d *REALLY* love to be able to do this in such a way that I could push as much of it down into PostgreSQL as possible, rather than doing the math in Perl. While I could open up all of my User records and iterate across them in Perl to manually figure out if its the right time of day for me to send a message to this particular User, it’d be far more efficient to just push it down into Pg.

    So… after resisting the urge to strangle that Ruby fanboy, what solution did you decide on?

    • earino says:

      Well, I can give you a high level overview.

      Store all times in UTC, in an event table. Have a job kick off every N minutes (where N is a reasonable quantity), if the job’s time is in the past in UTC, then I fetch the user record, send the message, and mark the record as handled.

      I’m sure I could have done something smarter, but this ended up being the “by far” easiest thing to do. Translate the time in my application layer to UTC, and do all my time checking in a single timezone.


      • bleargh45 says:

        Ah, so you’re queuing them up as Jobs, and then firing them out as needed that way. Cool.

        After a bunch of wrangling my own head around it, I’ve (for the moment) gone w/having this done in Perl and using DateTime to do the fun parts for me. I had managed to come up with some really fancy and elaborate ways to construct dates/times on the fly in pure SQL, but chucked all that and went w/plain Perl as it was going to leave me with something far more readable and understandable for when I come back to it again in a few weeks/months a look at it.

        Appreciate your reply and follow-up Ed. Thanks!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s