Re: Cool/useful short examples of Perl?

2011-06-08 Thread Ruud H.G. van Tol


On 30 May 2011 11:40, Leo Lapworth  wrote:


I'm working on http://learn.perl.org/ and I'd like to have a few rotating
example of what can be done with Perl on the home page.



# see also perlvar: $BASETIME
{ my $t0 = time; sub elapsed { time - $t0 } }

--
Ruud


Re: Cool/useful short examples of Perl?

2011-06-08 Thread David Matthewman

On 8 Jun 2011, at 13:17, Tom Hukins wrote:

> On Wed, Jun 08, 2011 at 02:00:41PM +0200, Abigail wrote:
>> I'd rather go for sacking people that don't know the difference 
>> between 
>> 
>>if (something) { ... }
>> 
>> and
>> 
>>unless (!something) { ... }
> 
> It's sunny outside and pubs are open:  I can think of worse times to
> lose my job.
> 
>> Or does everyone think they are always equivalent?
> 
> I'm not everyone, and with a language as flexible as Perl I hesitate
> to make strong statements involving words like "always", but I don't
> recall encountering a situation where they differ.

If 'something' is 'something && something_else' then you *really* want to put 
brackets around it before adding a '!' at the start.

But that's so trivial it barely needs saying, yes?

-- 
David Matthewman




Re: Cool/useful short examples of Perl?

2011-06-08 Thread Philip Newton
On Wed, Jun 8, 2011 at 15:37, Matt Lawrence  wrote:
> Perl's canonical true and false are 1 and '' respectively

Is that so? How would one find that out?

Dump-ing 4==4 and 4==5 with Devel::Peek implies to me that true and
false are PVNVs with integer, floating-point, and string values filled
simultaneously, so I'm not sure how any of the three fields could be
considered "the" value of those, er, values(?).

Cheers,
Philip
-- 
Philip Newton 


RE: Cool/useful short examples of Perl?

2011-06-08 Thread Chris Jack

Apologies for including the top half of the digest.
 
Chris 

Re: Someone needs to take jwz aside...

2011-06-08 Thread Matt Sergeant

David Cantrell wrote:

It's the lack of a CPAN-a-like for any other language that keeps me
coming back to perl.

Of course, it's possible that the Comprehensive Python Archive Network
or similar for ruby/javascript/java/C/whatever does exist but I just
can't find it.  But then, if I can't find it, it's not much use.

http://npmjs.org/

I'm actually liking it more than CPAN for publishing and installing 
stuff. The only weak area is lack of search.cpan.org.


Note that this is for Node.js stuff only - not Javascript in general.

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__


Re: Someone needs to take jwz aside...

2011-06-08 Thread Matt Sergeant

Hakim Cassimally wrote:

While Javascript-the-language is lovely (as you say, better in some
respects, worse in others, than Perl), that's only one part of the
story.  I've not followed Javascript-the-platform that closely (i.e.
anything much beyond jQuery) - what's your experience been like,
working with Node and other libraries?


It's "ok". The standard library shipping with node is lacking in areas 
(there's no flock(), there's no getopts parser, and a bunch of other 
things), and right now it feels like it is stagnating while they get in 
true Windows support, but I've been surprised by the breadth of things 
available on npm (the equivalent of cpan).



Perl->Javascript is a really interesting migration path I'd not
considered, and I'm not sure "it's faster!" would convince me on its
own -- we all know there are faster languages than Perl.  But... JS
does have a significant advantages over, say, Perl->Haskell, as
Javascript is so widespread and therefore has many(devs, projects,
jobs).


OK let me put it another way than just "faster" - it's the fastest 
option for dynamic languages (with the possible exception of Lua-JIT) 
that has a sane (ALGOL-style) syntax, while still having a large user base.


My thinking behind Haraka is that a lot of web sites need a mail server 
with custom functionality, and their web site coders know Javascript, so 
why not provide them with an option to do stuff in JS for email.


