Live data from Hacker News

Fighting spam with Haskell at Meta (2015)

engineering.fb.com

51–60 of 85 posts

Re: Fighting spam with Haskell at Meta (2015)

#51
post #27

Earlier quoted context omitted.

Haskell could be a great practical language if some constraints were introduced, e.g. limiting the language extensions used. https://www.simplehaskell.org attempted to do this and, currently, https://neohaskell.org is going in the same direction. After all, Haskell '98 is not that hard. Personally, I think Haskell, or something like Haskell, is going to be reasonably popular in the near future. Functional programming…

I'm not fully convinced. FP is such a different paradigm than the leading imperative/OO design that most are comfortable with. Other languages that are too different like lisp, forth, Apl, Haskell, and Prolog are just too different for the average person IMO. I've given Haskell/OCaml/F# a go a few times and enjoy learning new paradigms and it certainly didn't click for me. I have a feeling it'll be even harder with m…

It's not really that Haskell is "powerful", but the type system will catch a lot of errors for you and make refactoring much easier.

Also, I wouldn't recommend starting FP with Haskell. It's hard, mostly because of the monads (and laziness can make things more confusing too). Also the syntax which is confusing because indentation is meaningful in some places, but not others.

On the other hand, a language like Scheme is really super easy. Even OCaml is super simple if you stick to the classic ML subset of the language which can take you a very long way. These languages have been using to teach programming to complete beginners. Seriously, OCaml is arguably simpler than Python, and without doubt order of magnitude simpler than C++.

If you're familiar with things like lambda, closures and functions like map or filter in Python, you already know most of what you need to write OCaml code.

Re: Fighting spam with Haskell at Meta (2015)

#52
post #45

Earlier quoted context omitted.

I'm not fully convinced. FP is such a different paradigm than the leading imperative/OO design that most are comfortable with. Other languages that are too different like lisp, forth, Apl, Haskell, and Prolog are just too different for the average person IMO. I've given Haskell/OCaml/F# a go a few times and enjoy learning new paradigms and it certainly didn't click for me. I have a feeling it'll be even harder with m…

> The Haskell solution requires more steps and theory. Really? The suggested Haskell solution is main = do contents which is no more complex than the Python code. The entire file contents is read as a String into content. words breaks it into a list of words, and readInt parses each word into an Int. Finally the list of ints is printed.

I think the issue that many people have with Haskell is the order of expression evaluation is not structured left-to-right and top-to-bottom. At least it's what makes it difficult to read Haskell for me. Compare it with F# (and OCaml family in general):

    open System.IO

    (File.ReadAllText "text.txt").Split()
    |> Seq.map int
    |> Seq.iter (printfn "%d")
It doesn't really matter on simple expressions but as you keep chaining the operations the reverse order gets more difficult to follow.

Re: Fighting spam with Haskell at Meta (2015)

#53
post #26
post #16

Earlier quoted context omitted.

"If this article was about "fighting spam with C++ at Meta" That would not be news, Haskell is famous for being an academic language without many real world applications. C++ is famous for being practical.

I do think it's interesting how I've been hearing about how much people love Haskell and how elegant it is since middle school. Now I'm 10 years out of university and it's still notable when something is actually written in Haskell. That's got to tell you something about the language, the tooling, the docs, the community, or maybe some combination of those things.

Probably a combination of those things but also about the staying power or perception and stereotype from the broader programming community. (I’m not saying that Haskell is super pragmatic and industry-ready, only that the perception of it often lags behind its real usefulness — admittedly in part because other languages work well enough so why bother to engage with one that requires thinking differently?)

Re: Fighting spam with Haskell at Meta (2015)

#54
post #27

Earlier quoted context omitted.

Haskell could be a great practical language if some constraints were introduced, e.g. limiting the language extensions used. https://www.simplehaskell.org attempted to do this and, currently, https://neohaskell.org is going in the same direction. After all, Haskell '98 is not that hard. Personally, I think Haskell, or something like Haskell, is going to be reasonably popular in the near future. Functional programming…

I'm not fully convinced. FP is such a different paradigm than the leading imperative/OO design that most are comfortable with. Other languages that are too different like lisp, forth, Apl, Haskell, and Prolog are just too different for the average person IMO. I've given Haskell/OCaml/F# a go a few times and enjoy learning new paradigms and it certainly didn't click for me. I have a feeling it'll be even harder with m…

