
Perl6: The World's Worst ML? - hyperpallium
https://aearnus.github.io//2019/04/05/perl6-is-the-world-s-worst-ml
======
f055
To put it a bit over the top: In every other language you write code. Perl is
magic and you write spells. It suppose to be this way, because the way it
works is sorcery. I don’t know about you, but I always wanted to be a wizard,
not a typist.

~~~
rat87
> In every other language you write code. Perl is magic and you write spells.

Really? Every other language?

[https://mitpress.mit.edu/sites/default/files/sicp/full-
text/...](https://mitpress.mit.edu/sites/default/files/sicp/full-
text/book/book-Z-H-9.html#%_chap_1)

> The evolution of a process is directed by a pattern of rules called a
> program. People create programs to direct processes. In effect, we conjure
> the spirits of the computer with our spells.

> A computational process is indeed much like a sorcerer's idea of a spirit.
> It cannot be seen or touched. It is not composed of matter at all. However,
> it is very real. It can perform intellectual work. It can answer questions.
> It can affect the world by disbursing money at a bank or by controlling a
> robot arm in a factory. The programs we use to conjure processes are like a
> sorcerer's spells. They are carefully composed from symbolic expressions in
> arcane and esoteric programming languages that prescribe the tasks we want
> our processes to perform.

> A computational process, in a correctly working computer, executes programs
> precisely and accurately. Thus, like the sorcerer's apprentice, novice
> programmers must learn to understand and to anticipate the consequences of
> their conjuring. Even small errors (usually called bugs or glitches) in
> programs can have complex and unanticipated consequences.

> Fortunately, learning to program is considerably less dangerous than
> learning sorcery, because the spirits we deal with are conveniently
> contained in a secure way. Real-world programming, however, requires care,
> expertise, and wisdom. A small bug in a computer-aided design program, for
> example, can lead to the catastrophic collapse of an airplane or a dam or
> the self-destruction of an industrial robot.

...

> The dialect of Lisp used in this book is called Scheme.

~~~
webreac
"we conjure the spirits of the computer with our spells" is one of my favorite
quotes about computers with "Computer programming is an art form, like the
creation of poetry or music" (Donald E. Knuth)

~~~
nemo1618
I have to disagree. Programming is certainly a _craft_ , but it is not an art
form. Programming is fundamentally a means to an end, whereas art can be an
end in itself.

Programming is much closer to swordsmithing. It is possible to create a sword
that is both deadly and beautiful, but the former always takes precedence over
the latter. Furthermore, there are clearly-defined constraints: you cannot
smith an axe and call it a sword, just as you cannot write a web scraper and
call it a raytracing engine. Art does not have this limitation. In any art
medium, you can imagine creating a horribly mangled artifact, like a canvas
smeared with random colors, or a piece of discordant music, or a violently
disorienting video game -- and yet these would still be considered art. But a
program full of syntax errors is like a cracked sword without a hilt: useless.
Art cannot be useless.

~~~
svrtknst
A cracked sword without a hilt can't be called a sword, but it can be called
art.

A program full of syntax errors may not be a valid program, but it can be
valid art.

~~~
Rerarom
It may be art, but it is not programming anymore. Therefore reinforcing the
idea that programming is not art.

~~~
vidarh
What makes a valid program is not easy to define.

Is this a valid program?

Well, probably not, right now as I'm writing this. But all it takes is someone
writing an interpreter that maps words to a suitable instruction set. It
probably won't do anything sensible, where do you draw the line? Translating
code to other forms and back has a long history _that very often has been
about doing it for the sake of it_ rather than for functionality or
practicality.

I've linked to this elsewhere:

[https://www.reddit.com/r/programming/comments/b9fqwj/93_of_p...](https://www.reddit.com/r/programming/comments/b9fqwj/93_of_paint_splatters_are_valid_perl_programs/)

But much more famous were the many incarnations of DeCSS that sought to to
blur the lines between code and other expression:

[http://www.cs.cmu.edu/~dst/DeCSS/Gallery/](http://www.cs.cmu.edu/~dst/DeCSS/Gallery/)

~~~
Rerarom
A valid program in a given programming language has a precise definition.

~~~
vidarh
Yes, but a given string of text does not specify a language.

"Is this a valid program?" is syntactically and semantically valid Ruby for
example. But in itself it will just throw an error [some might argue this
means it is not a valid program, but these errors are part of the normal
runtime control flow of Ruby]. Depending on environment, however, it can do
something else.

E.g. if your environment contains this:

    
    
        def program?; 42; end
        def valid(arg); arg; end
        def a(arg); arg; end
        def this(arg); arg; end
        def Is(arg); arg; end
    

Then the string

    
    
        Is this a valid program?
    

Will execute and return 42.

A lot of random text will be valid programs in any number of existing
languages without any intent for them to be so. But _any_ random text can be
valid programs in an infinite number of possible languages that does not yet
exist.

So the question of what is a valid program is very much a philosophical one
about whether or not the intent of the author matters in the face of
processors that can re-interpret the data in ways it was not intended.

------
grawprog
It's been a while since I played with Perl. I haven't looked at Perl6 at all.
But reading Damian Conway's addendum at the bottom, really makes me want to
play around with it.

Mostly this:

>Ultimately, I think that we’re pretty happy with Perl 6 being the “World’s
Worst ML”, so long as it can also (simultaneously) be: the “World’s Worst
Smalltalk”, the “World’s Worst Lisp”, the “World’s Worst Snobol”, the “World’s
Worst QCL”, the “World’s Worst Erlang”, the “World’s Worst Prolog”, the
“World’s Worst Python”, the “World’s Worst C”, and even the “World’s Worst
Perl 5”.

Because that was one of our design goals too. :-)

~~~
thanatropism
Wait what prolog?

~~~
aggerdom
Similarity that jumps out to me is that both include a large degree of support
for grammars.

------
ab5tract
It’s the worst ML because it doesn’t look exactly like Haskell? Oh, no, it’s
just click baiting using an easy target.

~~~
Aearnus
While I won't deny that using an eye catching title like that got me more
clicks, I was trying to joke around with regards to Perl 6's flexibility.

It's the worst ML because it's not an ML at all -- but it has the impressive
ability to be able to emulate the behavior of one.

~~~
snapdangle
Considering the amount of crap that is heaped on Perl 6 for even daring to
exist, maybe in the future you might consider using language that highlights
something that you find impressive.

Otherwise it comes off as more cheap shots. Thanks for adding your comment,
though! It helps :)

------
JadeNB
Since it's a Perl article, can we golf? Just as Conway shows that we can re-
write the Perl, also the Haskell can be re-written. In general, manually
dispatching by pattern matching on a `Maybe` type I think indicates that you
should be using `maybe`; I would want to replace

    
    
        print_maybe :: Show a => Maybe a -> IO ()
        print_maybe (Just m) = print m
        print_maybe (Nothing) = putStrLn "nothing"
    

by

    
    
        print_maybe = print . maybe "nothing" show

~~~
Aearnus
not quite the same as what I wrote -- it would be more akin to:

    
    
        print_maybe = putStr . maybe "nothing" ((++ "\n") . show)
    

or maybe something like:

    
    
        print_maybe c = c >>= (\d -> print d >> putStr "\n") 
    

but that's already too long to finish

~~~
JadeNB
According to
[https://hackage.haskell.org/package/base-4.12.0.0/docs/Prelu...](https://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html#v:print)
, `print` already appends a newline, so I think that `print m` is not the same
as `putStr $ show m` and hence that the refinements you suggest are
unnecessary.

------
kkylin
Sometimes I feel my only purpose here is to repost xkcd:

[https://xkcd.com/224/](https://xkcd.com/224/)

~~~
lostmyoldone
At least as good a purpose as any other. I would even go as far as claiming it
as one of the finer purposes one can have. Using ones abilities selflessly in
a way that helps bring a smile peoples faces is one of the finer aspect of
humanity, at least if you ask me.

Myself I mostly write too long, slightly dry comments that get mostly ignored,
or entirely misunderstood. Or so it seems at times. On the positive side, I
feel I'm getting to the point a bit quicker, and with less triple negatives
these days, any time now I might even get my point across in less than a few
hundred words. Compared to you that get it across in 9 words, and the odd
dozens of syllables, I still got ways to go!

------
ericls
what is ML?

~~~
randallsquared
[https://en.wikipedia.org/wiki/ML_(programming_language)](https://en.wikipedia.org/wiki/ML_\(programming_language\))

~~~
lucb1e
> ML (Meta Language) is a general-purpose functional programming language.

\---

Your comment would have been more useful with a short citation, but
nevertheless, thanks! I didn't expect to be able to find that on Wikipedia (I
assumed it was 'multi threaded language' or so).

So ML is a functional language. Apparently functional languages are not quite
obscure enough, we need more words and abbreviations for things!

~~~
NikkiA
Meta languages normally imply that you can program the language syntax itself
via an extensive macro system.

But then, I'm not sure perl has that facility at all.

~~~
bmn__
It does. It's small and hacky, but powerful enough to do things like
[http://p3rl.org/Moops](http://p3rl.org/Moops)