Also the other huge thing for me is I've been writing async code in Perl 
now for years, and you always come across fighting with some library 
because it's got a blocking API so either you can't use it, or you take 
a risk and block the event loop while it runs (the same is true for 
Twisted or the Ruby one). That just doesn't happen in Node - everything 
is async.


Matt.

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__


Re: Cool/useful short examples of Perl?

2011-06-08 Thread Matt Lawrence

On 08/06/11 13:41, Paul Makepeace wrote:

On Wed, Jun 8, 2011 at 13:17, Tom Hukins  wrote:

On Wed, Jun 08, 2011 at 02:00:41PM +0200, Abigail wrote:

I'd rather go for sacking people that don't know the difference
between

 if (something) { ... }

and

 unless (!something) { ... }

It's sunny outside and pubs are open:  I can think of worse times to
lose my job.


Or does everyone think they are always equivalent?

I'm not everyone, and with a language as flexible as Perl I hesitate
to make strong statements involving words like "always", but I don't
recall encountering a situation where they differ.

$ perl -le 'print "$_ == !!$_ ? ", $_ == !!$_ ? "yes" : "no" for (-1,
0, 1, 2, undef)'
-1 == !!-1 ? no
0 == !!0 ? yes
1 == !!1 ? yes
2 == !!2 ? no
  == !! ? yes



But:

$ perl -le 'print 0 eq !!0 ? "yes" : "no"'
no

This still wouldn't affect the behaviour of the original example. In the 
context of an if or unless statement, the only thing that matters is the 
boolean value of the expression, not exactly which true or false value 
it is. Perl's canonical true and false are 1 and '' respectively, but 
everything has a boolean value.


Matt



Re: Cool/useful short examples of Perl?

2011-06-08 Thread Paul Makepeace
On Wed, Jun 8, 2011 at 14:15, Kaoru  wrote:
> On Wed, Jun 8, 2011 at 1:41 PM, Paul Makepeace  wrote:
>> $ perl -le 'print "$_ == !!$_ ? ", $_ == !!$_ ? "yes" : "no" for (-1,
>> 0, 1, 2, undef)'
>> -1 == !!-1 ? no
>> 0 == !!0 ? yes
>> 1 == !!1 ? yes
>> 2 == !!2 ? no
>>  == !! ? yes
>
> Whether they are equal according to "==" shouldn't matter here, should
> it? What matters between if(something) and unless (!something) is
> whether something and !!something are the same boolean-wise.
>
> I think this code shows they are all the same?

Yes, you're right - perl doesn't use == semantics for that.


$ perl -e 'for ("a", "", -1, 0, 1, 2, undef) {
print "$_: ";
if ($_) {
  unless (!$_) { print "ok" } else { print "not ok" }
} else {
  unless (!$_) { print "not ok" } else { print "ok" }
}
print "\n" }'
a: ok
: ok
-1: ok
0: ok
1: ok
2: ok
: ok

A legitimate use of unless + else! :-)

P



Re: Cool/useful short examples of Perl?

2011-06-08 Thread David Matthewman

On 8 Jun 2011, at 13:41, Paul Makepeace wrote:

> On Wed, Jun 8, 2011 at 13:17, Tom Hukins  wrote:
>> On Wed, Jun 08, 2011 at 02:00:41PM +0200, Abigail wrote:
>>> I'd rather go for sacking people that don't know the difference
>>> between
>>> 
>>> if (something) { ... }
>>> 
>>> and
>>> 
>>> unless (!something) { ... }
>> 
>> It's sunny outside and pubs are open:  I can think of worse times to
>> lose my job.
>> 
>>> Or does everyone think they are always equivalent?
>> 
>> I'm not everyone, and with a language as flexible as Perl I hesitate
>> to make strong statements involving words like "always", but I don't
>> recall encountering a situation where they differ.
> 
> $ perl -le 'print "$_ == !!$_ ? ", $_ == !!$_ ? "yes" : "no" for (-1,
> 0, 1, 2, undef)'
> -1 == !!-1 ? no
> 0 == !!0 ? yes
> 1 == !!1 ? yes
> 2 == !!2 ? no
> == !! ? yes

