174 points Β· by i_cannot_hack Β· 11y ago Β· 129 comments
There are neat things in this new language and there is no reason to leave the sea anchor of a name attached to it. Call it something fresh and new and it can be the cool hotness that is up and coming.
Everyone knows it as Perl 6. Therefore, everyone who would write about it after this proposed name change would say "formerly known as Perl 6," so that people know what you're talking about. All the conceptual baggage remains.
(And the reason the Perl name is a boat anchor is because someone hooked a chain to it and sank it to the bottom of the ocean. Perl didn't die from natural causes, Perl was killed by neglect - neglect caused because Perl 6 was always right around the corner and why sink more effort into maintaining Perl 5 than was absolutely necessary? So now OG Perl is stuck on 5.x from now until the heat death of the universe, because this project poisoned the well.)
thanks for the deep words, Kosh
What are you talking about? ( http://perldoc.perl.org/index-history.html ). A lot of the releases in the last decade were inspired by Perl 6 features. And Moose is clearly inspired by Perl 6.
I've spoken with people who believe the last Perl release was 5.8 (released in 2002). I believe this is caused by many Linux distributions still shipping old copies of Perl 5, but it's incredibly annoying.
I don't think the name is the problem, I think that there is just too much competition among languages. If you ask a younger person which language they want to learn, will they think of Perl at all? Where is it used? Everywhere isn't an answer, Web or application programming or Apps are answers. What can I use instead that recruiters think is cool/relevant is also a fair question, albeit a simultaneously stupid one.
Perl may even have some of that Lispy retro-mystery.
Not sure about the marketing value, but it's properly geeky.
Is that what P6 feels like?
that might be also because you are not familiar with perl6 though, a form of blub paradox.
I.e. are perl6 grammars better for parsing than anything available for python? Maybe or maybe not, but one needs to know them before being able to judge.
The strong features of Perl that I know (which might be completely wrong): Regex and huge library. Both features are not distinct to Perl anymore though. Perl's regex might be a little better than Python's or AWK's but probably not enough to make it worth learning it.
And yes learning a new language to level that you not just know the syntax but also a few of the important libraries, blogs and developers is a huge task that takes several months. If you are not a student any more you really need to think hard before you commit to something like that. Sure there are people who just learn new languages for fun as a hobby. But that's not your target audience if you want your favourite language to become more popular.
There is a set of programmers with whom this won't go down well. Enterprise programmers and the hipsters.
Because, obviously, if people don't like what you made, it's just a question of what you called it.
Some of the semantics seem really nice, but the syntax is utterly disastrous.
But I've also written some of the most maintainable code I've ever seen in my career in Perl. One project in particular was over 30k lines long (which in non-Perl languages must be worth millions of lines of code ;).
It was put aside for a few years (4 or 5 IIR), then I had to return to it to do some maintenance and inside of an hour was able to digest the code-base, make the needed changes, test and release.
Sloppy code and poor design infects every language. Perl does make it easy, but that's because Perl has a design emphasis on one-off scripts in the same way Java has an emphasis on large-team collaboration, and write-once run-once is what makes Perl so absurdly productive.
Just like with any language, you set some code standards and some overall design principles and you can write really maintainable code in Perl.
My wife has a similar story, after learning some basic Perl, she waded into a 100k line Perl codebase and in a couple days refactored some memory intensive code to use cheaper data-structures in a memory intensive part of the code. It was no-big-deal, but that's because the original team had left things well documented and wrote along sane standards.
The problem with Perl is most times people are exposed to it, it's either from code golfing sessions were code is deliberately obfuscated; or when it's basically been used as a shell scripting language and thus often written by aging Perl hackers who don't care much for code cleanliness. And sometimes people just run away screaming because they simply don't understand all the regular expressions (but to approach Perl without an understanding of Regex is a little like trying to code Java without understanding classes then moaning about the weird surplus boilerplate code)
I'm not trying to say that Perl doesn't have it's faults. It has a great many problems. But to state that Perls syntax makes it impossible to write clean code, is just a daft flamewar argument.
In python you have: dog.head.ears[0].hairs[123]
In perl5 you have: $dog->{head}{ears}[0]{hairs}[123]
I can see why some folks prefer the former.
Much of the uglyiness can come from trying to write code for another language in perl syntax. Perl lets you write code that looks live Java, or C, or many other languages, but it usually ends up looking ugly. I see a lot of this.
But when you write perlish perl, especially using modern features of the language, then... yeah. It can look as beautiful as any other language.
So, it's definitely possible to write non-trivial Perl programs without feeling ill.
I'm actually learning more of it right now, so I can clean up and modularize some of my scripts. Because my other options (ksh93, Progress 4GL, and maybe older versions of Java or C++) are even less suitable.
1: https://metacpan.org/favorite/leaderboard
2: https://metacpan.org/release/Path-Tiny
3: https://metacpan.org/release/Try-Tiny
The validation is unfortunately at runtime, but at least you get a clear error instead of unanticipated behavior. Moo (and it's bigger parent, Moose) can really help you structure your application better using roles.
https://metacpan.org/pod/Moo https://metacpan.org/pod/Type::Tiny
Edit: Don't use Params::Validate; kbenson's recommendation for Function::Parameters looks awesome!
https://duckduckgo.com/?q=CVE+2013-1667&ia=about
http://blog.booking.com/hardening-perls-hash-function.html
I would also recommend reading "Modern Perl" which is made available for free by the publisher/author at http://modernperlbooks.com/
( Also there are large codebases written in Perl ( I beleive booking.com is an example )
I also recommend installing the Perl you are using outside of the system directories. You may also find Pinto and https://Stratopan.com useful for managing your dependancies. Which is especially useful if you make your codebase modular.
For that matter, ditto for Java. Ideal Java code seems to be "not notable", rather than "beautiful". At its best, it is clean and clear but unexciting, like a Honda Civic.
Scheme (et al) are probably the more direct conceptual inspiration for Perl 6's rational decimals---the Perl 6 developers were certainly aware of it (as they were aware of pretty much all the major PL work out there :)
The bigger problem however is how precision is "managed" with floats, which leads to things like non-associativity of operations.
Self promotion: I've written about this topic before, and there is an aspect of trying to use fractions with relatively prime denominators that comes into play - http://roboprogs.com/devel/2010.02.html
There is a feature in Perl 6 that the OP didn't mention: if the denominator doesn't fit into a 64 bit integer anymore, it falls back to floating point arithmetic.
There's a type (FatRat, http://doc.perl6.org/type/FatRat) that stays precise if you really want, but the default give precise arithemtics for "usual" numbers without pathologic slow-down for pathologic cases.
Being cool seems to mean having automatic conversion to and from strings: http://doc.perl6.org/type/Cool
It has been, in fact. It's been faster than Python and Ruby for a very long time (though that's changing now with some new implementations like pypy).
> I imagine there's a trapdoor available if you want to use floats anyway; actually, knowing Perl, I'm sure of it.
Yes, if you use scientific notation (1e-1 etc.) you get floating points.
The second "trapdoor" is that you can just explicitly work with Nums (ie C doubles). If your numeric literal has a exponent (eg 1e-15), it's automatically a Num. Or you can convert any Real numeric type to a Num by calling the .Num method on it.
But the best thing is that because of Julia's type system, every subsequent operation on rationals will happen rationally as well, including (fast) linear algebra. Obviously this excludes things like `sqrt` or `fft`.
(http://docs.julialang.org/en/release-0.3/manual/complex-and-...)
As does, for example, scheme (tests done in racket).
> (- (+ (/ 1 10) (/ 2 10)) (/ 3 10))
0
> (= (- (+ (/ 1 10) (/ 2 10)) (/ 3 10)) 0)
#t $ python -c "from decimal import Decimal as D; print(D('.1')+D('.2')-D('.3'))"
0.0
Or if you prefer true rational numbers: $ python -c "from fractions import Fraction as F; print(F('.1')+F('.2')-F('.3'))"
0
$ python -c "from fractions import Fraction as F; print(F('3.1415927'))"
31415927/10000000 $ perl -E "use bignum; say .1 + .2 - .3"
0
$ perl -E "use bigrat; say .1 + .2 - .3"
0
$ perl -E "use bigrat; say 3.1415927 / 1"
31415927/10000000
ref: http://perldoc.perl.org/bignum.html | http://perldoc.perl.org/bigrat.htmlThe control flow is:
- Run a set of zero or more statements once at the beginning
- Run a set of statements once per input record
- Run a set of zero or more statements once at the end
I was always struck by the similarity to:
BEGIN { ... }
while (<>) {
...
}END{ ... }
- [record] -> [derived from record] :: map
- Begin and End blocks are accumulator/stateful logic :: reduce
sed is also a little twisted version of awk, per line mapping, with pattern spaces for accumulations.It's first order, because it can't reuse itself on smaller pieces of data, namely recursion (grammars, trees, etc)
I find it very interesting that RPG uses it, and I wonder if it's convergent evolution (relative to awk and RPG) or if one is copying the other.
`Rat` is what falls out of the expressions the OP was working with, specifying you want `Num` is possible.
You can even attach it to the π© character. The result looks like this: π©Μ§
In Perl 6, you can make anything into an operator. For example, you can write a summation function and assign it to the Ξ£ operator.
The "unicode tapeworm operator" puts these two concepts together.
[1]: http://www.fileformat.info/info/unicode/char/1f4a9/index.htm
[2]: http://www.fileformat.info/info/unicode/char/327/index.htm
[3]: http://blog.mattoates.co.uk/2012/02/perl6-and-fun-with-unico...
perl -C -E 'say "\x{1F4A9}\x{0327}"'
I've really poo poo'd the tardiness and vaporware aspects of P6, but I'm starting to get excited again.
Some of the new stuff looks absolutely sublime.
About P6 - I especially like how it becomes more functional-ish and has more consistent notation. Also, the new grammars.
It will probably see more adoption when it is preinstalled in all Linux distros.
If you start that project, I'll certainly support you in any way I can.
We also had an online training about binding C-libs (the first online training that I know of), but it was not recorded. Perhaps we should do so and put it on a youtube channel...
data result_float type f.
result_float = '0.1' + '0.2' - '0.3'.
write: / result_float.
>> 5.5511151231257827E-17
data result_packed type p length 4 decimals 4.
result_packed = '0.1' + '0.2' - '0.3'.
write: / result_packed.
>> 0.0000
data result_d16 type decfloat16.
result_d16 = '0.1' + '0.2' - '0.3'.
write: / result_d16 decimals 16.
>> 0.0000000000000000
data result_d34 type decfloat34.
result_d34 = '0.1' + '0.2' - '0.3'.
write: / result_d34 decimals 34.
>> 0.0000000000000000000000000000000000Perl is largely irrelevant, killed off by the advent of better scripting languages. The inordinate length of time that the incompatible Perl 6 has taken has not earned it any friends either.