News for hackers. Stuff that matters.
Re:The Four Flaws of Haskell by ioseph on Monday August 15, 2016 @01:48AM (#12288885)
Readability : although I'm not proficient in Haskell it seems to lend itself towards perl-like clever one liners.
Re:The Four Flaws of Haskell by rtpg on Monday August 15, 2016 @01:58AM (#12288909)
I share this feeling , esp. when each third party lib wants to introduce some variant of <$../<>).

But I've found some of the more common symbols end up being how you think about your code when you become more versed.

The big one is <$> for fmap. If you have some functor/monad/thingy, you'll often be like "I have this pure function that I want to apply to the inner value of my functor", and <$> is the perfect analog to $.

The high abstraction level of Haskell makes reaching for these really tempting and easy. And the alternatives are verbose and harder to read in many situations.

compare "capitalise <$> readStrLn" to

    do val <- readStrLn
       return capitalise val

(though "fmap capitalize readStrLn" isn't too bad)
Re:The Four Flaws of Haskell by taylorfausak on Monday August 15, 2016 @08:36AM (#12289996)
This post explores the differences in those two styles: http://www.yesodweb.com/blog/2015/10/beginner-friendly-code-...

> It seems like my progression as a Haskeller results in forcing myself to write in a harder-to-parse style to make my code shorter, to satisfy some base need for "better" code, even though by most measurements I just made, the longer/explicit/pattern matching code is in fact better.

Re:The Four Flaws of Haskell by chriswarbo on Monday August 15, 2016 @09:00AM (#12290100)
To be fair, "<$>" is a synonym for "fmap", so "fmap capitalise readStrLn" is the go-to alternative.

The "do" example is not only more verbose, but less general (it only applies to monads rather than all functors), and relies on special syntax (despite its awkwardness, "<$>" is still just a function call).

You could also do "capitalise `fmap` readStrLn", which is kind of intermediate between the two :)

Re:The Four Flaws of Haskell by Iceland_jack on Thursday August 18, 2016 @06:07AM (#12311376)
`ApplicativeDo`[1] do-notation works with Functors

[1] https://downloads.haskell.org/~ghc/master/users-guide/glasgo...

Re:The Four Flaws of Haskell by eof on Monday August 15, 2016 @09:39AM (#12290332)
Interesting, readability is something I would put on a list of upsides of Haskell.

I agree that the abundant use of operators can make things difficult in some cases, but this is largely naivety on the part of the reader rather than complexity like Perl.

Perl's obfuscated one-liners are just vanilla things that every perl programmer will understand, while Haskell's weird lines are generally package specific operators that one needs to become familiar with.

Once familiar (unlike in Perl) a seasoned Haskeller will be able to grok a lot of what is going on very quickly.

As a further point, the strictness of it all makes understanding the entire system a much easier experience than many other languages.

Re:The Four Flaws of Haskell by Ericson2314 on Monday August 15, 2016 @02:01AM (#12288925)
The article is about things that impact professionals (thought they also beginners). For better or worse, experienced Haskell users can read the one liners just fine.
Re:The Four Flaws of Haskell by b34r on Monday August 15, 2016 @02:21AM (#12288990)
Sure, but you've also nuked a developer's ability to easily onboard and understand the codebase with "clever" one liners. Good, maintainable code tends to trend toward lower cognitive load more often than compact solutions.
Re:The Four Flaws of Haskell by nilkn on Monday August 15, 2016 @02:27AM (#12289007)
I'm generally of this opinion, but with Haskell I think more often than not the "clever" one liners are actually not clever -- they're just completely standard usages of fundamental language constructs, and they only appear clever to people who haven't used the language.

It's very common to see newcomers or people who've never used Haskell at all mention <$> and friends in this regard. Then someone will say that if you just used do notation explicitly it'd be a lot clearer. And then someone will point out that do notation might look familiar, but semantically it can be spectacularly different from what one might expect from truly imperative languages (e.g., when using the nondeterminism of the list monad). So by encouraging overuse of do notation, you're making the code feel familiar, but you're not actually making it more understandable; if anything, you're making it harder to understand, because you're making it look like something that it's not.

Additionally, while do notation is very generic and broadly powerful, <$> does exactly one thing: it applies a function to a wrapped value, producing a new wrapped value. Once you've used Haskell a fair bit, you very strongly internalize this and tend to immediately understand code involving <$>. If all this code were expanded out to use do notation, you'd have to spend a lot of extra timing reading through the do notation to realize that, oh, this is just a re-implementation of fmap, over and over again.

Re:The Four Flaws of Haskell by blowski on Monday August 15, 2016 @02:47AM (#12289065)
Is that then a limitation of the language? I've only briefly toyed with Haskell (and most of the time I use PHP, so my opinion is almost moot). But from what you've written, it sounds like it's hard to write Haskell that's expressive for novices and experts at the same time.
Re:The Four Flaws of Haskell by catnaroek on Monday August 15, 2016 @04:36AM (#12289305)
> Is that then a limitation of the language?

How exactly is it a limitation that the language has greater expressive power than most?

Haskell does have serious limitations: laziness is a horrible default, modularity is a joke, reasoning about performance is very difficult, and the correctness of most basic abstractions is conditional on the user never ever using a partial function, not even accidentally - or else hilarity ensues.

But functors, applicatives and monads are godsend.

Re:The Four Flaws of Haskell by sclv on Monday August 15, 2016 @04:25PM (#12293134)
If you think reading X loc/min is the norm, and then hit a language where you read much slower, you might think "this is hard to read". But if you're reading the same density of _logic_ at the same speed, then that's not a drawback. If the haskell is say 3x as dense in logic, then reading at 1/3 the speed isn't a drawback at all...
Re:The Four Flaws of Haskell by nilkn on Monday August 15, 2016 @08:58AM (#12290093)
Personally I don't think it's a limitation of the language so much as it is an artifact of Haskell's relative uniqueness. Most programmers have never encountered a type system stronger than that of, say, Java, so they have little to no precedent for this sort of language. Consequently, the very idea of a generic fmap (i.e., <$>) is foreign and new.
Re:The Four Flaws of Haskell by eof on Monday August 15, 2016 @09:50AM (#12290386)
> it's hard to write Haskell that's expressive for novices and experts at the same time.

That is definitely a fair analysis. Though I suppose that is a limitation it is not necessarily a severe one, or one that should matter to most people putting code in production.

Haskell in general is extremely unfriendly to novices; but what you lose in accessibility you gain ten fold in maintainability.

Haskell in general requires far, far more upfront problem solving than something like PHP or Javascript. It's easy to take for granted the implicit coercion, smart defaults, overlapping scopes when working in PHP to iteratively work on a problem.

In haskell you are more likely to need a pretty good idea of what the final solution will look like before you even get the code compiling the first time, unlike php/js where you can write one or two lines, check the output, rinse and repeat.

Re:The Four Flaws of Haskell by bad_user on Monday August 15, 2016 @05:24AM (#12289397)
Cognitive load has nothing to do with your ability to "easily onboard".

If you can't understand German, would you say that usage of German increases one's cognitive load? No, that would be preposterous. If you need to speak in German, then you hire Germans or people willing to learn the language. Onboarding might be a challenge, but it wouldn't have anything to do with the performance of those that do know German.

I myself speak English as a second language, because I had to learn it in order to do my job. Seeing you're from NYC, there's a high probability that English was imposed on you from birth. Good for you given our profession, but a lingua franca is context sensitive, temporary and English isn't even the second most spoken language.

And do you know what language is more universal than all natural languages and that doesn't change much? Math. And math uses symbols, not English words. And Haskell is much closer to math than all mainstream languages.

Re:The Four Flaws of Haskell by fusiongyro on Monday August 15, 2016 @02:40AM (#12289043)
There are much bigger fish to fry than "clever" one-liners when onboarding a new Haskell programmer.
Re:The Four Flaws of Haskell by pyrale on Monday August 15, 2016 @06:30AM (#12289544)
My problem about the one liners is not the introduction of new symbols so much as it's the application of many functions on the same line.

experienced devs may have some talent reading more complicated expressions. It doesn't remove the fact that the expression requires many mental steps to visualize, and that for each of these steps, even an experienced dev may slip.

An example of this is function assembly. When you combine elusive function naming (because we like math, right ?) with assembling of a dozen functions to define a new function, you definitely have a readability problem.

Re:The Four Flaws of Haskell by tome on Monday August 15, 2016 @03:13AM (#12289128)
I'm not sure whether I would say I "can just fine" but I would certainly say I don't want to have to!
Re:The Four Flaws of Haskell by thesz on Monday August 15, 2016 @07:16AM (#12289669)
The less decisions you make through you programming day, the more you achieve and the less stressful the job is.

Naming variables is a decision (I am looking at you, function arguments in most mainstream languages). Naming variables once and for all is a big and heavy decision (and now it is time for class members to be looked at).

For one operator in Haskell I often have to invent names for three-to-five variables in C#.

Re:The Four Flaws of Haskell by tikhonj on Monday August 15, 2016 @04:12PM (#12293046)
That's a great way of putting it.

Sure, sometimes an intermediate name helps—that's when I reach for `where` or `let`. But much of the time the extra name would just be extra noise that obscures what the code is doing and makes it harder to read at a glance.

Re:The Four Flaws of Haskell by hyperpape on Monday August 15, 2016 @09:59AM (#12290455)
I suspect that there's a grab bag of things that happen in those one liners, and whether they are a good idea or not depends on the details. For instance, <$> seems pretty helpful, but I shudder when I see flip. I'd go out on a limb and speculate that even for experienced readers, flip is going to be a bit difficult to parse. But I'll have to come back to that when I have more experience.