I managed to optimize a similar problem as yours until it was I/O limited. 1/10th the CPU would not change anything in the overall system.
What else have you tried?
So, that rules out Brainf--k I guess
Any toy example can be made to look clean.
Perl uses sigils for two reasons. First, to provide a separate namespace for variables and language keywords. Second, to allow amount contexts.
Reasonable people will disagree about the value of both of those reasons, but those are the reasons why sigils exist in Perl.
You complained about the simple presence of sigils, without even stopping to think and consider what advantages they bring. I may be rude, but close-minded? No.
Imagine how ugly C would be if every variable that wasn't a pointer dereference had to be prefixed with $.
I am not necessarily opposed to meaningful sigils, e.g. Ruvy's @, but using them everywhere is a pure misfeature that hurts readability.
First off, in Perl the parens for a function call are not mandatory.
As such it is very useful for functions and variables to be visually difference, especially when you're using functions to generate parameters for other functions without any temp variables inbetween.
my W = qq_mult ConjugateQ, qv_mult RotationQ, Vector;
You can't tell at a glance what's going on and will need to look carefully. Adding sigils makes it quite clear:
my $W = qq_mult $ConjugateQ, qv_mult $RotationQ, $Vector;
Further, most languages have only one type of variable, a name for a single thing. Perl has multiple types of variables that behave differently. For example:
my $res = munge $one;
I see this and know that the function munge is passed one single variable. However, consider this:
my $res = munge @two;
If there wasn't the @ there, it would be easy to assume that munge gets exactly one argument. However the @ there alerts us to the fact that @two is an auto-flattening array, and munge will end up with anywhere between 0 and MAX_INT arguments passed to it.
Similarly with hashes:
my $res = munge @two;
They also auto-flatten, so they need to be marked as being different from scalars, but they also flatten in a very different way from array, in that they flatten into a list that alternates the keys and values. So they need to be marked differently from arrays.
Lastly, due to functions, variables, array and hashes having explicit sigils, they can be recognized by editors without any heavy analysis, enabling editors to mark these four types with different colors, which is extremely useful. Personally i don't see the sigils anymore, and instead just see the colors with which the types are highlighted.
(Bonus set: Actually C is often written with sigils too. I've often seen code where variables are prefixes with p_, s_, a_, i_, etc. They are not enforced by the language, but people often force themselves to use them. The downside: They are inconsistent from project to project and have to be relearned every time.)
Actually, that's clear as mud. Is this a function call of 3 arguments? Function composition/chaining, an array of 3 items?
Regardless, please defend how that is not just an improvement over, but better than, say:
my $W = qq_mult $ConjugateQ, qv_mult $RotationQ, $Vector;
w = qq_mult(qv_mult(CondugateQ, Vector))
or whatever the precedence and dataflow semantics are try {
die "foo";
}
catch {
warn "caught error: $_";
};
If parens were mandatory, it would need look like this: try(
sub {
die "foo";
}
catch(
sub {
warn "caught error: $_";
}
)
);
Having the nicer form in the first example is possible only because sigils are mandatory, along with auto-flattening variables and easy code highlighting.As for the example, with mandatory parens it would look like this:
w = qq_mult( ConjugateQ, qv_mult( RotationQ, Vector ) );
In production i'd write it like this: my $W = qq_mult $ConjugateQ, qv_mult( $RotationQ, $Vector );
That gives a nice balance between a low number of parens, and clarity of intent.Where is this general case? I clicked thru the presentation and it boils down to here are some obscure yet interesting and trendy corners of the computational world where Perl doesn't work well, therefore we have to change everything.
We could have had the same presentation 20 years ago, just the trendy weird corners would have to change to match the times. Doesn't mean those trendy corners are useless, just not required to write 'good code'.
Not that the goals are inherently awful. I don't do anything requiring UTF-8 at work. Someday I probably will, and it'll probably be a PITA.
I tend to see this kind of presentation as rabble rousing. "Here's some stuff that other languages care about, although you don't care, but it obviously doesn't prevent any of you from being profitable and gainfully employed writing good code so its obviously not required, which is why Perl doesn't have it. If I can convince you to care about it, Perl would gain it or more likely you'd just leave Perl. Hope you feel uplifted, here's some internet meme pictures, k thx bye" I'm not sure other languages consider it "insightful" when they get a cut and paste rephrasing of the same presentation, which is possibly the most interesting part of the whole story.
So far I have not found anything faster than perl unpack (1), but I would be happy to. I plan to investigate Go soon.
Would you have another suggestion?
1 : or marginally faster, with the advantages negated by the time it takes to write the code. However, a 10x improvement would be very interesting to me.