Well, -1 may not equal !!-1, but truthwise it's the same, so it's the same to 
an if or unless statement.

I realise this is getting a bit silly, but:


foreach my $test_item (-1, 0, 1, 2, undef, '') {
print "$test_item:\t" 
. return_truth_by_if_not($test_item) . ', '
. return_truth_by_unless($test_item) . ', '
. return_truth_by_if_not(!$test_item) . ', '
. return_truth_by_unless(!$test_item) . ', '
. return_truth_by_if_not(!!$test_item) . ', '
. return_truth_by_unless(!!$test_item) . "\n";
}

sub return_truth_by_if_not {
  my $value = shift;
  if (!$value) {
  return 'non';
  }
  else {
  return 'oui';
  }
}

sub return_truth_by_unless {
  my $value = shift;
  unless ($value) {
  return 'non';
  }
  else {
  return 'oui';
  }
}

-- 
David Matthewman




Re: Cool/useful short examples of Perl?

2011-06-08 Thread Chris Jack




> From: london.pm-requ...@london.pm.org
> Subject: london.pm Digest, Vol 68, Issue 13
> To: london.pm@london.pm.org
> Date: Wed, 8 Jun 2011 14:00:37 +0100
> 
> Send london.pm mailing list submissions to
> london.pm@london.pm.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> http://london.pm.org/mailman/listinfo/london.pm
> or, via email, send a message with subject or body 'help' to
> london.pm-requ...@london.pm.org
> 
> You can reach the person managing the list at
> london.pm-ow...@london.pm.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of london.pm digest..."
> 
> 
> Today's Topics:
> 
> 1. Re: Someone needs to take jwz aside... (Paul Makepeace)
> 2. Re: Someone needs to take jwz aside... (Denny)
> 3. Re: Someone needs to take jwz aside... (Peter Edwards)
> 4. Re: Cool/useful short examples of Perl? (Abigail)
> 5. Re: Cool/useful short examples of Perl? (Bill Crawford)
> 6. Re: Cool/useful short examples of Perl? (Tom Hukins)
> 7. Re: Cool/useful short examples of Perl? (Paul Makepeace)
> 8. Re: Cool/useful short examples of Perl? (Peter Corlett)
> 9. Re: Cool/useful short examples of Perl? (Roger Burton West)
> 10. Re: Cool/useful short examples of Perl? (David Matthewman)
> 
> 
> --
> 
> Message: 1
> Date: Wed, 8 Jun 2011 12:07:01 +0100
> From: Paul Makepeace 
> Subject: Re: Someone needs to take jwz aside...
> To: "London.pm Perl M[ou]ngers" 
> Message-ID: 
> Content-Type: text/plain; charset=ISO-8859-1
> 
> On Wed, Jun 8, 2011 at 11:21, David Cantrell  wrote:
> > Of course, it's possible that the Comprehensive Python Archive Network
> > or similar for ruby/javascript/java/C/whatever does exist but I just
> > can't find it. ?But then, if I can't find it, it's not much use.
> 
> (If you were a python programmer and yet had still somehow managed to
> assiduously avoid all mentions of it, you could search for 'python
> packages' (because that's what they're called in python) and would
> find the top result is http://pypi.python.org/pypi)
> 
> 
> Paul
> 
> 
> 
> --
> 
> Message: 2
> Date: Wed, 08 Jun 2011 12:15:51 +0100
> From: Denny <2...@denny.me>
> Subject: Re: Someone needs to take jwz aside...
> To: "London.pm Perl M[ou]ngers" 
> Message-ID: <1307531751.13033.12.ca...@serenity.denny.me>
> Content-Type: text/plain; charset="utf-8"
> 
> On Wed, 2011-06-08 at 12:07 +0100, Paul Makepeace wrote:
> > On Wed, Jun 8, 2011 at 11:21, David Cantrell  wrote:
> > > Of course, it's possible that the Comprehensive Python Archive Network
> > > or similar for ruby/javascript/java/C/whatever does exist but I just
> > > can't find it. But then, if I can't find it, it's not much use.
> > 
> > (If you were a python programmer and yet had still somehow managed to
> > assiduously avoid all mentions of it, you could search for 'python
> > packages' (because that's what they're called in python) and would
> > find the top result is http://pypi.python.org/pypi)
> 
> As helpfully documented here:
> http://wiki.python.org/moin/MovingToPythonFromOtherLanguages
> 
> -- next part --
> A non-text attachment was scrubbed...
> Name: not available
> Type: application/pgp-signature
> Size: 490 bytes
> Desc: This is a digitally signed message part
> Url : 
> http://london.pm.org/pipermail/london.pm/attachments/20110608/5c15a72b/attachment-0001.pgp
> 
> --
> 
> Message: 3
> Date: Wed, 8 Jun 2011 12:19:15 +0100
> From: Peter Edwards 
> Subject: Re: Someone needs to take jwz aside...
> To: "London.pm Perl M[ou]ngers" 
> Message-ID: 
> Content-Type: text/plain; charset=ISO-8859-1
> 
> >
> > On Wed, 8 Jun 2011, David Cantrell wrote:
> >
> > It's the lack of a CPAN-a-like for any other language that keeps me
> >> coming back to perl.
> >>
> >> Of course, it's possible that the Comprehensive Python Archive Network
> >> or similar for ruby/javascript/java/C/whatever does exist but I just
> >> can't find it. But then, if I can't find it, it's not much use.
> >>
> >>
> >> Python repo
> http://pypi.python.org/pypi
> 
> It was fairly chastening a couple of years back looking for a library
> implementing Role Based Access Control and finding that there was a Python
> one but no Perl one
> 

Re: Cool/useful short examples of Perl?

2011-06-08 Thread Kaoru
On Wed, Jun 8, 2011 at 1:41 PM, Paul Makepeace  wrote:
> $ perl -le 'print "$_ == !!$_ ? ", $_ == !!$_ ? "yes" : "no" for (-1,
> 0, 1, 2, undef)'
> -1 == !!-1 ? no
> 0 == !!0 ? yes
> 1 == !!1 ? yes
> 2 == !!2 ? no
>  == !! ? yes

Whether they are equal according to "==" shouldn't matter here, should
it? What matters between if(something) and unless (!something) is
whether something and !!something are the same boolean-wise.

I think this code shows they are all the same?


$ perl -le 'print "$_\tis the same booleanwise as\t!!$_\t", !($_ xor
!!$_) ? "yes" : "no" for (-1, 0, 1, 2, undef)'
-1  is the same booleanwise as  !!-1yes
0   is the same booleanwise as  !!0 yes
1   is the same booleanwise as  !!1 yes
2   is the same booleanwise as  !!2 yes
is the same booleanwise as  !!  yes

