5 ms·
> sub prefix:<∑> (*@els) { @els.sum } It is not exactly selling it ;-)
by rdtsc 11y ago
> sub prefix:<∑> (*@els) { @els.sum }
It is not exactly selling it ;-)
- kbenson 11y agoThat depends on your audience. There's a far more people that know mathematical summation than know how to program. Allowing a language to easily make good use of preexisting knowledge seems like a good selling point to me. Making it optional, as in provided through a module seems a sane way to gate it as well.
- agumonkey 11y agoIt would be funny it Perl6 manages to deliver what Fortress couldn't really (mathematical notation).
- rdtsc 11y agoI was just implying that Perl was jokingly called a "write once" language. It certiainly was for me. Remember starting a bionformatics project with it, and after a few months, I could not read my own code. This just reminded me of that.
- kbenson 11y agoThere are definitely those times when that happens, but I find it's mostly when the code has grown without a plan, and that it's mostly a problem for every language. That said, Perl (5 or 6) can easily get you in trouble if you aren't disciplined and decide to take your one liner and make a program out of it without taking a bit of time to convert it into a more readable form. I'm still undecided on whether Perl 6 takes the TIMTOWTDI motto too far. There seem to be multiple purely cosmetic ways to do something (sigil-less variables), and that's less of a "more tha none way to do it" thing and more of a "more than one way to make it look" thing (colon method call syntax), and I'm not sure how that will work in practice. Then again, there are lots of things that I think are unequivocally much better, such as method signatures (which you can approximate in Perl 5 with Kavorka[1]) and OOP (which Moops[2] in Perl 5 seems to do a good job of bundling the various Moose family modules together for, with Kavorka). 1: https://metacpan.org/pod/Kavorka https://metacpan.org/pod/Kavorka 2: https://metacpan.org/pod/Moops https://metacpan.org/pod/Moops
- fibo 11y ago"Perl gives you enough rope to you .." cit. Larry Wall. It is cause Perl is very expressive. I usually write code even my boss can read, and looks trivial remember Perl is inspired on natural languuages. On the other hand you can write very cryptic code, in every language, but Perl can be very tricky: use comments for the future you. Learning Perl was a great excercise, after that I could learn JavaScript really easy not only cause they are so similar but cause Perl and its culture teaches you about programming. It is a milestone.
- Montezuma123 11y agoI will say that I started using Perl5 recently (big python fan). I expected everything to be crusty and bad. CPAN worked great, and the doc...my GOSH the doc is sooo good. It is everywhere. In my command-line, gazzillions of websites. I forgot what it was like to not be dependent on StackOverflow.
- collyw 11y agoPerl Monks is far better than Stack Overflow for Perl questions, as they actively encourage the discussion that Stack Overflow avoids, leading to a greater understanding afterwards as opposed to just something that works.
- Montezuma123 11y agoI can't count the # of times a super helpful question was closed on StackOverflow for being "off topic" or being likely to cause a flame war. I do like Perl Monks, but wish the format was a little different UI wise. Def still usable though.
- txutxu 11y agoI work with legacy third party perl code every day. It's very rare if I need to check the docs reading the code. Very exceptional, no issue. If you cannot read your own code, maybe the issue was your level at the time? no offense intended.
- labster 11y agoIs not being able to read code from six months ago just a Perl thing?
- ionforce 11y agoIt's an every language thing, but it is magnified with code typically produced by people who write in Perl.
- collyw 11y agoI have inherited code from bioinformaticians with the same problem, except that it was written in Python.
- jqm 11y agoAll languages no doubt have that problem. But I firmly believe some have it worse than others and Perl is at the top of that list in my opinion.
- chris_wot 11y agoHow is that different from C or any other code? Every programmer has had the "what the fuck did I write?" moment at least once in their career...
- greggman 11y ago> There's a far more people that know mathematical summation than know how to program Source? My experience is about 100 to 1 the opposite. I know tons of programmers that don't know math notation. I know few people at all, even non programmers, that know math notation. I know 8yrs old that code. They don't know any math.
- thfuran 11y agoAren't summations taught in high school?
- Elrac 11y agoYes, but I think they're the kind of knowledge you hold on to for the test and then, unless you become a mathematician, you avoid for the rest of your life. I understand "sigma notation" and related mathematical symbolism, and can work my way through understanding a formula if I really need to. But given a choice, I let my eyes glaze over and pretend I didn't see the formula. I'm one of those programmers, and I think typically so, who consider math a distant relative whom I give a friendly wave from a distance but not one I like to corner for an intense heart-to-heart.
- kbenson 11y agoBut you've seen it before, and if you saw it again and you didn't remember exactly what the symbol stood for, you would probably still remember it was math related, and be able to look it up fairly quickly. There's a whole class of domain symbols that fall into this category, and even for the people that don't know them immediately, if they look them up, they might find useful info that conveys some of the original developer's intent. For example, Δ, an searching for it will probably bring you to Wikipedia[1], where some common usages are easy to see (and "change" is the top one, which is what I would assume when seeing it). Increased symbolism front-loads learning to increase expressiveness later. If we've already front-loaded that learning to a small or large part on a large chunk of the population, that can greatly change the equation for how much it slows initial understanding of the code, and thus it's usefulness. As I mentioned elsewhere, we generally use '+' and '-' in programming languages because everyone already knows what they mean. We could just as easily use add(a,b) and subtract(a,b), and in some languages we do so, but in general there's so little friction in using the most basic math notation it's accepted without qualification as a better way to do it. 1: https://en.wikipedia.org/wiki/Delta_(letter) https://en.wikipedia.org/wiki/Delta_(letter)
- kzrdude 11y agoThis is where I turned off and realized it was a joke.
- grondilu 11y agoI would have written it sub prefix:<∑> { [+] @_ } would you have liked it more? (I personally find it more "perlish")
- JadeNB 11y agoI've never written any Perl 6, so this comment could be badly foolish. As you point out, the suggested `∑` is just sugar (for some value of 'sugar') for `[+]`. In Perl 5, one could easily alias subroutines using, for example, `* a = \&b` (space inserted to fool Markdown). Is there any analogue in Perl 6, so that, say, `* ∑ = \&[+]` or its modern variant would automatically inherit the parsing semantics without having to go through the cumbersome process of declaring a new sub just to pass its arguments unchanged to an old one?
- grondilu 11y ago[+] is not a function with a name, as it is the result of the metaoperator [] to the function &infix:[+]. Thus you really need a closure.