3 ms·
Actually basic Haskell syntax is very simple, it's lot closer to basic math symbol and equation. What make it hard to understand is the use of abstractions like
by ardfard 6y ago
Actually basic Haskell syntax is very simple, it's lot closer to basic math symbol and equation. What make it hard to understand is the use of abstractions like Monad, Transformers etc, and people use it a lot in Haskell. It's very hard in fact to make a useful Haskell program without a Monad. That said, I don't think another mainstream languages that use advanced abstraction like Haskell is gonna be easier to read either. Try to imagine a Java program that trying to use higher-kinded abstraction, I bet it won't be pretty and easy to teach. I have experience trying to explain about Monad in Ruby to a coworker and it's really hard.
- yencabulator 6y agoMonads, Transformers etc can make Haskell code hard to follow. But the culture of overusing unpronounceable/unmemorable operators is what makes Haskell really hard to read. >@> <$> <*> <|> <=< <+> <$> --> <&&> <||> ||| .|. None of the above are made up, all are from real code.
- whateveracct 6y agoOf code is using <$>, <*>, And <|>, it's probably easier to read & understand at a glance than the the best, most read-optimized Go equivalent. If you know what those symbols mean (aka the interfaces they belong to.) If you don't have that knowledge and are instead complaining about the fact that they have symbols period, I suggest you quit spouting answers when you should be asking questions.
- Macha 6y agoWhy is <$> for example easier to read, type, understand, Google, or any dimension really over "fmap"?
- whateveracct 6y agoApplicative style for one data Person = Person { age :: Int , name :: Text , height :: Int } Person <$> parseAge <*> parseName <*> parseHeight Applicative style is one of the easiest constructs to read relative to the power of what it typically does. Most other times when you use <$>, you're using it instead of something like this: fmap f $ x y z Which is simplified by f <$> x y z Google is a non-issue. Hoogle exists and works great (and can even index all symbols importable by your project)
- siraben 6y agoSome of these are explanable from mathematical conventions. In abstract algebra it's common to surround an operator in a circle to denote a "generic" or "lifted" operator. So <$> denotes a "lifted application", i.e. ($) :: (a → b) → a → b (<$>) :: Functor f => (a → b) → f a → f b
- jandrese 6y agoIt's easy, it's just like higher order forms of math! Mathematic notation is horrible. We have to teach kids the forms for _years_ and most are still shaky at it once they're adults. You have to memorize everything because the syntax is basically shorthand, nothing is self explanatory. Then we wonder why kids struggle with math. If a programmer decided to replace his function names with single characters from a different language he would be dope slapped by his colleges. If he always used single character variable names he would be kicked out.
- throwaway894345 6y agoI have exactly this frustration with math. The notation was confusing at nearly every level of my education perhaps starting with operator precedence in arithmetic and escalating exponentially in college with more advanced forms of math. I remember nearly flunking calculus (saved by a merciful curve) with no concrete understanding, only to find in my later engineering curves that calculus was downright easy and intuitive to me, but the notation (and perhaps the pedagogy) were inhibiting. To this day, when I'm reading computer science papers, I have to look really hard to make sense of the math gibbrish and get at the actual meaning, and often when I do I realize that it would have been much clearer in a few lines of JavaScript or Python or Go or Rust or just about anything else. Well, perhaps anything except Haskell, OCaml, and similar. Even after learning the syntax, I still haven't internalized it as effortlessly as I did with other languages. Note that lisp is not very algol-like and I have a much easier time parsing it than I do Haskell despite relatively equal familiarity. I think Haskell has given us a lot of great ideas, and thankfully they've filtered down from the Ivory Tower of academic languages into pragmatic mainstream languages, such as Rust.