Reassess Perl's Plain Old-The Value of Simple and Classic

Perl is a programming language that was born in 1987. It has an old and modern origin in dynamically typed languages. The language mechanism is simple.

Perl is not a programming language that keeps up with the times, trends and popularity, and keeps up with new things.

What can be solved with a classic and simple solution will be used, and if necessary in a new field, it will be incorporated over time.

Perl focuses on text processing that is often used in daily work, and is characterized by being easy for users to use.

The backward compatibility is very high, and the system can be operated stably.

Below are some examples of how simple it works in Perl.

Reference counting GC

Perl uses a classic and simple reference-counted GC.

Characteristics of Perl's Garbage Collection (GC) --Reference Count GC

The strength of reference counting GC is that it is the simplest to implement in GC. It is an implementation that releases the object whose reference count is 0.

In the internal implementation of a programming language, the implementation is consistent and rarely changes with Perl versions.

What are the good points from the user's point of view? That is the ability to reduce latency.

In the reference counting method GC, GC is performed every time an object is destroyed, so GC does not accumulate.

Low latency is very important for non-blocking I / O, which is a web server implementation required for high performance.

Perl optimizes performance for handling large amounts of text, which is also expected to result in the creation and destruction of large amounts of objects.

The disadvantages of reference counting GC are, frankly, that the throughput is lower than that of generational GC, and in a program where objects are expected to exist for a long time, when a circular reference occurs, the weak reference function is used. It's something you have to use and manage yourself.

In the post-Perl era, reference counting GC was once regarded as an old and bad implementation, but it is clear that low latency is important for performance in non-blocking I / O, which is a Web server implementation. Therefore, the reference count GC is being re-evaluated.

Single thread

Perl programs are supposed to work on the assumption that they are single-threaded. Perl used to aim for threads, but now Perl's threading capabilities are deprecated.

The reason is that even though the Perl core itself can support threads, third-party modules such as the CPAN module do not assume threads.

That's why Perl sought to be a safe thread, but it was so heavy that it didn't reach the level required for a thread.

Therefore, Perl compiled on a Linux server, by default, chose to remove thread support and improve performance by about 10%.

In fact, the existence of threads is a factor that reduces performance in itself.

Perl chose to improve simplicity and performance, rather than choosing thread convenience and complexity. This is one of the personalities of the Perl language.

In case of misunderstanding, I'll add it, but the lack of threads does not mean that the multiCPU cannot be fully used.

Read this article about it.

You can make the most of multiCPU even in Perl

I've heard that Perl is complicated, but isn't it really?

If you read this far, you may be wondering, "Perl is said to be complicated in the world, but isn't it?"

It's half true, half wrong.

One of the seemingly complex causes of Perl is not the language side, but the syntactic sugar.

Sintuck sugar is a hassle to write many times, so let's prepare a notation that can be written easily. Also, since it is easy to make a mistake in the meaning, let's introduce an easy-to-understand notation.

For example, in Perl, the following meanings are the same, but there are two expressions.

my%person = ('name','yuki','age', 19);

my%person = (name =>'yuki', age => 19);

Perl has a syntack sugar that looks the same when viewed from a computer, but looks different when viewed from a human.

This gives the impression of being complicated on the surface.

However, Syntack Sugar has been reviewed in recent years and is becoming more and more popular in languages ​​other than Perl.

For example, the language kotlin is designed as a language that incorporates syntax sugar into the Java language while ensuring compatibility with Java.

There are also many adoptions of Perl-like syntax sugar.

However, it is also true that having multiple writing styles makes maintainability less if a good writing style is not chosen.

Therefore, before starting development, there is something called best practice from the accumulation of knowledge for a long time, so I think it is good to read it once.

A list of modern Perl writing methods

Associated Information