393 points · by azhenley · 3y ago · 249 comments
1. How much should the language surprise you?
2. When the language does surprise you, should it delight you or horrify you?
surprising
^
|
|
|
delight <------+------> horrify
|
|
|
v
unsurprising
Only a sadist would deliberately design a language for the top right quadrant, but there are many esoteric languages in there. I think most people tacitly assume that all well-behaved languages belong on the bottom left: the language should rarely suprise you but in the rare case it does, hopefully it's a delight.Raku seems to overtly aim for the mostly-unoccupied top left. It's like the designers and users (two sets with apparently very large overlap) all think, "Yes, it's weird. Isn't that grand!"
Other people I showed it to felt it was more on the horrifying side, but like I said, it's subjective.
The problem with Perl (or, I assume, Raku) in production is that the responsible way to read it is like reading every single footnote in an annotated edition of Shakespeare. It sucks the joy out of it, and joy is the point. Production Perl is joyless and therefore pointless, unless you're some kind of prodigy who understands every obscure political reference and every 16th century pun without any help.
e
|
|
|
-r ------------- r
|
|
|
-eAlso debuggers. Give RR a try some time :)
Had never heard of it, looks pretty amazing, I might actually enjoy debugging now!
Yet I only hear other people speaking of it positively, so it seems they don't have that experience.
During my undergrad I implemented a semester-long physics project in about 30 minutes. The supervisor had previously taught the Programming in C module, so I asked if I had to use C; he said I didn't, so I used numpy. The code was literally just repeated matrix multiplication.
Perl has it's own healthy share of "delightful surprises" and Raku was mostly designed to eliminate perl's horrifying surprises.
Good grief, I don't miss working in Perl.
Good and grief in the same sentence about the same language ... Perl.
Delighted and horrified?
;-)
Yeah, ok, I see what you mean.
>> 0,2,4...10
> (0 2 4 6 8 10)
>> 1,2,4...10
> (1 2 4 8)
Wait... what? Is it looking the next number up in OEIS or something?
Unable to deduce arithmetic or geometric sequence from: 1,2,5
Did you really mean '..'?See, that doesn't delight me. OEIS is what's needed here.
one of my greatest pet peeves is when some words in a list, or diagram, are in their adjectival form and some are in their verbal form. "Surprising" + "horrify"
It really unnerves me. The worst is that nearly every company has this in some form in their promotional or educational materials.
E.g. here at Genericorp, we prioritize the following valurs : integrity, kindness, honest,
Etc
You get my point. Drives me nuts this kind of thing constantly slips through the cracks.
PHP is often just bland drudge, true horror in PHP land is unexpected when I encounter it.
I clearly remember reading through the synopsis and exegesis documents around fifteen years ago and being excited for what was to come, but I also remember the first bits that gave me pause. Like unspace[1].
I also clearly remember when it started dawning on me that Perl 6 (as it was still called at the time) would never see any real adoption by people that were interested in other people working with them on things, whether that be some open source project or at a company with coworkers. It was when I was reading through the advent calendar exercises for some year and realized that while I couldn't recall half the features used to solve the problems, I had been exposed to them all multiple times before. The reason I couldn't remember them was because there were so many ways to solve the problems, that it felt like just keeping up with the features and syntax was overwhelming, and that unless you used a very strict subset of the language, it would be near impossible to limit the effort requires to understand what you read from others, or even yourself some time previously.
To many detractors of Perl, this won't be an unfamiliar complaint, but I've always felt that while Perl (5) projects could easily devolve into a mess if some care wasn't taken, it wasn't that hard to exercise some restraint and still take advantage of the extra capabilities when more power was needed. Put another way, while there was definitely more than one way to do it, it didn't feel like there were tens of vastly different ways of doing it that might have been sourced from random inclusions anywhere in the codebase because of numerous ways to insert entry points into every block, leaving you scratching your head when you encountered odd behavior.
Now, it's not a problem for a language to want to reside squarely in the "this is for screwing around and trying any feature you can imagine and how they interact together", but that's not necessarily great when you are trying to accomplish something with someone else and you need to have a shared base of understanding to work from. The real problem is that many, many people in the Perl6/Raku community obviously really hoped for it to take over for Perl 5 or at least be useful for projects which might have multiple people working on them, whether they be through github or for some commercial work entity with coworkers, so they could spread its use and have a reason to use it on a regular basis. I think once it became clear that it wouldn't serve that purpose as well, many people lost interest. I know that was the case for me. I was an avid lurker on the project for well over a decade, but eventually I just couldn't convince myself it was a good idea to use the language for anything other than small test programs to satisfy my own curiosity, and eventually not even there, since if I didn't already have it installed the overhead for a small test was quite high.
In the end I guess Raku found its niche, and it's doing okay where it is (I assume, I've fallen so out of date I'm not sure), but it's sad that it seems they had to shed a lot of their original community (as someone who identifies as part of their original community) to do so, whether that's through any concerted effort on their own part or not. That is, I don't think Raku changed to be what it is, I think most people eventually realized what the bundle of features that was originally proposed really means in reality, and realized it didn't fit what they actually wanted.
There's More Than One Way To Do It
timtowdy
which I somehow did not like, but shrug.And then Python got on the bandywagon :) with:
There should only be one, preferably obvious, way to do it
or such, which, in later years, seems to be not bandied about as much.
I do agree though, that if a language surprises me, it should be to the left quadrant in this case. If a language is not surprising me, it should be delight as well.
I don't know if I call people who made / use Brainfuck sadists as much as I'd call them very geeky / nerdy.
But that's some incredibly clever stuff! I wouldn't want to use it, for like, anything, but if there was a programming based game or code golf contest or something it would probably be a great choice.
And the original article talks about math, and I have no real experience actually doing nontrivial math IRL, so perhaps it has some useful properties for people who do.
Why so? Raku is practical, I have a solid experience of doing a lot of practical things with it. It has all battery included things - type checking, overloading, named/typed function parameters, oop, functional programming - what else you need? Python seems awkward for me in comparison with Raku with all that features ...
I can't get over some of the idioms, they just don't map nicely in my head. The same reason AppleScript struck me as weird, it trys to use natural language on one hand (e.g. `my`, `say`, `sub`, `gather`) with some oddities like `@` being used for (assuming?) scoped iterations or declaring modules[0] and some other from-an-outsider byzantine syntax decisions. For instance, I can logic this out, mostly, but it would not feel intuitive to me to "discover":
```
my @bottles = (flat ((99...2) X~ ' bottles'),
'1 bottle',
'no more bottles',
'99 bottles');
my @actions = (flat 'Take one down and pass it around' xx 99,
'Go to the store and buy some more');
for flat @bottles Z @actions Z @bottles[1..*] {
say "$^a of beer on the wall, $^a of beer.
$^b, $^c of beer on the wall.\n".tc;
}
```These idioms don't click for me intuitively. Its a very symbol heavy language and the symbols often appear to be overloaded by context.
All to say, its okay! different languages isn't a bad thing, however I can't say that I'd use Raku even if it was the best fit for something, like say, a natural language parser (which based on all evidence Perl / Raku is really good at building parsers)
[0]: https://examples.raku.org/categories/module-management/Fletc...
By all means though, if folks like it, carry on. I am sure Raku as a runtime is well engineered, I respect that.
I don't know what lineage Raku shares other than Perl, but it seems to be on its own plane if you will, and thats cool.
Having come from a Pascal background, C felt weird with all of its curly braces. Then after getting familiarity with C and its ilk, Python felt weird. In fact one of the reasons I was reluctant to learn Python was because I was good enough at Perl that I didn’t see the need to learn Python. I had a similar repulsion to LISP too, until I learned s-expressions and now I can see beauty in LISPs too.
Bar for esoteric languages, whose goals are typically different from a general purpose language, most languages are designed to be useful. So once you spend a little time in it you do start to appreciate some of syntactical quirks you once perceived as ugliness
…or at least that’s been my experience with most languages (and I’ve learned a lot of programming languages over the years)
> (+ 5/3 4/5)
37/15
> (expt #C(0 1) 2)
-1
> (expt #C(3/2 1/2) 2)
#C(2 3/2)
And of course they all support arbitrary precision numbers as well: > (complex (fact 10) (fact 20))
#C(3628800 2432902008176640000)
> (/ (complex (fact 10) (fact 20)) 29)
#C(3628800/29 2432902008176640000/29)
Composition is a wonderful thing. > WHAT 1/10
(Rat)
> WHAT 1/100000000000000000000
(Num)
(There is FatRat, which does not so 'promote', but it is not the default.)See: https://docs.raku.org/language/variables#$*RAT-OVERFLOW*
We could (and have) debate whether FatRat should be the default, but imo the right expectation for an untyped language should be that very large or small numbers are represented with a floating point representation that (i) uses the FPU that's right there and (ii) sacrifices precision in the mantissa for accuracy.
Since Raku has (gradual) types, you can easily specify what you want and throw an error.
Scheme’s numeric tower has a handled exact expressions with exact representations correctly for decades, so I guess its true that is not “moving away from” unnecessary and error-prone use of inexact floats where not explicitly requested, but only because it was never there to move away from.
> (/ 1.0 3.0)
0.3333333333333333
> (/ 1 3)
1/3
> (- (+ 0.1 0.2) 0.3)
5.551115123125783e-17> The following built-in types inherit from Cool: Array Bool Complex Cool Duration Map FatRat...
Also, related and recent:
Ask HN: Are you using Raku? Pros / cons?
https://news.ycombinator.com/item?id=36922692
Question inspired by starting to watch this: Raku for Beginners, at TPRC 2023:
Look at the following page as a jumping off point for conceptual stuff. Absolutely top class:
The worst offender in my experience is the module system. There are docs around it, but they would benefit from a rewrite with a less "technical" audience in mind. The module/package distinction is difficult to wrap your head around just from reading the Modules page. The fact that the declared namespace of what you import can be different from the namespace you used to import, but the directory structure has to match the namespace for the compiler to find it... it's useful and makes sense in a strange way, but I had to learn that by fiddling around.
# in Name/Space/Thing.rakumod
unit class Thing { … }
# in UseCode.rakumod
use Name::Space::Thing;
my Thing $thing .= new: …;I remember downloading them, as multiple PDF files, one for each broad subsection (like perlsub, perlvar, etc.) under the main TOC or so, over a somewhat slow Internet cafe connection and then reading many of them.
Not only excellent content, but excellent typography and design too, even though they were mainly text. I remember, even now, thinking that the PDFs looked really good.
>https://docs.raku.org/language
Thanks for that.
Something to note is that there are ASCII equivalents[0] for every cool Unicode operator found in Raku. For example, the equivalents for ∈, ∉, ∋, ∌ are (elem), !(elem), (cont), !(cont).
[0] https://docs.raku.org/language/unicode_ascii#Other_acceptabl...
> Raku has no qualms about using Unicode operators.
You have the option. I have used this option because I want my code to be compact and expressive on screen. A good fit for careful, considered, creative unicode usage.
Or the ever popular (Jeez that's new):
> I hate the sigil thing
For me I have been using Raku/ Perl 6 because I loved the expressiveness of Perl's swiss army chainsaw. Raku is Perl to the power of Perl. It's cleaned up. It's expressive. Some massive piles of features have been built up from the good old Perl. It's great. The documentation is good - and does need some continuing work. (The comparison with Perl is tough. Perl documentation was/is just amazing.)
What's the point: Absolutely not saving typing. The point is to have a more visually distinctive notation. A math blackboard would be full of that. For example, in the code right in front of me I have a U+25C0 e2 97 80 BLACK LEFT-POINTING TRIANGLE as a custom infix operator for two specific data types. I could have overloaded an existing one... but no, the existing one still exists and it should be extra clear which one is used. When that code is in front of me, it's perfectly clear which is which. And now that the symbol is there in the code, it can just be copy-pasted. (For good measure, the unicode code point is specified in the operator's definition - but that's not necessary in day to day editing.)
The about on GitHub reads "slaps roof of [programming language]* this bad boy can fit so much [syntax sugar] into it."
They even used the language in the most recent event Advent of Code and won. https://github.com/betaveros/noulith
The author seems to be unfamiliar with both Perl and Raku's history, given that he immediately comments on the x operator for repeating strings. Which has been the case for many decades of Perl. :)
so it looks like the author has at least passing familiarity.
Perl wasn't following the PCRE standard. It was the PCRE standard. Everything else was following it. Usually with some piece missing--far more implementations should have the /x modifier.
The Perl 6 design process didn't throw it away after 30 years. It threw it away with less than 10 years. There was already widespread knowledge that Perl had gone beyond "regular expressions", and IIRC, that was even before it had implemented recursive expressions. Perl 6 would be "patterns", and they would be good enough to be used as a full grammar. The language itself could be parsed in it, and Raku sometimes is, depending on the implementation.
It says that (most) other languages followed the standard set by Perl 5, not that Perl followed the PCRE standard
But it is also true that Raku’s grammars were designed from the start to write real parsers in, whereas Perl 5’s regexes sort of gradually got that way.
haha true
> The language itself could be parsed in it, and Raku sometimes is, depending on the implementation.
That's fantastic, didn't realize.
Raku is an attempt to design a sane regular expression language from first principles, now that we know what we want them to be able to express. The alternative is being stuck with (?:this|(?>or that)) for the next 30 years.
I haven't touched perl in years but I still find myself writing regex often!
Agreed, but god-damn is it useful.
But this idea of programming in The Large vs The Small: I disagree with that comparison. A less wise person might assume that means it makes a bad language for The Large work. On the contrary, it's probably just as good as any other language at it, maybe better. The problem, as it was with other gremliny languages, is you need wisdom to use it.
Simplest example: using $x instead of @x. Any person who has used a similar language "enough" would never confuse these. In fact, the sigils actually make your life easier when reading the code, because you now know the type (well, the simple type, or with Raku, the interface) just by looking at that variable anywhere it's used. Now you don't have to go look it up, and you can do useful things with the same variable namespace using different sigils. It looks weird, and it's extra characters you shouldn't need, and you need to know what it means to use it, but it can make life easier. (https://www.perl.com/article/on-sigils/)
The problem comes for people without wisdom. The people who don't really know what they're doing. They will probably find this gremlin language a living nightmare. These people need a lot of bowling-bumpers and floaties and kevlar gloves and hard hats and GPS. Somebody let them into a store full of sharp objects and they need a lot of padding to navigate it without killing themselves.
That doesn't mean you can't build a skyscraper with the gremlin language. It just means the accident-prone unwise non-gremlins can't build a skyscraper with it. But wise gremlins can.
Tooling exist to help you and your team do the required work as good or fast as possible.
If you are using tools to gate keep juniors in your field, or that are unnecessary complex in order to stroke your own ego. Then the tool is more of a weapon against the rest of your organisation instead of something helpful.
Except that no: Many people were not even paying attention to that. And the perl sigil system - which was taught pretty much from the start - was still one of the top objections! It wasn't gatekeeping. It was people refusing to learn the tools they were meant to use.
This is actually cool
https://docs.scala-lang.org/scala3/book/methods-main-methods...
Python has typer[1] to do this with type hints. It's limited and gets ugly quickly, but I love it for simple scripts.
[0] nushell.sh
[1] typer.tiangolo.com
Should this be a fundamental lesson for language designers? Should languages come with a converter to switch back and forth between the "calm, proper english version" and the "compact, expert mode" visual?
(Without mentioning the translated programming languages like BASIC in french and such things which were discussed on HN not long ago.)
$lhs ~~ $rhs
is mostly sugar for $rhs.ACCEPTS($lhs)
and then method resolution (including multimethod handling, of course) figures out which ACCEPTS method to call and that does ... whatever the author of the type implemented.('mostly' because ~~ actually aliases $lhs as $_ and passes $_ as the argument to ACCEPTS)
- the left handside is evaluated into a value (let's symbolize this value with $lhs) - this value is passed into the expression on the right handside as the $_ (topic) variable - the expression on the right handside gets evaluated, producing an $rhs value - now, $rhs.ACCEPTS($lhs) is called
The funky thing is that the right handside of this operator is an expression, not an evaluated value... it's like an invisible code block. The implementation calls this property of an operator "thunkiness", the expression on one side acting like a thunk rather than something that can be evaluated right away. This is akin to the short-circuiting behavior of && and ||.
> This isn't weird, lots of languages have multiple dispatch. What is weird is that you can also dispatch based on a runtime predicate of the value.
Is it wrong to think of the predicate itself as a type here?
I’m in a desparate need of a message from Captain Obvious right now. I know nothing about perl