Hacker News new | ask | show | jobs
by arianvanp 4764 days ago
Makes me cringe to hear someone say `|>` is the `pipe operator`.

If you're thinking operators your probably doing it wrong in functional programming.

It's simply another higher-order function that enables function composition. g |> f = λx → f (g (x))

edit: My reasoning might be really flawed as I have no idea if erlang/elixr can define functions that look like `operators` and therefore don't know if `|>` is built in. Yet, you shouldn't assume |> is some magical thing, but respect it as a higher-order function in my opinion.

7 comments

The word "operator" need not imply "a built-in construct"; instead it's often used to describe a name made up of symbols, which is how it appears to be used here. In F#, for instance, where |> is used frequently because it improves type inference, it is defined in the standard library as `let (|>) x f = f x` (note that the definition you give is actually for the related (>>) operator). Would you claim that someone is "doing it wrong" because they call (+) the "addition operator"?
ye you're right. (|>) = flip ($) now I come to think of it.
> If you're thinking operators your probably doing it wrong in functional programming.

I'm sorry but that simply makes no sense. Yes, many FP languages have custom & customizable operators. They still have built-in operators which are actual operators for real. And there are also FP languages which do not have custom & customizable operators. Erlang is one of the latter.

> My reasoning might be really flawed as I have no idea if erlang/elixr can define functions that look like `operators`

It can not.

> If you're thinking operators your probably doing it wrong in functional programming.

Stating that the creator of Erlang is doing FP wrong is a bold statement.

Two points:

* Erlang, nor Elixir, has currying. And they can't define their own infix identifiers/operators. This severely limits the way the language works, and you need built in support. * the |> notion is not even a higher-order combinator in Elixir. It is a special-case built-in you cannot redefine.

I agree with you that this is a bad design decision if you are to evolve the Erlang language :P

You're probably the only one who got my point. That's not because others were stupid, but because of my horrible formulation.
Elixir does have currying/partial application.

I can say:

plus_one = &1 + 1

Enum.map [1,2,3], plus_one

Partial application and currying are not the same thing. (That's not a value judgment, they're just different things.) That's partial application.
> Makes me cringe to hear someone say

Do you have an inkling of who the 'someone' is in this case?

Let me help you, in case you don't:

http://en.wikipedia.org/wiki/Joe_Armstrong_%28programming%29

I'm not going to change the way I speak based on who I am speaking to. fine, accuse me of speaking wrongly by telling me why and i'll accept it. I made a bit of a bold statement, an I appreciate people correcting me appropiatly by giving me valid reasons why my statement is wrong. But basing your argument on an appeal to authority is just a logical falacy and is annoying.
> But basing your argument on an appeal to authority is just a logical falacy(sic) and is annoying.

But you are also making statements full of adjectives and subjective descriptions such "makes me cringe" and "probably doing it wrong". That is quite a bit of flair for someone expecting logical and nice refutation of their own statements.

If you jump in the middle of the discussion, throwing around "you're wrong, you're wrong, you're wrong" at everyone then don't be surprised you get replies that are equally accusatory and harsh.

BTW I still don't see what is really so cringe-worthy in calling it an operator. It is just syntactic sugar. Call it green tomatoes if you want. Joe calls it an operator. I understand what Joe means. It is like yelling at someone talking about function default arguments and saying "ha! bit it is all assembler underneath, all this is wrong, it is just registers and pointers!".

And when someone says that the original author of Erlang is speaking wrong about a basic mechanism of... Erlang, I don't think there's going to be many objective responses, probably more pointing and laughing.
It's not a basic mechanism of Erlang, but Elixir.
I'm not well versed in either language, but from the examples provided in the TFA it looks to me like the capability/mechanism of the operator appears to exist in Erlang and Prolog, while the operator syntax itself is only in Elixir.
> basing your argument on an appeal to authority is just a logical falacy

This is incorrect. An appeal to an authority is a valid argument. The fallacy is an appeal to a false authority.

