Hacker News new | ask | show | jobs
by Miky 5316 days ago
It makes me sad that having monad sugar is now just a given feature for a functional language.

Especially when that language has unrestricted side effects and the example code using the monad syntax uses those side effects, completely obviating the need for, and in fact rendering useless, monads as used in the example.

This is cargo cult programming at its worst. Including monad sugar because it's the thing to do, without even understanding what monads are or why they're useful. This is quite clear from the "tracing monad" example code. This "tracing monad" is like the Writer monad, stripped of all utility and sense.

What drove you to unleash this horror on the programming masses, Moggi? Why have you cursed us so?

2 comments

The example sucks but is very simple.

I didn't add monadic sugar just to be part of the "cargo cult". I added it because I'm eventually going to use it to implement an automatic continuation-passing transform. I've done a similar thing before with ClojureScript's macros:

http://brianmckenna.org/blog/cps_transform_js

Monadic sugar is probably not the way to go for implementing an automatic continuation-passing transform. Why not just do macros?
Monads suit the problem nicely and it's been done in quite a few languages already:

http://lambda-the-ultimate.org/node/4117

http://ocaml.janestreet.com/?q=node/100

http://en.wikibooks.org/wiki/F_Sharp_Programming/Async_Workf...

This is something that JavaScript desperately needs.

Macros aren't so nice for this stuff in non-homoiconic languages.

I previously had a someone antagonistic comment, but I decided to remove it.

I think that finding ways to notate asynchronous code cleanly is a pretty awesome goal, and I hope you find success in your project.

Monads are not simply a tool for managing side-effects. Why would you consider parser combinator/List Monads useless in a language with unrestricted side effects? Writing monads without sugar becomes clumsy very quickly and monads have been demonstrated to be useful innumerable times, why wouldn't you support some syntactic sugar for it?
I never said monads are made useless in a language with unrestricted side effects. I understand very well their utility even in the presence of side effects.

However, if you'll take a look at the example monad code, the bind and return methods themselves use side effects. I think that speaks for itself.

So, his example monad is bad. Indulging in hyperbole and invoking Moggi can at best be seen as attention-seeking behavior and at worst as an underhanded FUD tactic to turn people off the project. Peaker has pointed out the problem with the example monad without indulging in antics. There are better ways to communicate the mistake made in the example program. There is nothing irrecoverably terrible with Roy, but your comment conveys a false impression to the uninformed reader.
My issue is not with Roy. It's absolutely fantastic to have a functional language that compiles to JavaScript.

My issue is with the use of monads in particular, and I think my comment pretty well communicates that it's solely about that. I don't think it conveys a false impression about Roy as a whole at all.

Your statement that my comment "can at best be seen as attention-seeking behavior and at worst as an underhanded FUD tactic to turn people off the project" is just absolutely ridiculous. I have nothing against the project Roy, and I wish it nothing but success. Why would I possibly have any motivation to use underhanded FUD tactics to turn people off the project? And I don't even know what to say to your accusation of attention-seeking behavior. In what world is initiating a productive discussion about an important issue, and not in a self-promoting way at all, "attention-seeking behavior"? Get off your high horse.

> In what world is initiating a productive discussion about an important issue

A toy example is not an important issue. As for initiating productive discussions, I will let your comments speak for themselves

1. This is cargo cult programming at its worst

2. What drove you to unleash this horror on the programming masses, Moggi?

3. Why have you cursed us so?

4. It makes me sad that having monad sugar ....

5. .... stripped of all utility and sense.

The toy example is a microcosm of the important issue. The important issue is the use of monads in functional programming.

How is a discussion not productive just because it's not framed in the most formal language possible?