Why is Perl's idea of ​​diversity and discipline kind to people?

Perl has the idea of ​​diversity and discipline. Why is this idea kind to people's hearts?

The meaning of Perl's diversity

Here are some examples of what Perl's diversity means.

Consider human diversity

The premise of Perl programming is that people are diverse. Human-written texts are not as uniform as computer-generated ones. Each person has a habit, and that habit is diverse, so the Perl program takes that into account.

For example, when writing the number 1, let's say that there are people who write half-width "1" and people who write full-width "1".

This happens frequently when considering human habits, but I would like to treat computers uniformly.

Perl is human-friendly and can quickly address these writings and convert them into computer-friendly forms.

# Convert full-width 1 to half-width 1
$str = ~ s / 1/1 /;

Deal with common patterns in grammatical diversity

The following is an example of dealing with a common pattern in Perl's grammatical variety.

You want to handle line breaks with string copy and paste.

When developing a system, line break delimited strings appear frequently. One example is when it is entered as a vertical column in Excel.

# Line break delimited string
bar bar

In practice, I want this to be an array programmatically right away.

There are two ways in Perl. You can use the string list operator or the DATA section.

# Make an array with a string list
my $strs = qw (
bar bar

Treat like file I / O with #DATA section
while (my $line = <DATA>) {
  chomp $line;
  # process

bar bar

Perl does not have a single array syntax for uniformity, but in response to the desire to "handle line breaks with string copy and paste", the string list operator and DATA Sections are available.

This is an example of Perl's grammatical variety, which has value and meaning.

Developers and teams need discipline

Perl has a variety of grammars to adapt to human diversity, so some discipline is needed for developers and teams.

It doesn't have to be as rigid as a coding convention, but it should be designed to be readable by other developers, designers, and infrastructure engineers.

You need to be considerate of other developers, designers, and infrastructure engineers so that Perl takes care of your writing. You also need to wonder if this code will be easier for future engineers to manage if the developer changes.

It is worth comparing the value of diversity with the value of uniformity

Perl doesn't have the idea of ​​treating humans uniformly.

As many people misunderstand, it is unlikely that system development will be successful if this one method is applied or if this one method is used.

Since the developers are selfish, as an organization's product manager, you'll want to treat this person like a replaceable, uniform component and proceed with system development.

However, in reality, we forget the fact that "human beings have a heart", which is too obvious.

In particular, creative developers who move products forward can resist, lose value, or be disappointed when treated uniformly.

I want to be able to make small mistakes, be free to choose, and be self-disciplined.

If you continue to be treated uniformly over the long term, you may become depressed.

Perl's idea of ​​diversity and discipline is kind and hopeful.

The criticism that "Perl can be written in any way and no one can read it" has been criticized from the aspect of uniformity, but please compare it with the idea of ​​diversity and discipline.

In fact, Perl has spoken as a culture in the following two messages.

  • Perl grammar needs to be somewhat diverse in order to apply to human diversity
  • You need to be disciplined in coding, thinking of the reader later

Associated Information