On Sat, Mar 27, 2010 at 05:24:00AM -0500, Dave Sherohman wrote:
> tl;dr summary:  I'll (++n)th Perl as my primary language.  I know it, I
> like it, and, gosh-darnit, it's just fun to use.
Indeed.
> --- cut here ---
> package PRangers::Cargo;
> 
> use MooseX::Declare;
> 
> class PRangers::Cargo
>   with KiokuDB::Role::Intrinsic {
> use MooseX::Has::Sugar;
> use PRangers::Item;
> 
> has item => ( isa => 'PRangers::Item', ro, required );
> 
> has qty => ( isa => 'Num', rw, required );
> around qty (Num $new_value?) {
>   return $self->$orig unless defined $new_value;
>   $new_value = 0 if $new_value < 0;
>   $self->_clear_calculated;
>   $self->$orig($new_value);
> }
> method add_qty    (Num $delta) { $self->qty($self->qty + $delta) }
> method remove_qty (Num $delta) { $self->qty($self->qty - $delta) }
> 
> has [ qw( mass volume ) ] => ( isa => 'Num', ro, lazy_build );
> method _build_mass   { $self->item->mass   * $self->qty }
> method _build_volume { $self->item->volume * $self->qty }
> 
> method _clear_calculated {
>   $self->clear_mass;
>   $self->clear_volume;
> }
> 
> }
> 
> 1;
> --- cut here ---
class PRangersCargo():
   def __init__(self):
      self.item = PRangersItem()
      self.qty  = 0
   def addQty(self, delta)
      self.qty += delta
   def removeQty(self, delta)
      self.qty -= delta
   def mass(self):
      return self.item.mass * self.qty
   def volume(self):
      return self.item.volume * self.qty
> That doesn't feel overly messy to me.  How about you?
Python looks more clean and elegant to my eyes, closer to the
pseudo-code.  I could show Python to a non-programming accountant or
doctor and they could follow what the code is doing without getting
distracted by arrows, double arrows or dollar signs.  I use C/C++ most
of my days to the arrows don't scare me.
> > You just have to accept indentation (white space) matters.
> 
> When I first heard about Python, my initial reaction was "I could never
> trust a language with syntactically-significant whitespace."
It smelled funny, indeed.
> When I finally tried Python, I have to admit that, aside from a little
> initial confusion about the rules regarding it, the whitespace thing
> didn't bother me at all.  A ton of other things did, though.  Perhaps it
> was just lack of familiarity, but I felt constantly hamstrung by having
> to work out how to think like Guido instead of being able to express my
> thoughts directly.
I have to hit the Python manual often even for simple things like list
or string methods while I haven't opened the Camel book in ages.  But
those might be quirks of naming things - on the fundamental level,
Python is beautiful.
> I'm not, by any means, trying to say that there's anything wrong with
> Python or that Perl is objectively "better", but Perl works the way my
> mind works, so I like it.  Python doesn't, so I prefer to avoid it.
> That's what works for me; YMMV.
Perl is like playing, Python is like working.  One is messy and fun,
the other one is clean and revenue producing 8^)  Can't have one
without the ooooooother.
Cheers,
florin
-- 
Bruce Schneier expects the Spanish Inquisition.
      http://geekz.co.uk/schneierfacts/fact/163
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20100327/2425937d/attachment.pgp