An "expressive" language is a language that allows you to easily express logical concepts in code.
People often call Perl expressive since it allows you to use many different approaches to express a specific concept, so it's very flexible in this regard.
(There is a lot of debate about whether this is a good thing or not, though...)
In this context I think it means you can do a lot of things without writing too much code.
For example one-liners:
$ echo Foo | perl -pe "s/o/e/g"
Fee
Or Moose:
# A simple Point class with x and y coordinates.
package Point;
use Moose;
has [qw/x y/] => (is => 'ro', isa => 'Num', default => 0);
1;
Or the concept of context:
my @array = qw(foo bar baz);
my $count = @array; # three
Or the Schwartzian transform:
@sorted = map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [$_, foo($_)] }
@unsorted;
This is good, because you can have things done the way you want. (If you feel like shotgunning through the problem, you can.) On the other hand it’s sometimes bad, because you can have things done the way you want :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With