-

As has been pointed out "!" can be overridden etc, but I think the use
of unless is safer than your example suggested.

- Alex



Re: Cool/useful short examples of Perl?

2011-06-08 Thread David Matthewman

On 8 Jun 2011, at 13:17, Tom Hukins wrote:

> On Wed, Jun 08, 2011 at 02:00:41PM +0200, Abigail wrote:
>> I'd rather go for sacking people that don't know the difference 
>> between 
>> 
>>if (something) { ... }
>> 
>> and
>> 
>>unless (!something) { ... }
> 
> It's sunny outside and pubs are open:  I can think of worse times to
> lose my job.
> 
>> Or does everyone think they are always equivalent?
> 
> I'm not everyone, and with a language as flexible as Perl I hesitate
> to make strong statements involving words like "always", but I don't
> recall encountering a situation where they differ.

Their side effects are different. There may be a simpler way to demonstrate 
this, but for instance:

#! /usr/bin/env perl

print "unless: ";
print use_unless() . "\n";
print "if: ";
print use_if() . "\n";

sub use_unless {
  my $value = 1;
  unless ($value) {
# nop  
  }
}

sub use_if {
  my $value = 1;
  if (!$value) {
# nop
  }
}

-- 
David Matthewman


Re: Cool/useful short examples of Perl?

