←back to thread

306 points jameshh | 3 comments | | HN request time: 0s | source
Show context
behnamoh ◴[] No.44409423[source]
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/

replies(4): >>44410370 #>>44410421 #>>44410532 #>>44411932 #
tikhonj ◴[] No.44410532[source]
At 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.

replies(4): >>44410542 #>>44410908 #>>44412356 #>>44413399 #
dmead ◴[] No.44410542[source]
Combinator 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.

replies(4): >>44410690 #>>44410730 #>>44411031 #>>44411206 #
librasteve ◴[] No.44410730[source]
err, no

the perl6 guys ended up inventing the new perl (now renamed raku)

https://rakujourney.wordpress.com/2024/10/12/raku-burritos/

the first perl6 parser (pugs) was written in Haskell btw

replies(1): >>44418269 #
dmead ◴[] No.44418269{3}[source]
I'm aware. I was using the world pejoratively. Combinator style degrades into line noise.
replies(1): >>44420920 #
1. librasteve ◴[] No.44420920{4}[source]
no doubt its fashionable to think "perl == line noise == bad"

however, there are certain sub languages (slangs) where the use of punctuation chars as operators is very helpful, of course regex is the most compelling where the code is parsing one char at a time

  my regex url {
    ^                                # Start of line
    [<http> s? '://']                # Match http or https
    ['www.' ]?                       # Optional www.
    [<[\w\-]>+ '.' ]+                # One or more domain segments
    <[a..z]> ** 2..6                 # TLD, 2 to 6 lowercase letters
    [ '/' <[\w\-./?%&=]>* ]?         # Optional path/query
    $                                # End of line
  }
imo raku has improved the situation a lot by introducing "regex 2.0" with deep support for unicode and with built in grammars that can work smoothly with regex
replies(1): >>44426795 #
2. dmead ◴[] No.44426795[source]
Ahh not sure I agree. The reputation for being unreadable is pretty well deserved. It didn't happen for no reason.
replies(1): >>44427177 #
3. librasteve ◴[] No.44427177[source]
ok - I agree that there was a culture of golfing and obscurity in some sections of the perl coder base

it was inevitable that a simpler language - Python - would take the big slice of scripters who wanted something easier to learn and to read

I'm sad that perl no longer has a credible niche for script level coders who want to learn a more powerful and more expressive language than Python ...