When you make a statement like "it makes me cringe", you are making an appeal to your own authority. Cringe-worthiness has nothing to do with reasoning or logic: it's only relevant if your opinion matters, and your opinion only matters if you're (1) the audience of the argument or (2) an authority. If you do not claim to be an authority, you are dismissing your own argument: you acknowledge its own fallaciousness.

https://en.wikipedia.org/wiki/Argument_from_authority

I have to disagree on this one. Even if you appeal to a True authority, you're just moving the onus to the one you're arguing with. You're not giving a valid argument, but ask your opponent to go find a counterargument himself. I think many eod consider that a fallacy.
> Even if you appeal to a True authority, you're just moving the onus to the one you're arguing with. You're not giving a valid argument, but ask your opponent to go find a counterargument himself.

This is always the case, though. If I say, "Fish need water, fish are good, so we should provide water," you have to independently verify my claims yourself or choose to accept the assertion.

No claim is exempt from this.

> I think many eod consider that a fallacy.

Sorry, I don't know what an "eod" is.

Unless you mean "end of day", in which case you're making an argument from popularity which, I'm sure you know, is a fallacious argument because popularity isn't a valid authority for determining whether or not something is a fallacy.

Blah blah blah. Knowing about logical fallacies can be instructive for the skeptical among us, but often bringing them in every-day discussions is pedantic.

Regardless of whether the statement was an appeal to authority, regardless of whether Joe Armstrong or arianvanp are "true authorities" or if that's even objectively determinable, regardless of whether we consider inductive arguments as persuasive... regardless of all that.. we have brains. You can see what Joe Armstrong wrote. You can pick up Erlang and Elixir and use them yourself. You can see what arianvanp wrote. Some of us (excepting jacquesm, of course) have the capacity to use our own brains to consider the validity of the arguments at hand without having to resort to the lazy inductive argument that Joe Armstrong is smart about Erlang and therefore is probably right.

If you have a brain, use it instead of checking it in at the door.

> Knowing about logical fallacies can be instructive for the skeptical among us, but often bringing them in every-day discussions is pedantic.

That's why I wrote the comment. arianvanp brought them up, was pedantic, and also wrong about their usage.

It's not an appeal to authority. It's Bayesian probability.

P(author_doing_fp_wrong) < P(author_doing_fp_wrong | author_invented_erlang)

Not sure if you got your sign backwards or if this is a really nerdy burn on Erlang.
damn! sign backwards! /blush
Even with your operator fixed, this is still bull. This only only instructive if you have zero external knowledge regarding the context. Since we can read Joe Armstrong's words, and since we can read arianvanp's objection, and since most of us have brains, we can and should do a lot better than "bayesian probability".
When in a hole, stop digging.
Why has this comment not been voted out of existence? If arianvanp is wrong it's because he's wrong. If his way of phrasing things is uncalled for or downright rude, then it's uncalled for or downright rude. But it doesn't matter if it was Joe Armstrong, Albert Einstein, or Sloth Fratelli who he is responding to.

See masklinn's response for how to avoid stupid responses like this one. Or kvb's. Or even rtdsc's.

> Why has this comment not been voted out of existence?

Because when you make a bunch of rude and unfounded accusations against not 'an' authority in the field but 'the' authority in the field you come across as not having done your homework.