2011-06-08 Thread Roger Burton West
On Wed, Jun 08, 2011 at 01:41:29PM +0100, Paul Makepeace wrote:

>$ perl -le 'print "$_ == !!$_ ? ", $_ == !!$_ ? "yes" : "no" for (-1,
>0, 1, 2, undef)'
>-1 == !!-1 ? no
>0 == !!0 ? yes
>1 == !!1 ? yes
>2 == !!2 ? no
> == !! ? yes

Might as well add lua, since I'm trying to learn it at the moment (and
therefore this is unlikely to be idiomatic). Having explicit boolean
types makes it all a bit more predictable, I feel.

$ lua -e 'function process(x) y=not not x;print(x,"==",y,"?",(y==x)) end for 
x=-1,2 do process(x) end process(nil) process(true) process(false)'
-1  ==  true?   false
0   ==  true?   false
1   ==  true?   false
2   ==  true?   false
nil ==  false   ?   false
true==  true?   true
false   ==  false   ?   true

Roger


Re: Cool/useful short examples of Perl?

2011-06-08 Thread Peter Corlett
On 8 Jun 2011, at 13:00, Abigail wrote:
[...]
> I'd rather go for sacking people that don't know the difference 
> between 
>if (something) { ... }
> and
>unless (!something) { ... }
> Or does everyone think they are always equivalent?

Is this a trick question?

I would expect it to be equivalent if "something" is an expression with higher 
precedence than "!". If not, I'd be fascinated to know what the 
counterintuitive behaviour is and why somebody thought it was a good idea. (And 
also how I've managed to treat them as equivalent for years and not get burned.)

For "something" being arbitrary text, no. if($foo && $bar) and unless(!$foo && 
$bar) are of course not equivalent.

I do like "unless". It's more visible than "!". I like it enough that I'll 
invert the sense of an expression using De Morgan's law and use unless to 
eliminate those oft-missed plings. Avoiding misreading trumps avoiding ugliness.





Re: Cool/useful short examples of Perl?

2011-06-08 Thread Paul Makepeace
On Wed, Jun 8, 2011 at 13:17, Tom Hukins  wrote:
> On Wed, Jun 08, 2011 at 02:00:41PM +0200, Abigail wrote:
>> I'd rather go for sacking people that don't know the difference
>> between
>>
>>     if (something) { ... }
>>
>> and
>>
>>     unless (!something) { ... }
>
> It's sunny outside and pubs are open:  I can think of worse times to
> lose my job.
>
>> Or does everyone think they are always equivalent?
>
> I'm not everyone, and with a language as flexible as Perl I hesitate
> to make strong statements involving words like "always", but I don't
> recall encountering a situation where they differ.

$ perl -le 'print "$_ == !!$_ ? ", $_ == !!$_ ? "yes" : "no" for (-1,
0, 1, 2, undef)'
-1 == !!-1 ? no
0 == !!0 ? yes
1 == !!1 ? yes
2 == !!2 ? no
 == !! ? yes


FWIW,
$ python -c 'for x in -1, 0, 1, 2, None: nnx = not not x; print x,
"==", nnx, "?", "yes" if x == nnx else "no"'
-1 == True ? no
0 == False ? yes
1 == True ? yes
2 == True ? no
None == False ? no

(Wait, what? Command line python? Semicolons? Ternary ops?)

Paul



Re: Cool/useful short examples of Perl?