> FP is such a different paradigm than the leading imperative/OO design that most are comfortable with.

I don't think most of FP is at all hard for most programmers to understand. Hell I interviewed plenty of Javascript devs that couldn't solve a simple fizzbuzz level question because they didn't know how to do for loops - they only knew how to use `.forEach()`!

The hard bits in Haskell are:

1. Purity. I get it, but it definitely makes things harder.

2. Weird syntax: pervasive currying / single argument functions / lack of grouping syntax / waaaay too many operators, etc. E.g. from your link:

        let singlewords = words contents
            list = f singlewords
This is just a collection of words. No clue of what is a function call, what is a variable name, etc. Allow me to recreate the experience of reading Haskell, if you think the above is reasonable:

    file read lines put
    lines iter while cbr empty
    for do  x IO::print
3. General unfriendliness to people who aren't hardcore Haskellers. E.g. suppose I want to match a regex. In Go, Python, Rust, Javascript, etc. there's one obvious way to do it. Haskell? How about you pick between 8 alternatives... https://wiki.haskell.org/index.php?title=Regular_expressions

There are other flaws, like global type inference & lazy IO, but I think those are the main ones.

Re: Fighting spam with Haskell at Meta (2015)

#55
post #9

Earlier quoted context omitted.

You aren't hiring good programmers if they are intimidated by syntax.

I've encountered many otherwise solid engineers who are intimidated and/or put off by Nix (the language).

I count myself among them. And I wouldn't say I am "otherwise solid". I am solid. Nix is just a weird custom footgun-laden language in a place where I don't want to have to learn a weird custom footgun-laden language. It has other serious issues too, like the fact that it is declarative makes discoverability extreeemely difficult. What does setting `foo: true` do? You can't go-to-definition on it. You can only hope it is well documented (it isn't) or try to find the place that reads that key ... somewhere... in all of Nix... Good luck.

