12 ms·
A little thing to love about Perl 6 and COBOL
- ChuckMcM 12y agoI think the thing that would make perl 6 really successful would be to call it something other than perl. Many people who have programmed perl for a long time seem to think it is an abomination of the first order, many people who have never programmed in perl think perl is some sort of dead language like COBOL or PL/1. Both groups are going to have a systemic aversion to this new language simply based on its name. And that is unfortunate. 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.
- wwweston 12y agoI think Larry Wall once suggested it converge on perl 2π (progressively approaching 6.2831853071). Not sure about the marketing value, but it's properly geeky.
- steveklabnik 12y agoVery similar to what Knuth did with Tex. I like it.
- JadeNB 12y agoActually, I think that, for exactly that reason, it's a wrong idea. Knuth's numbering is meant to suggest that, except for minor corrections, TeX is in its final form. I can't imagine Larry Wall ever feeling that way about Perl.
- steveklabnik 12y agoAt his FOSDEM talk, he actually talked a little about how Perl 6 should be flexible enough to keep on changing basically forever... given that you can edit the parser even on the fly, it seems plausible.
- chrstphrhrt 12y agohttps://www.youtube.com/watch?v=4rA4ZRErflE https://www.youtube.com/watch?v=4rA4ZRErflE Is that what P6 feels like?
- fidotron 12y agoI don't think so. The real problem with Perl is it's an aesthetic train wreck. It is possible to write beautiful Python, Ruby, Erlang, ML, Prolog, C, C++ or even Java, but I challenge anyone to write a non-trivial Perl (5 or 6) program that doesn't make you feel slightly ill. Some of the semantics seem really nice, but the syntax is utterly disastrous.
- nickysielicki 12y agoI disagree, I mostly write perl for my job and I think that most of what I write is at least equally beautiful but generally more beautiful than equivalent python.
- anom9999 12y agoI hear this argument time and time again and it's simply FUD. Bad Perl is no different to bad C++ or any other language with a flexible syntax. But it's also the same visa versa. 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.
- nkurz 12y agoI have great fondness for Perl, think the the innovations present in P6 are great, and even I agree with you whole-heartedly: continuing to call it "Perl 6" is a terrible strategic blunder. The redeeming factor is that a great name is already in common use: just officially rename it to "P6". It carries practically no stigma while acknowledging the legacy.
- chrstphrhrt 12y agoP6!
- deleted 12y ago[deleted]
- lumpypua 12y agoP6 is a sick as fuck name. They need to do this.
- kagamine 12y agoWhy not Perl 2000? It's both futuristic and original. 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.
- lumpypua 12y agoMaybe I'm missing sarcasm. Perl 2000 is the definition of out of touch. 2000 was fifteen years ago.
- davidgerard 12y ago2000 was when the Perl 6 effort started.
- henpa 12y ago
- brudgers 12y agoIt's been so long that Perl is just a language most people might have heard about but probably never used. The name isn't a marketing issue. Perl may even have some of that Lispy retro-mystery.
- cwyers 12y agoThe avalanche has already begun, it is too late for the pebbles to vote. 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.)
- machinshin_ 12y ago> The avalanche has already begun, it is too late for the pebbles to vote. thanks for the deep words, Kosh
- desdiv 12y agoI apologize for being out of the loop, but who's Kosh?
- Poiesis 12y agoI don't know what the right answer is here, but I find it intriguing that this approach is in a way the opposite of what Python ended up doing with the 2/3 split.
- kamaal 12y agoThat's not exactly true. While its true that there issues with Perl. Its still by and large a language widely used by developers across the world. There is a also a huge and a very active community which does amazing things with it. Now taking away the name means re doing some 2.5 decades of marketing all over again. No body needs to go over that all over again. There is a set of programmers with whom this won't go down well. Enterprise programmers and the hipsters.
- singingfish 12y agodon't forget the hipster enterprise programmers (aka the contractors)
- peterwwillis 12y agohow are contractors the hipsters of enterprises? if anything they're the yuppies. do whatever the fuck they want, get paid boatloads of cash, don't produce anything of value, are generally dicks. i think you're thinking of brooklyn trustfund hipsters, which are just the new yuppies.
- Ovid 12y agoI'm a consultant, produce plenty of value, have very happy customers, and I don't get called a "dick" too often. Don't pay all of us with the same brush, please :) (Note: I'm the guy who wrote the post OP linked to)
- singingfish 12y agoUs perl contractors (former in my case, a decent job in my home town with good working conditions came up) are what the enterprise turn to when they need to circumvent the bureaucracy.
- erikb 12y agoI'm certainly one who would rather learn Go or Ruby instead of Perl. Because I already know quite a lot Python and a little PHP, AWK and Bash I don't think I'll ever run into a usecase where learning Perl would be worth more than implementing a solution in e.g. Bash+Python+AWK. Around me the people all know these three languages better than Perl (or at least think so). Giving Perl6 a new name would certainly help in making it more interesting.
- riffraff 12y ago> I don't think I'll ever run into a usecase where learning Perl would be worth more than implementing a solution in e.g. Bash+Python+AWK. 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.
- erikb 12y agoThe reason I've written that comment is that I believe Perl lovers can, based on feedback like that, make better decisions about how to present their favourite language to the world. So if I would read a few articles on HN about how problems got solved with Perl in a way that Python wouldn't be able to, then I might start learning Perl soon. That's why I wrote that comment. Not for you guys to feel bad about your favourite language, but about helping you to present it better to people who don't know it yet. 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.
- 12y ago
- maxlybbert 12y agoThe funny thing (to me) is that a little while ago, the Perl 5 developers started talking about renaming Perl 5 as a branding issue ( http://blogs.perl.org/users/matt_s_trout_mst/2013/02/pumpkin-perl-breakdown.html http://blogs.perl.org/users/matt_s_trout_mst/2013/02/pumpkin... ). Because, obviously, if people don't like what you made, it's just a question of what you called it.
- 0x0 12y agoWhat is the "unicode tapeworm operator"? Google didn't yield much more than this post?
- i_cannot_hack 12y agoYeah, I would like to know as well. I tried googling, but got the same results as you.
- raldi 12y agoYou know the "ç" character? Well, that thing on the bottom is called a cedilla, and in Unicode you can attach a cedilla to anything. Şȩȩ?̧ 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.
- samatman 12y agoWe've been played: http://www.fileformat.info/info/unicode/char/1F4A9/index.htm http://www.fileformat.info/info/unicode/char/1F4A9/index.htm http://www.fileformat.info/info/unicode/char/327/index.htm http://www.fileformat.info/info/unicode/char/327/index.htm
- deleted 12y ago[deleted]
- patrickmay 12y agoTry this: perl -C -E 'say "\x{1F4A9}\x{0327}"'
- jerf 12y agoIt is the Unicode Pile of Poo [1] with a Combining Cedilla [2]. In Perl 6, a language that makes Haskell look shy with its operators, you can presumably make this into an operator. You definitely can with the pile of poo itself [3], but I don't know if throwing a combining character in there does anything bad since I've never done it myself. [1]: http://www.fileformat.info/info/unicode/char/1f4a9/index.htm http://www.fileformat.info/info/unicode/char/1f4a9/index.htm [2]: http://www.fileformat.info/info/unicode/char/327/index.htm http://www.fileformat.info/info/unicode/char/327/index.htm [3]: http://blog.mattoates.co.uk/2012/02/perl6-and-fun-with-unicode-operators.html http://blog.mattoates.co.uk/2012/02/perl6-and-fun-with-unico...
- lucianp 12y agoInteresting! I wonder what drove their decision to use rational number representation. Is it possible to turn this feature off and use floating point instead (for performance reasons, let's say)?
- wwweston 12y agoIIRC, there's several numeric types that conform to the larger `Numeric` type family: `Rat`, `Int`, and `Num` (which is basically a float). `Rat` is what falls out of the expressions the OP was working with, specifying you want `Num` is possible.
- excitom 12y agoI like the comparison to COBOL. Another IBM language of similar vintage is RPG (Report Generator) and it also uses packed decimals. The 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{ ... }
- agumonkey 12y agoBecause these are two basic building blocks of 'computation', I'd say first order. It's map and reduce in disguise (or the other way around, doesn't matter). - [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)
- cbd1984 12y agoThat's awk. That is literally the control flow style of awk, which Larry Wall copied into Perl very directly and entirely deliberately. 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.
- al2o3cr 12y agoRational-as-default seems like an odd choice. It prevents catastrophic cancellation (the ".1 + .2 - .3" from the article is an example) but at the cost of pathological complexity for some operands. For instance, summing the harmonic series (nth term is 1/n) means doing massive amounts of factoring to keep intermediate results in lowest terms...
- jzwinck 12y agoHow many programs written in Perl do you think add currency values together, vs. how many sum the harmonic series?
- reikonomusha 12y agoConsider computing compound interest using rationals. That's a practical thing that could happen akin to harmonic series calculation, where you'll get absurdly large rationals.
- smosher_ 12y agoConsidering .exp results in a Num, not a Rat, there's no problem here. I seem to recall this working sensibly years ago, where numerical types would coerce in sensible manner. Same happens with large denominators, so even if you roll your own successive approximation it will coerce away from Rat before things get out of hand.
- nemo1618 12y agoThat was my first reaction too, but I think we're reaching the point where the increased computational complexity is manageable. Efficiency has certainly never been one of Perl's selling points. I imagine there's a trapdoor available if you want to use floats anyway; actually, knowing Perl, I'm sure of it.
- colomon 12y agoThere are (at least) two trapdoors. The first is that an operation on Rats which would produce a denominator which does not fit in a 64-bit unsigned integer will produce a Num instead. (If you're okay with your denominators growing in an unbounded fashion, you can use the FatRat class instead.) 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.
- deleted 12y ago[deleted]
- upofadown 12y agoThe problem with using floating point to represent money has nothing to do with base 2. It is that money is generally treated as something countable. If you divide a dollar in thirds the resulting third of a cent is not exactly representable in base 10 either.
- reikonomusha 12y agoBase-2 is a problem in accounting because the written value doesn't always actually numerically equal what's being represented internally. With decimal, you don't have that problem, because we write in decimal. The bigger problem however is how precision is "managed" with floats, which leads to things like non-associativity of operations.
- inglor 12y agoYes, but the way we write decimals doesn't represent numbers very easily, for example 10/3 can't be represented accurately with finite length decimals (but can with rationals)
- ricardobeat 12y agoThus you'll never see anything being sold for "a third of a dollar". Accounting and finance have specific rules for rounding these, which can then be replicated with precision.
- upofadown 12y agoThe article suggested hardware BCD (packed decimals) was superior to floating point. That is true but not for the reason stated. The reason old time BCD was better was simply because they were treated at counting numbers (integers). If you use binary integers you get all of the same advantages with none of the serious headaches of BCD.
- Roboprog 12y agoExactly - accountants count cents (or maybe mils), they do not measure/approximate them. If I buy 2 apples at 3 for a dollar, the cost gets normalized to cents before further adding up on the bill. 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 http://roboprogs.com/devel/2010.02.html
- blahedo 12y agoNot to disagree with anything the OP says, but a language with somewhat more recent currency that shares the "decimals are rationals by default" advantages is Scheme (and Racket and so on). At least in Racket, floating point representation is an implementation detail of the inexact-real numbers, while the exact-rational numbers are correctly produced and computed on when you give values in decimal form. 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 :)
- kbenson 12y agoPerl 6 borrowed liberally from many sources. That does make it a very complex language, but you can omit many of the more complex features until you are more comfortable with them. There's a slide deck that touches on that point by the same author that was posted to HN recently called "Perl 6 for mere mortals" (a FOSDEM 2015 talk). 1: https://news.ycombinator.com/item?id=8953368 https://news.ycombinator.com/item?id=8953368
- bane 12y agoI'm very eager for Perl 6 1.0 to come out. I'm even planning on carving out a few weeks to learn it. 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.
- muraiki 12y agoIf you'd like to try some things out now, check this post: http://blogs.perl.org/users/ovid/2014/08/try-rakudobrew-and-play-with-concurrency.html http://blogs.perl.org/users/ovid/2014/08/try-rakudobrew-and-...
- brongondwana 12y agoAs Larry said during the talk at Fosdem - Lord of the Rings took 14 years to be written too, but it doesn't matter how long something took to write once it's done. That's all in the past.
- marktangotango 12y agoSomeone should point his declaration "01 TOTAL PIC S9(4)V9(2)." isn't packed, it's display.
- ape4 12y agoPerl 5 has packed decimal.
- kevin_thibedeau 12y agoWhat are the consequences of using rational numbers by default? I can imagine unexpected bloat when large arrays are in use that you expected to contain native floats but are now a more complex object.
- perlgeek 12y agoYou only get compact storage if you declare the array with a type constraint on the elements, so at that point you start to actively think about the numeric type, and can still convert to floating point if that's what you want.
- seesomesense 12y ago15 years and Perl 6 is still "just around the corner" Does anyone care anymore ? Perl 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.
- ScottBurson 12y agoOf course COBOL, though it has packed decimals, doesn't have general rational numbers. Zetalisp (aka Lisp Machine Lisp) was the first language I know of that had general rationals (ratios of two arbitrary-precision integers).
- rvanmil 12y agoAnother very popular ;) language which supports packed decimals (and decimal64 & decimal128 ) is ABAP. 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.0000000000000000000000000000000000
- kganser 12y agoCrockford's Dec64 proposal has some interesting background on decimal representation: http://dec64.org/ http://dec64.org/
- aidenn0 12y agoCOBOL used packed decimals, not rationals; fixed precision BCD is quite different from arbitrary precision rationals.
- arocks 12y agoI prefer Python's explicit approach to decimal types: $ 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
- herge 12y agoWhat other languages call all-important features Python calls a module in the standard library :)
- draegtun 12y agoYou could say the same thing about perl5 then :) $ 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/bignum.html | http://perldoc.perl.org/bigrat.html http://perldoc.perl.org/bigrat.html
- visarga 12y agoSeems like it's right around the corner. So, when will we have an online course with lessons and exercises for P6? I'd like a set of problems and some quick presentations to work through. 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.
- FROGGS 12y agoYou can look here for code examples for a given problem: http://rosettacode.org/wiki/Category:Perl_6 http://rosettacode.org/wiki/Category:Perl_6 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...
- perlgeek 12y ago> So, when will we have an online course with lessons and exercises for P6? If you start that project, I'll certainly support you in any way I can.
- kbenson 12y agoWhat's inconsistent about the notation of Perl 5?
- Derbasti 12y agoAnother language that supports this is Julia: In Julia, `/` is division, but `//` creates a rational number. Thus, in Julia, `1//10 + 2//10 - 3//10 == 0//1`, and `1 / (1//10 + 2//10 - 3//10) == 1//0`, where `isinf(1//0) == true` and `0//1 == 0`. 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-rational-numbers/#rational-numbers http://docs.julialang.org/en/release-0.3/manual/complex-and-...)
- cnvogel 12y ago> Another language that supports this is Julia: As does, for example, scheme (tests done in racket). > (- (+ (/ 1 10) (/ 2 10)) (/ 3 10)) 0 > (= (- (+ (/ 1 10) (/ 2 10)) (/ 3 10)) 0) #t