2011-06-08 Thread Tom Hukins
On Wed, Jun 08, 2011 at 02:00:41PM +0200, Abigail wrote:
> I'd rather go for sacking people that don't know the difference 
> between 
> 
> if (something) { ... }
> 
> and
> 
> unless (!something) { ... }

It's sunny outside and pubs are open:  I can think of worse times to
lose my job.

> Or does everyone think they are always equivalent?

I'm not everyone, and with a language as flexible as Perl I hesitate
to make strong statements involving words like "always", but I don't
recall encountering a situation where they differ.

In response to your question, I started out thinking about "zero but
true" values, but this doesn't matter because double negation of
truthfulness won't care about the value.  So I got stuck.

The only special situation I can think of would be when someone
overloads the "!" operator.  I would console anyone doing this on code
I maintain by mentioning that it's sunny outside and pubs are open.

I suspect I've missed lots of other interesting syntactical
peculiarities, though.  Would you mind sharing them?

Tom


Re: Cool/useful short examples of Perl?

2011-06-08 Thread Bill Crawford
On 8 June 2011 13:00, Abigail  wrote:

> I'd rather go for sacking people that don't know the difference
> between
>
>    if (something) { ... }
>
> and
>
>    unless (!something) { ... }
>
>
>
> Or does everyone think they are always equivalent?

There are those (though I wouldn't be so stern) who would advocate
sacking people who wrote overloaded operators that made them not do
the same thing :)

> Abigail

Will.



Re: Cool/useful short examples of Perl?

2011-06-08 Thread Abigail
On Wed, Jun 08, 2011 at 09:24:50AM +0100, Dirk Koopman wrote:
> On 08/06/11 08:31, Abigail wrote:
>>
>>
>>  unless (!something) {
>> ...
>>  }
>>  else {
>> ... # Unless not something isn't true.
>>  }
>>
>
> An earnest question in the interview test along the lines of "what does  
> this mean and when would you use it" should weed several people out.
>
> Instant sacking (or promotion if in Britain) on sight would seem to be  
> an answer.
>


I'd rather go for sacking people that don't know the difference 
between 

if (something) { ... }

and

unless (!something) { ... }



Or does everyone think they are always equivalent?



Abigail


Re: Someone needs to take jwz aside...

2011-06-08 Thread Peter Edwards
>
> On Wed, 8 Jun 2011, David Cantrell wrote:
>
> It's the lack of a CPAN-a-like for any other language that keeps me
>> coming back to perl.
>>
>> Of course, it's possible that the Comprehensive Python Archive Network
>> or similar for ruby/javascript/java/C/whatever does exist but I just
>> can't find it.  But then, if I can't find it, it's not much use.
>>
>>
>> Python repo
http://pypi.python.org/pypi

It was fairly chastening a couple of years back looking for a library
implementing Role Based Access Control and finding that there was a Python
one but no Perl one
http://pypi.python.org/pypi?%3Aaction=search&term=role+based+access+control&submit=search
http://search.cpan.org/search?query=role+based+access+control&mode=all

Then when I was doing WxWidgets programming from ActivePerl having to use
the wxPython library docs http://www.wxpython.org/ because they were more up
to date and complete than the Perl ones
http://wxperl.sourceforge.net/documentation.html in terms of calling from a
wrapper (more useful than the C++ docs).


Node.js repo
http://npm.mape.me/
V8 seems to work well on Unix and takes little code to implement an
event-driven networking app using server-side JS.

If you can get over the 'Nam-style flashbacks to old skool javascript hacks
for IE5.0


Regards, Peter
http://perl.dragonstaff.co.uk


Re: Someone needs to take jwz aside...

