7 ms·
Simplicity Made Easy
- blondin 7y agooh wow, the "say" keyword is quite nifty. also, straightforward iterative solutions often lead to inefficient implementations. which is why most of us fall prey to complicated implementations that use all the tricks in the book... i don't know much about perl anymore, but in some languages, creating a new date object every time through that loop might not be space efficient.
- SwellJoe 7y agoThe magic isn't really in say. say is just print with an automatic linefeed at the end (and, two fewer keystrokes for the keyword). Perl's print (even in very old versions of Perl, dating long before say arrived) also accepts expressions as arguments, so you can write: `print join "\n", @array;` Obviously, the Date (and other) type stuff is new to Perl 6, and is quite lovely.
- coldtea 7y ago>Perl's print (even in very old versions of Perl, dating long before say arrived) also accepts expressions as arguments, so you can write: `print join "\n", @array;` How's that different from any other language? Isn't the expression argument evaluated before being passed to print, so at that point it's just a string anyway? >>> print ", ".join(["a","b","c"]) a, b, c Or, if the point is about omitting the automatic newline, comma in python suppresses it: >>> print "\n".join(["a","b","c"]), a b c
- SwellJoe 7y agoIt's not (at least most modern languages have it). I was just saying that `say` isn't the interesting thing in the examples given.
- wruza 7y ago>print ... also accepts expressions as arguments It's true for all perl functions. Unusual part, if I got you right, is that parenthesis are optional in perl. So, this: foo bar "\n", @baz; is equivalent to: foo(bar("\n", @baz)); (unless bar has ($) prototype, anyway; but then it all gets ambiguous)
- SwellJoe 7y agoMostly I was just saying that `say` isn't the interesting bit of the examples given. But, sure, Perl is nice in how flexible/expressive it is (and Perl 6 takes that even further). I think maybe that's even the most interesting thing about the article. I mean, the date math is super cool and impressive and elegant, but the various paradigm examples is maybe more fun for me, since munging dates is rarely a thing I do. TIMTOWTDI can get out of hand, at times, but it's really nice to have such beautiful concise ways to solve a problem in OO, functional, parallel, etc. styles all of which are very readable and quite concise.
- b2gills 7y agoMoarVM has gotten an optimization where it doesn't always have to actually generate the object. Though that is more about time optimization than space optimization.
- iLemming 7y ago> So, whether you prefer an imperative, functional, object-oriented, or pipelined approach The problem with this: if you give people a multi-paradigm language, they'd be using all of them. Often in the same codebase.
- dan-robertson 7y agoI think people should use all of them. Some problems are much better expressed with logic programming, others with inheritance, others with polymorphic functions. There is one school which says people ought to be giving a powerful programming language to better write powerful programs in the best way. The idea is to amplify what a single programmer can produce. Another school says you should give programmers a non-powerful language because they aren’t to be trusted. The goal is to make changing enormous codebases easy (or maybe to maximise lines of code). Perl fits into the first category and java is representative of the second. So I think this argument isn’t so much about Perl as it is a complaint about its philosophy. It could equally go on an article about the next c++ feature.
- pjc50 7y agoI'd like a definition of "powerful" that is more than just "agrees with my personal prejudices"; Perl lacks the power of a strongly checked type system, for example.
- tadzik_ 7y agoAll the examples in the post are written in Perl 6 though, which does not lack it.
- 0x445442 7y agoAny business problems that can be shown, objectively, to be better solved by one paradigm versus another can also be isolated into its own code base/module where said paradigm is canonical and ubiquitous. The problem is, this rarely happens and with a language like Perl and Java you end up with a mish mosh of hard to reason about code bases because the authors at the time were just trying to muddle through as best they could with whatever approach resonated with them.
- valw 7y agoIf people wonder, this is NOT the same notion of 'simplicity' at all than in the classic 'Simple Made Easy' talk: https://www.infoq.com/presentations/Simple-Made-Easy/ https://www.infoq.com/presentations/Simple-Made-Easy/ I think a more relevant title for this post would be: "any paradigm made straightforward in Perl 6".
- kamaal 7y agoFrankly speaking its surprising Perl 6 hasn't taken off yet. Its a language which has Java like potential. Not sure where the efficiency/speed story has gone so far(Which was preventing adoption?). But pretty much any one I have shown the language has been floored by it so far. I guess a killer framework is lacking too.
- coldtea 7y agoSurprising? 1) The Perl 5 community itself was dwindling before Perl 6. 2) Perl 6 took a good chunk of time to arrive. 3) It's still not 100% baked. 4) Perl 6 is mostly a different language. 5) Perl in general doesn't have a good "name" with todays devs 6) There's no killer app 7) Python got the data/science niche, Node got the web/services niche, Go got the backend niche - what's left for Perl 6? 8) The libs are also lacking. 9) Too complex to begin with (kitchen sink offering), at a time when devs started valuing simplicity more than before. 10) Maturity of implementation, tooling, support, etc. 11) No major commercial backing...
- hyperpallium 7y agoIn a nutshell: unlike Perl itself, it wasn't created to solve a problem. Its purpose was to "keep the gang together". Imagine a start-up that didn't set out to solve a problem... So it's a kind of research language - which is important and has its place.
- lizmat 7y ago> So it's a kind of research language - which is important and has its place I'd rather say that Perl 6 is an inspirational language. With other languages stealing ideas and features from it. But also a complete, production ready language on its own. Based on MoarVM, a virtual machine specifically designed to run Perl 6 on, but with more general applicability as well. And with some exciting developments for the GSOC: one of which should allow creation of a single executable for a Perl 6 application on Linux / MacOS and Windows.
- 7y ago
- agumonkey 7y agoperl6 seems heavily oriented toward a dsl metalanguage. Not that I'm against it.
- beders 7y agoInteresting examples. Thank you! However, I'm not sure having to parse 3-4 very different syntax constructs to arrive at the same mental model is an advantage. I do appreciate the terseness though.