It would be like telling PG what hackernews is supposed to be (I think we've had that one) or to tell Abelson why he doesn't understand the basics about lisp or scheme.

At some point appeals to authority are perfectly ok, not every dumb point made in an insulting and rude way needs to be refuted by textbook rules.

And really, not being aware who the players are and attempting to play the game is a-ok with me, just make sure that you have your t's crossed and your i's dotted when you do and nobody will call you out for making a fool of yourself.

And yes, it does matter whether it is Joe Armstrong or not, and how matters regardless of who it is.

But he isn't 'the' authority in FP, simply 'an' authority. And this particular thread seems to be more grounded in discussing FP concepts than Erlang.

I had a similar thought when reading the article, unaware to who wrote it... I wondered how currying and the like factored into the language, and thought that comparing |> to unix pipes was a big simplification. And whilst this simplification might be intentional for the article's purpose of giving an overview, it instead read - to me at least prior to realising who the author was - like the author was not fully informed on its use in other FP languages.

> But he isn't 'the' authority in FP, simply 'an' authority.

Sorry to see mr. Armstrong does not meet your requirements, would you like to take the matter up with mr. McCarthy instead?

> And this particular thread seems to be more grounded in discussing FP concepts than Erlang.

So? That makes it ok to speak in a disparaging manner about someone who did more for reliability of complex FP systems than anybody else that I'm currently aware of? And to fail to even do the author the courtesy of checking his/her credentials before firing off an ill thought out rant?

Really, not recognizing your elders and betters, -5 points, not knowing who they are, -50 points and being dead wrong on top of all that -500. The article is interesting for one reason only, it's Joe Armstrong writing about a new entrant on the VM that he designed and for those that are interested in such stuff his opinion carries a lot of weight. To dismiss his writings as the drivel of just another anonymous 'someone' who couldn't be bothered to do his homework about FP is ridiculous.

Anyway, I'm done with this thread.

> Anyway, I'm done with this thread

I'm glad you've decided to follow your own advice and stop digging.

Ignoring your original reply to arianvanp, you'll see that interesting discussion has arisen in response to their original bold statement. This is why I read HN.

You have entered this thread, seemingly to show off your superior knowledge of PL creators, without actually contributing to the discussion. My attempt to diffuse things clearly had the opposite effect (FWIW, I was trying to point out that the words used in the article could lead to the interesting discussion that has happened, and certainly wasn't defending an attack on Joe Armstrong - an attack that you have read into but I don't feel is there).

Instead, what has been achieved?

To go meta for a moment, this is the problem with with HN that gets discussed from time to time (and I am well aware that I'm replying to a highly active user). Why do people feel the need to be so combative, just to win internet points (something someone is down 555 of by your count)? Perhaps after having pointed out who the author was, you could have explained why that matters. Maybe we aren't all as clever as you are.

Yes, arianvanp's original post was also phrased in a somewhat combative way, but at least it sparked interesting discussion. This subthread is the antithesis of that.

Because when you make a bunch of rude and unfounded accusations against not 'an' authority in the field but 'the' authority in the field you come across as not having done your homework

But why? In the same situation but talking to a non-expert, do you magically come across as having done your homework?

What's wrong with telling Abelson he doesn't understand the basics about lisp? Are these people infallible? Does your hero-worship allow for all-knowing experts to sometimes forget shit? Does senility factor into the equation, or do we drop to our knees at every utterance until they die?

Personally, I'm just not sure what the association with monads is supposed to be.

Shouldn't Joe Armstrong know what function composition is when he sees it? (Although it is really weird that it slots into the first argument position.)

I suspect Joe is referring to the fact that when you desugar "do notation" you arrive at basically a lot of function composition:

    do x <- f
       y <- g
       return $ h (x + y)
becomes

    f >>= (\x -> g >>= (\y -> return (h (x+y))))
I don't think Joe does a lot of Haskell, so I'm not sure his vision of monads matches up with a Haskeller's though. For me, the fact that monadic do-notation desugars this way is less meaningful than that a monad is anything that supplies the functions bind and return with the necessary types. After all, not every block introduced by "do" is an SSA-friendly looking series of assignments leading up to some function call.
slotting into the first argument position is not weird, it's the functional idiom for the pattern "take a single value and apply a sequence of transforms (some of which have side inputs) to it". in an object-oriented language it would be foo = bar.f(args).g(args).h(args) where bar is being "piped" through the functions f, g, and h.
Yes, my functional programming is holier than thine.