2011-06-08 Thread Denny
On Wed, 2011-06-08 at 12:07 +0100, Paul Makepeace wrote:
> On Wed, Jun 8, 2011 at 11:21, David Cantrell  wrote:
> > Of course, it's possible that the Comprehensive Python Archive Network
> > or similar for ruby/javascript/java/C/whatever does exist but I just
> > can't find it.  But then, if I can't find it, it's not much use.
> 
> (If you were a python programmer and yet had still somehow managed to
> assiduously avoid all mentions of it, you could search for 'python
> packages' (because that's what they're called in python) and would
> find the top result is http://pypi.python.org/pypi)

As helpfully documented here:
http://wiki.python.org/moin/MovingToPythonFromOtherLanguages



signature.asc
Description: This is a digitally signed message part


Re: Someone needs to take jwz aside...

2011-06-08 Thread Paul Makepeace
On Wed, Jun 8, 2011 at 11:21, David Cantrell  wrote:
> Of course, it's possible that the Comprehensive Python Archive Network
> or similar for ruby/javascript/java/C/whatever does exist but I just
> can't find it.  But then, if I can't find it, it's not much use.

(If you were a python programmer and yet had still somehow managed to
assiduously avoid all mentions of it, you could search for 'python
packages' (because that's what they're called in python) and would
find the top result is http://pypi.python.org/pypi)


Paul



Re: Someone needs to take jwz aside...

2011-06-08 Thread Bob Walker

On Wed, 8 Jun 2011, David Cantrell wrote:



It's the lack of a CPAN-a-like for any other language that keeps me
coming back to perl.

Of course, it's possible that the Comprehensive Python Archive Network
or similar for ruby/javascript/java/C/whatever does exist but I just
can't find it.  But then, if I can't find it, it's not much use.




ruby does have rubygems.org now and they have almost decided that it is 
the canonical archive. (rubyforge and github being previous choices). All 
though there has beeen a schism over what 
tool to use to install gems. http://slimgems.github.com/


of course it may fail on your definition of comprehensive :)

Lets put it this way. Im happy to be back sysadmining a perl stack instead 
of a ruby stack :)





--
bob walker
everything should be purple and bendy
http://randomness.org.uk




Re: Someone needs to take jwz aside...

2011-06-08 Thread David Cantrell
On Wed, Jun 08, 2011 at 09:06:48AM +0100, Hakim Cassimally wrote:

> While Javascript-the-language is lovely (as you say, better in some
> respects, worse in others, than Perl), that's only one part of the
> story.  I've not followed Javascript-the-platform that closely (i.e.
> anything much beyond jQuery) - what's your experience been like,
> working with Node and other libraries?
> 
> Perl->Javascript is a really interesting migration path I'd not
> considered, and I'm not sure "it's faster!" would convince me on its
> own -- we all know there are faster languages than Perl.  But... JS
> does have a significant advantages over, say, Perl->Haskell, as
> Javascript is so widespread and therefore has many(devs, projects,
> jobs).

The huge problem I have with programming in Javascript is that, apart
from a few competing libraries for doing browsery stuff, which I'm not
really interested in, there's not much else.  Perl's strength isn't its
speed (there are faster languages for just about every task apart from
munging text, and little that I do these days has speed of text munging
as a priority) or the language itself (which is a bit of a dog's
breakfast) but is the CPAN.

It's the lack of a CPAN-a-like for any other language that keeps me
coming back to perl.

Of course, it's possible that the Comprehensive Python Archive Network
or similar for ruby/javascript/java/C/whatever does exist but I just
can't find it.  But then, if I can't find it, it's not much use.

-- 
David Cantrell | Hero of the Information Age

  The test of the goodness of a thing is its fitness for use.  If it
  fails on this first test, no amount of ornamentation or finish will
  make it any better, it will only make it more expensive and foolish.
 -- Frank Pick, lecture to the Design and Industries Assoc, 1916


Re: Someone needs to take jwz aside...

2011-06-08 Thread Dave Cross

On 06/08/2011 11:21 AM, David Cantrell wrote:

Of course, it's possible that the Comprehensive Python Archive Network
or similar for ruby/javascript/java/C/whatever does exist but I just
can't find it.  But then, if I can't find it, it's not much use.