Hell even if it were a perfectly designed language (it isn't) I still would be put off by it because I don't really want to be a professional full-time packaging engineer.

I think Bazel got a lot right by using a subset of Python. Basically nothing to learn language-wise.

Re: Fighting spam with Haskell at Meta (2015)

#56
post #44

I’m very sad that this service is basically on life support and got moved into PHP with everything else.

Haha I was checking the comments precisely to see if this was the case. This happens nearly everywhere a language that isn't Java, Python, Ruby, Go, PHP, or JavaScript is used. IMO it has more to do with tech labor arbitrage[1] than anything technical. Even if a system is punching above its weight, over time, the Weird Language Choice spooks people enough that they get the rewrite bug.

Bleacher Report is a funny example: it used to be a darling example of Elixir, where a migration from Ruby -> Elixir claimed a move from "150 Ruby servers to 5 (probably overprovisioned) Elixir servers."[2] But then management and politics got scared, moved it all to more conventional tech, and the whole system suffered (see this legendary post[3]).

Fred Hebert describes a similar thing happening with a migration from Erlang deployments to Go/Docker/immutable, where you lose some pretty valuable capabilities by migrating to more conventional tech.[4]

I don't see this changing anytime soon -- we came of age when it was viable to attract investment with the promise of tech innovation. These days, those are liabilities because managers misunderstood the "Use Boring Technology" post the way consultants bartardized "Agile" (taking decent advice and misunderstanding it into something wholly different and horrifying). The result is you've got companies with customers in the 1000s using k8s, calling it "simple" and "Boring," whereas that same company would be called amateur if they did things like stateful deploys on-prem.[5]

At least we'll always have WhatsApp.

[1]: https://www.baldurbjarnason.com/2024/react-electron-llms-lab... [2]: https://web.archive.org/web/20170204160005/http://www.techwo... [3]: https://www.reddit.com/r/erlang/comments/18f3kl3/comment/kct... [4]: https://ferd.ca/a-pipeline-made-of-airbags.html [5]: https://morepablo.com/2023/05/where-have-all-the-hackers-gon...

Re: Fighting spam with Haskell at Meta (2015)

#57
post #45

Earlier quoted context omitted.

> The Haskell solution requires more steps and theory. Really? The suggested Haskell solution is main = do contents which is no more complex than the Python code. The entire file contents is read as a String into content. words breaks it into a list of words, and readInt parses each word into an Int. Finally the list of ints is printed.

yes, it looks all good, until you want to change it. For instance, to make the file name a CLI parameter, you need to understand things like type classes, specifically Monad, Functor and Applicative. You may need a long time to be at ease with these things and a superficial understanding will not take you very far. In Python, it'll take you a few minutes to do the same thing.

What do you mean by "long time"? Why wouldn't it apply just the same to some Python file that defines a Maybe with a bit of unwrap and bind and orElse or whatever?

Instead of things going boom and spewing a stack sometimes they just go Nothing instead, you don't need much more understanding than that. There is a lot of syntax in Haskell that is somewhat hard to understand at first but you don't actually need it to write stuff yourself.

This idea that you need to talk a particular way and be able to teach CS theory at uni and whatnot to build stuff in Haskell is probably not very healthy.

Re: Fighting spam with Haskell at Meta (2015)

#58
post #56
post #44

I’m very sad that this service is basically on life support and got moved into PHP with everything else.

Haha I was checking the comments precisely to see if this was the case. This happens nearly everywhere a language that isn't Java, Python, Ruby, Go, PHP, or JavaScript is used. IMO it has more to do with tech labor arbitrage[1] than anything technical. Even if a system is punching above its weight, over time, the Weird Language Choice spooks people enough that they get the rewrite bug. Bleacher Report is a funny exam…

Love your take on it. From a fellow prog languages enthusiast that matured, I can safely say that you are right.

I've coded in so many languages in my life, but the job market pull from Ruby always drags me back, with time, I began to really love and appreciate what Ruby is.

I still find Ruby a bit niche than other mainstream languages like Java and Python, I bet that if I had >5 years of Java, the Java market pull would be higher than Ruby and I'd be doing Java.

Re: Fighting spam with Haskell at Meta (2015)

#59

Earlier quoted context omitted.

I'm not fully convinced. FP is such a different paradigm than the leading imperative/OO design that most are comfortable with. Other languages that are too different like lisp, forth, Apl, Haskell, and Prolog are just too different for the average person IMO. I've given Haskell/OCaml/F# a go a few times and enjoy learning new paradigms and it certainly didn't click for me. I have a feeling it'll be even harder with m…

> FP is such a different paradigm than the leading imperative/OO design that most are comfortable with. I don't think most of FP is at all hard for most programmers to understand. Hell I interviewed plenty of Javascript devs that couldn't solve a simple fizzbuzz level question because they didn't know how to do for loops - they only knew how to use `.forEach()`! The hard bits in Haskell are: 1. Purity. I get it, but…

From the Haskell snippet, f is just "map read" specialized for lists of Integers, so inlining it would read like this :

  let list = map read (words contents)
The equivalent Python is basically this:

  list = [int(word) for word in contents.split()]
I'm just writing this for the benefit of others here.

Re: Fighting spam with Haskell at Meta (2015)

#60
post #57

Earlier quoted context omitted.

yes, it looks all good, until you want to change it. For instance, to make the file name a CLI parameter, you need to understand things like type classes, specifically Monad, Functor and Applicative. You may need a long time to be at ease with these things and a superficial understanding will not take you very far. In Python, it'll take you a few minutes to do the same thing.

What do you mean by "long time"? Why wouldn't it apply just the same to some Python file that defines a Maybe with a bit of unwrap and bind and orElse or whatever? Instead of things going boom and spewing a stack sometimes they just go Nothing instead, you don't need much more understanding than that. There is a lot of syntax in Haskell that is somewhat hard to understand at first but you don't actually need it to wr…

Long time, I mean possibly several weeks of full-time studying for an intermediate Python or C++ programmer.

I'm not saying you need any CS theory to write Haskell or that it's super hard. But I think the learning curve is pretty steep, and it's hard to write code without a good understanding of the concepts. Just tweaking until it type checks isn't going to cut it.

Consider this code. Generated from ChatGPT. This is supposed to be a simple command line option parsing. I don't think it's obvious what all the operators mean.

Sure, you can try to reuse this, and extend it. But I think sooner than later you'll be stuck with some undecipherable error messages and you'll have to sit down and understand what it all means.

  data Options = Options
    { optVerbose :: Bool
    , optInput   :: String
    } deriving Show

  optionsParser :: Parser Options
  optionsParser = Options
     switch
        ( long "verbose"
        short 'v'
        help "Enable verbose mode" )
     strOption
        ( long "input"
        short 'i'
        metavar "FILENAME"
        help "Input file name" )
Post reply on HN