Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Why not perl have raw/native type

by sundialsvc4 (Abbot)
on Jan 09, 2020 at 02:08 UTC ( #11111222=note: print w/replies, xml ) Need Help??


in reply to Why not perl have raw/native type

“Wow.   My reputation still precedes me.” Whodathunkit?

Nonetheless, I will once again dare to chime in personally to say that "it is laughably silly," in today's technical cornucopia, to suggest that "human-perceptible slowdowns" could be attributable to "interpreter-level type conversions."   Exactly how many microseconds do you think it takes a modern-day processor to make the necessary "wasteful" decisions and conversions?

But also(!) ... Why do you think it matters anymore?

Today, most companies are embracing "containers" and "microservices," with the associated introduction of [albeit, "virtual" ...] network(!) protocols into what heretofore had been simple procedure-calls.   Now more than ever, the importance of "actual profiling" cannot be dismissed ... and, that such profiling must now be done, not merely on "the developer's machine," but in actual production environments ... and before(!!) the to-be-deployed eventual design is accepted.

Today, quite frankly, “your [Perl ...] application” is no longer the whole it is but a piece.   One interpreted language, perhaps, among many.   Certainly, now, “the sovereign master of its ... ... ... container.”   Nothing more.

Replies are listed 'Best First'.
Re^2: Why not perl have raw/native type
by jcb (Priest) on Jan 10, 2020 at 04:52 UTC

    Because microseconds add up: if you waste one microsecond on each record and process a million records, that is one whole second wasted right there, which is certainly "human-perceptible" in and of itself. As Ben Franklin famously wrote in Poor Richard's Almanac: (and I am probably misquoting from memory)

    "Beware little expenses; a small leak will sink a great ship."

    String/value type conversions can easily take enough time to cause significant problems, and the Tcl community has a significant problem with this because in Tcl, "Everything Is A String" and the interpreter does extensive tricks to make those semantics acceptably fast on modern hardware — if the code cooperates, otherwise you get what they call "shimmering" or repeated type conversions. There is an example on that page (in Tcl) with the benchmarks "left as an exercise for the reader". The same problem is less severe in Perl, because large structures do not normally have string representations in Perl and numbers that fit in a machine integer can be translated quickly, but you deceive yourself if you claim that it does not exist.

    Boxing/unboxing strings between the PV slot of an SV and raw C char * strings should be (almost) free in perl, but wrapping a C string into an SV is not free if a new SV must be allocated. Memory allocators are complex, despite an extreme level of optimization, and take significant time in even the best cases: several microseconds for each call to allocate memory has been typical in my experiments, with worst cases of many milliseconds if the system suspends the task and swaps a page. Worse, in modern systems, malloc can return quickly, but the first access instead causes a page fault, producing outlier measurements that confound profiling.

    None of this is new. Lisp programmers, working in one of the oldest languages still in use, have long had the simple advice "avoid consing in an inner loop" that expresses this exact problem.

Re^2: Why not perl have raw/native type
by chromatic (Archbishop) on Jan 10, 2020 at 00:38 UTC
    Why do you think it matters anymore?

    Because containers and clusters aren't free, and my code loops locally.

Re^2: Why not perl have raw/native type
by Your Mother (Bishop) on Jan 09, 2020 at 03:07 UTC
    But also(!) ... Why do you think it matters anymore?

    Because yoctoseconds become yottaseconds if you have the need to count them out far enough. The real question is why you think your opinion on Perl issues matters anym^W^W ever mattered at all.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2020-05-30 19:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (173 votes). Check out past polls.

    Notices?