Live data from Hacker News

Dwindling CPAN Releases

perlancar.wordpress.com

31–40 of 180 posts

Re: Dwindling CPAN Releases

#31
post #8

Long ago I used to joke that perl is write-only... was that harsh or realistic? (I still believe it - too clever constructions which feel smart at the time you come up with them :)

"too clever constructions which feel smart at the time you come up with them"

That's the coder, not the language.

Which is more obvious what's happening.

  print ''.join('%(pre)s%(num)s %(bot)s on the wall, %(nul)s %(bot)s,\n%(tak)s\n' % (lambda c,b: {'pre':['','%s %s on the wall.\n\n' % (c,b)][abs(cmp(c,'Ninety-nine'))], 'num':c, 'nul':c.lower(), 'bot':b, 'tak':['Go to the store and buy some more... Ninety-nine %s.' % b,'Take one down, pass it around,'][abs(cmp(x,0))] })((lambda x,o: [(['Twenty','Thirty','Forty','Fifty', 'Sixty','Seventy','Eighty','Ninety'][x/10-2]+'-'+o.lower()).replace('-no more',''), o][int(x=20)]]),'bottle%s of beer' % ['','s'][abs(cmp(x,1))]) for x in xrange(99,-1,-1))

Or

  my $firstline = 1;
 my @tens = qw/Ninety Eighty Seventy Sixty Fifty Forty Thirty Twenty/;
 my @teens = qw/Nineteen Eighteen Seventeen Sixteen Fifteen Fourteen Thirteen Twelve Eleven Ten/;
 my @ones = qw/Nine Eight Seven Six Five Four Three Two One/;

  sub go {
     my $num = shift;
     my $bottles = "bottles";
     if ($num eq "One") {
         $bottles = "bottle";
     }
     if ($firstline == 0) {
         print "$num $bottles of beer on the wall.\n";
         print "\n";
     }
     $firstline = 0;

     print "$num $bottles of beer on the wall, ".lc($num)." $bottles of beer,\n";
     print "Take one down, pass it around,\n";
     if ($num eq "One") {
         print "No more bottles of beer on the wall.\n";
         print "\n";
     }
 }
     
 foreach my $ten (@tens) {
     foreach my $one (@ones) {
         go("$ten-".lc($one));
     }
     go($ten);
 }
 foreach my $teen (@teens) {
     go($teen);
 }
 foreach my $one (@ones) {
     go($one);
 }
 
 print "No more bottles of beer on the wall, no more bottles of beer,\n";
 print "Go to the store and buy some more... Ninety-nine bottles of beer.\n";
 print "\n";


People can do clever things in either language, people can write clear code in either language.

Re: Dwindling CPAN Releases

#34
post #28

Large Perl codebases are terrible - let it die.

But the small perl codebases I have are great. I have a crontab that runs every five minutes: 30 lines that use one CPAN module, no bugs in years. The code has the kind of hackiness that's okay when it fits on one screen, and it fits on one screen precisely because of that hackiness.

It's very hard to know which codebases will grow to be large - every codebase starts out small, and by the time you realise it's going to be big, rewriting into another language is expensive. Better to use a language that can scale to small codebases and large, that can accommodate hackiness and cleanness alike.

Re: Dwindling CPAN Releases

#35

Large Perl codebases are terrible - let it die.

Perl more than any other language I know depends on the self-restraint of the programmer to write readable code and not be overly clever with their syntax. I’ve worked on some large Perl codebases in the past that were as readable and maintainable as, say, Python.

Re: Dwindling CPAN Releases

#37

I used Perl for a bit but switched to Python because I was finding it harder to work out what some code I'd written a year or so ago did than to write it again, a problem I don't have with Python.

I used python for a bit but switched to Perl because it 1) Works 2) Is ubiquitous 3) Is stable 4) Is normal (semicolons, braces etc)

> 2) Is ubiquitous

On which systems do you have Perl readily available but not Python?

Re: Dwindling CPAN Releases

#38

Earlier quoted context omitted.

Really more around 1994, just before Perl 5 came out. Perl was a great sh/sed/awk replacement for a while..

What's better 25 years later for that sort of work?

Yeah I learned Perl in 2013 or so and I almost exclusively use it as a better shell+sed for text munging, which is where it excels. In my experience Python is super bad at this compared to Perl or even shell

Re: Dwindling CPAN Releases

#39
This september 2012 release was kinda huge for me. It brought venv, generator expressions (event loops) a-la nodejs at the time, sped up a lot of things as well. It was a great release and a step in the right direction. Perl6 was still a myth at the time.

I did not start using python3 until last year, but I was aware it was evolving quickly to one day become usable.

https://docs.python.org/3/whatsnew/3.3.html

Re: Dwindling CPAN Releases

#40
post #35

Large Perl codebases are terrible - let it die.

Perl more than any other language I know depends on the self-restraint of the programmer to write readable code and not be overly clever with their syntax. I’ve worked on some large Perl codebases in the past that were as readable and maintainable as, say, Python.

That is not normal.
Post reply on HN