in reply to Time efficiency of object creation in Perl (or the "bless" function)

Like everything in life: "It depends".

Creating and accessing a simple hash will always be faster than creating and using an object.

If all you do is to set and get a few fields of an object, then it looks --to me-- that the whole object creation is much overkill.

A good example of "good" object oriented programming is DBIx::Class. Sure it is a lot slower than pure DBI, but once you have set-up the database classes for your database, querying the database becomes very easy. Any (run)time lost in using DBIx::Class is paid back many times over in the much shorter development time you now spend to write programs that use that database.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

  • Comment on Re: Time efficiency of object creation in Perl (or the "bless" function)