6 ms·
Haskell has an interesting syntax: it is intuitive after someone explains it to me, but not intuitive much before the explanation. I don't think it's because I
by behnamoh 1y ago
Haskell has an interesting syntax: it is intuitive after someone explains it to me, but not intuitive much before the explanation.
I don't think it's because I'm used to Algol-based languages (C, Python, etc.). Every Haskell code I've seen is plagued with a plethora of operators which aim to make the code concise but it's not obvious what they do just by looking at them: https://academy.fpblock.com/haskell/tutorial/operators/ https://academy.fpblock.com/haskell/tutorial/operators/
- theLiminator 1y ago> it is intuitive after someone explains it to me, but not intuitive much before the explanation Isn't that pretty close to what something being intuitive means? Ie. something being intuitive means that it's easily understood or learned without requiring prior knowledge or instruction.
- gylterud 1y agoWith Haskell code it is often so that the code which actually does something is expressed in terms of combinators. These combinators are often very general, so one must do a bit of mental work to understand what they do in this particular context. Once you understand what the combinators do in a particular context the code often reads very easily, and what it does is very intuitive and natural. Best example I can think of is applicative parsers, where there are scattered <*> and <$> operators around, but if you just ignore them the parser just looks like a very intuitive description of what the expressions you want to parse look like.
- the_af 1y agoMost of the operators in that link are bog standard, and among the least interesting things to say about Haskell. If I didn't know programming and picked at random some Java program, I wouldn't understand much either. If I didn't take a single math course and I tried to read a math formula, I wouldn't understand the operators or anything either. The standard should be: how much can you understand once you learn the basics and do a couple of tutorials?
- tikhonj 1y agoAt some point, I did a rough count, and the number of operators you encounter in "normal" Haskell code—avoiding lens or domain-specific libraries—was pretty close to the number of operators you'd encounter in, say, JavaScript. This was a while ago and I don't want to redo the exercise now, but, even if we're being generous to JavaScript, practical Haskell needs on the order of 2x as many operators as practical JavaScript, not 10x. Haskell has some up-front incidental complexity, but it's a difference of degree not kind from popular starting languages. It's easy to underestimate how much you had to learn about Algol-style languages that you've just internalized so well that you don't even realize. I've taught some complete programming beginners (high or middle schoolers) Java and Python and, especially one-on-one, I've seen how they get confused by things I did not even remember required explanation! For example, in Python, people put : in the wrong place and don't understand how = works. "Basic" syntax like : and = are far more complex than we realize, we've just learned the basics so well that it's second nature. It's similar to how native English speakers don't even realize we have rules for adjective order ("big red ball" vs "red big ball"), while language learners run into it like a brick wall.
- dmead 1y agoCombinator style, while good and well designed and all they only ended up inventing the next perl. #haskell on freenode in the 2000s was a really fun place. I could not for the life of me convince anyone else to use the language.
- eru 1y agoCombinators (in the Haskell sense) have nothing to do with whether you write your functions with letters or with comic book swearing.
- librasteve 1y agoerr, no the perl6 guys ended up inventing the new perl (now renamed raku) https://rakujourney.wordpress.com/2024/10/12/raku-burritos/ https://rakujourney.wordpress.com/2024/10/12/raku-burritos/ the first perl6 parser (pugs) was written in Haskell btw
- mejutoco 1y agoI think Larry Wall mentioned something like this regarding perl. Things can only be intuitive after learning them. I do not think it is syntax you are complaining about either. Some constructs in Haskell reference a certain model (monads, lenses) and no syntax is going to infuse any reader with that knowledge if they do not possess it already.