Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Golf Challenge: FizzBuzz

by perrin (Chancellor)
on Mar 03, 2007 at 06:02 UTC ( [id://603032]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Golf Challenge: FizzBuzz
in thread Golf Challenge: FizzBuzz

It contributes to the notion of perl being obscure and hard to read. It's not fair, since golf is a game, not a normal way to write code, but it still reinforces stereotypes for outsiders.

Replies are listed 'Best First'.
Re^4: Golf Challenge: FizzBuzz
by blazar (Canon) on Mar 03, 2007 at 14:47 UTC
    It contributes to the notion of perl being obscure and hard to read. It's not fair, since golf is a game, not a normal way to write code, but it still reinforces stereotypes for outsiders.

    Well, "outsiders" sometimes still confuse Perl and CGI, or even web server stuff. Who cares anyway? Some C programmers like to play obfu games too. That doesn't give C a bad reputation, though.

      Who cares anyway?
      Managers who are selecting technologies care.

      People who make their living selling corporate america the idea that Perl is a strong architecture choice care.

      So, yes, it matters to me. When the discussion of "Perl vs $other_tech" comes up, and the discussion quickly (and I mean very quickly) devolves to "Oh, Perl is unreadable", and they point to JAPHs and Golf because that's google-able, my heart saddens a bit. Even if we've lost the battle for entirely the wrong reasons, we still lost.

        All good points, but personally I think that there are other "reasons" why managers who are selecting technologies may prefer $other_tech to Perl, and they are reasons only in double quotes because they're all mostly related to FUD and misinformation anyway, so that activities like Obfu and Golf may be rather contribute to the phenomenon or be taken as an excuse for the "Oh, Perl is unreadable" pseudo-argument and I don't know how much they would weight in the overall bad reputation that Perl gets in some circles. I expect that the tons of examples alleged to be productive code but sporting bad programming habits that lie around in the net are much worse in this sense. OTOH that unreadable code is google-able doesn't mean that readable one is not: indeed it's easy to show that the latter overnumbers the former by large. If that is their argument, it's easy to counter it.

Re^4: Golf Challenge: FizzBuzz
by jdporter (Paladin) on Dec 27, 2015 at 04:45 UTC
    It contributes to the notion of perl being obscure and hard to read

    or it gets the hose again.

      Sorry. :-D

      Here's my fun solution to the problem. It's not golfed, but is intended to show a different approach from the usual modulus operator based solutions. Instead, this uses a "generator".

      use strict; use warnings; $\ = "\n"; my %label = ( 3 => 'fizz', 5 => 'buzz', ); my $end = 100; my %queue; $queue{0}{$_} = 1 for keys %label; my $i = 0; while (1) { my($n) = sort { $a <=> $b } keys %queue; # "shift" the next genera +ted number while ( $i < $n ) { print $i++; } # print any "non-special" number +s before it last if $i++ > $end; my @why_its_special = sort { $a <=> $b } keys %{ delete $queue{$n} + }; print @label{ @why_its_special }; $queue{ $n + $_ }{$_} = 1 for @why_its_special; # generate the ne +xt succeeding number(s) }
      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
Re^4: Golf Challenge: FizzBuzz
by shmem (Chancellor) on Mar 12, 2007 at 23:47 UTC
    It contributes to the notion of perl being obscure and hard to read.
    For me, it contributes also to the notion that perl is hard to write - summing both: that perl is very sophisticated.

    I like golf not only because it reveals dark corners of perl; it also reveals perl's tremendous ability to eliminate noise and produce dense expressions. Ultimately, golf tends to be noise, when shorter statement can not anymore be contrieved, but even those constructs - add a bit of air (white space) to them, a bit more verbosity, and many of them expand into beautiful, perfectly understandable nailing-downs of solutions to the problem at hand.

    Compare

    %hash = (); { my @keys = qw ( a, b, c); my @values = 1..3; for ( my $c = 0; $c <= $#keys; $c++ ) { $hash { $keys [$c] } = $values [ $c ]; } }

    which is a common idiom in many languages, to

    @hash { qw (a, b, c) } = 1..3;

    of which the latter is the golfed code version, useable in production code, and you must admit that perl to some extent is golf - well, compared to Java anyways ;-)

    Any language is "obscure and hard to read" for those that don't venture into it; and no matter whether that "obscure and hard to read" judgement is uttered as a pretext to not do so, or as a disinformed dismissive, it is just prejudice - and there being perl golf or not doesn't change that in the least.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://603032]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 04:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found