by CuriouslyC · 10y ago · 0 comments
It seems like the guiding principle was to create a language that gives you incredible freedom in terms of how you do things. While that is great in theory, in practice mentally modelling that expressiveness reduces the amount of attention I can devote to the specific problems being addressed by the code. Maybe if I put a lot of time in that would change; I don't see a big potential payout though, so I'm not going to bother.
With that being said, grammars look well designed. If all I was doing was parsing/transforming text, I would definitely consider using Perl 6.
As far as heritage, I think Perl's love of magic and concise operators is influenced more by the awk/sed/sh trio that it originally borrowed a lot of its syntax from, rather than by C++.
Java is getting increasingly painful to look at (even without operator overloading), and most of our work is still Java (due to the need to write so much of it???)
C++? Ever looked at some "advanced" Haskell code?
Apart from that, there isn't really much problem with Haskell's operators. There are only few in standard library addressing applicative and monad, and the de facto standard Lens library.
Additionally, while there is a definite elegance to its simplicity, most people have built up fairly good understanding of a number of glyphs. Using some of the additional glyphs to make the code more visually distinctive would definitely improve code reading speed.
Ultimately it seems like operator overloading is something that should be possible, but made intentionally difficult to discourage abuse.
I suppose what you said is an "occupational hazard", but not an unavoidable problem.
Yes, at the end they all are token and one has to learn them. But I miss more exact words for some value of exact. Going a little bit into the ObjC school of naming would do Perl some good.
say
This function is loosely similar to `print` in the sense it sends a version of its arguments to an output handle (STDOUT by default).But `say` is emphatically casual and human oriented in stark contrast to the formal and computer oriented `print`. For example, `say` uses human friendly gists of its arguments and truncates arguments that are absurdly long. I think `say` fits perfectly.
hyper
Er, yeah. Reasons. Onward: race
A race delivers the first of several competing concurrent computations to successfully complete (or the last to fail if none succeed). What would be clearer? start
`start` starts something that will complete later. Again, what word would you pick?I agree with kbenson about `my` and `our` and note that those were stolen from Perl 5 because they're considered to be spot on.
But following my gut feeling for completeness in bikeshedding:
say → Two things irk me, also in other languages. First is the where of writing out. Which is missing here. So I'd always use it as a method of the corresponding handle, here STDOUT. What to name the method? .write would be used for generalized writing (print in Perl6, I think). .writeLine for writing with Newline. And yes, say seem to write a custom representation of the written objects. STDOUT.writeRepresentation would be to long even for me. ;) So .. Stdout.writeRepr(), maybe.
.hyper, .race → If I understand .race correctly after some googling (the Perl6 docs seem to be very sparse), it doesn't returns the result of a race, e.g. a winner or an ordering from winner to loser. Instead it transforms an Iterable into a parallel processing pipeline with custom map/filter/... methods which do their work on parallel workers. Iterable::inParallel / Iterable::inOrderedParallel would be my compromise.
start → I don't have a Problem with Promise.start but with the corresponding global routine. Start seems so be a too often used concept for different things, most of them custom defined by the user of the language. But I don't know how pervasive usage of promises is in Perl 6, so maybe it is warranted.
I'm not super happy about some of the other words chosen (start, race, etc), but I think my/our has a nice symmetry to it.
Which begs my question: If you already have more exact words (”private“, ”shared“) for these concept, why not use them? Yes, ”my“ and “our” have these connotation too, but it works only for humans and their relations.
I guess that's my disquiet with some of these names: Perl mixes the realms of machines and humans. See also `bless` and `say`. And the anthropomorphization of abstract concepts only creates a slightly uncanny valley in my mind.
Maybe because english isn't my mother tongue. Perhaps native speaker is more ok with this mixture of concepts?
English is an expressive language as well, but I don't become paralyzed writing this comment.
As for English... Writer's block and futile rewriting cycles are real issues that basically every writer grapples with. On the other hand, coder's block isn't really a thing, and refactoring occurs infrequently compared to writing.
Another thing I like about perl is a lot of the standard library functions take an array of inputs, or a single value; and return an array or a single value.
When all you have are regeces, there's a tendency to model a parser as a finite automaton where transitions are labeled with regex matches, but given how frequently programmers deal with extracting information from text, I think there's a solid argument for grammars or parser combinators being readily available in a language. Really, any text processing task more sophisticated than grep calls for tools more sophisticated than regular expressions.
With $1 and so on for each match.
In defense of Perl 6, you could say more or less the same thing about Perl 5 and every Perl that came before it. Perl has always been optimized for cleverness, in the sense that it's much more interested in making it easier for people to write code than it is in making it easier for anyone (even the person who wrote it) to read it.
I do have trouble reading other people's code sometimes, but that's true in any language. It's easy to get thrown for a loop when someone uses a language feature that you've never seen before.