Perly people were working on a "JSAN" several years ago. I have no idea 
what the status is (which rather proves your point, I suspect).


  http://openjsan.org/

Dave...


Re: 4th edition

2011-06-08 Thread Dave Cross

On 06/08/2011 09:41 AM, Steve Mynott wrote:

Apparently out in October!


It's on the O'Reilly site, so it must be true :)

  http://oreilly.com/catalog/9780596004927/

Dave...


4th edition

2011-06-08 Thread Steve Mynott
Apparently out in October!

I assume "Programming Perl6" will be out in 2021 by which time Centos 7 will
have 5.14.

-- 
Steve Mynott 


Re: Cool/useful short examples of Perl?

2011-06-08 Thread Paul Makepeace
On Wed, Jun 8, 2011 at 08:31, Abigail  wrote:
> On Wed, Jun 08, 2011 at 07:46:52AM +0200, Richard Foley wrote:
>> I've found a lot of German programmers very uncomfortable with the "unless"
>> keyword, (or maybe it's just c programmers).  They appear to very often 
>> prefer
>> to use a construct of the form:
>>
>>       if ( !something ) { ...
>>
>> Even worse is:
>>
>>       unless ( !something ) { ...
>>
>> The brain just into tailspin goes.
>
>
>    unless (!something) {
>       ...
>    }
>    else {
>       ...     # Unless not something isn't true.

 dont(...);

>    }

Joking aside, I wonder if part of the confusion with unless is that
it's usually associated with some kind of negative when it's in the
prefix form "Unless  (you'll be in trouble | don't ... | ruh-roh)"

Paul



Re: Cool/useful short examples of Perl?

2011-06-08 Thread Dirk Koopman

On 08/06/11 08:31, Abigail wrote:



 unless (!something) {
...
 }
 else {
... # Unless not something isn't true.
 }



An earnest question in the interview test along the lines of "what does 
this mean and when would you use it" should weed several people out.


Instant sacking (or promotion if in Britain) on sight would seem to be 
an answer.


Dirk


Re: Someone needs to take jwz aside...

2011-06-08 Thread Hakim Cassimally
On 7 June 2011 16:22, Matt Sergeant  wrote:
> As someone else who has written a bunch of popular perl stuff over the
> years, I'll chime in here too - I write a lot less open source stuff these
> days, but when I do I'm looking much more to JavaScript. The language is
> actually about as good as Perl (some areas better, some worse), but the
> implementation, the interpreters, are just WAY faster.
>
> https://github.com/baudehlo/Haraka

Javascript proponents always used to say that the language would scrub
up quite nicely if browser vendors actually bothered to work on it!
And of course, being a much *simpler* language than Perl, it's not
surprising that it's been possible to apply some great optimisations
on it.  Some more details and write-up on your actual benchmarks would
be really interesting.

While Javascript-the-language is lovely (as you say, better in some
respects, worse in others, than Perl), that's only one part of the
story.  I've not followed Javascript-the-platform that closely (i.e.
anything much beyond jQuery) - what's your experience been like,
working with Node and other libraries?

Perl->Javascript is a really interesting migration path I'd not
considered, and I'm not sure "it's faster!" would convince me on its
own -- we all know there are faster languages than Perl.  But... JS
does have a significant advantages over, say, Perl->Haskell, as
Javascript is so widespread and therefore has many(devs, projects,
jobs).

osf'


Re: Cool/useful short examples of Perl?

2011-06-08 Thread Abigail
On Wed, Jun 08, 2011 at 07:46:52AM +0200, Richard Foley wrote:
> I've found a lot of German programmers very uncomfortable with the "unless" 
> keyword, (or maybe it's just c programmers).  They appear to very often 
> prefer 
> to use a construct of the form:
> 
>   if ( !something ) { ...
> 
> Even worse is:
> 
>   unless ( !something ) { ...
> 
> The brain just into tailspin goes.


unless (!something) {
   ...
}
else {
   ... # Unless not something isn't true.
}



Abigail