Live data from Hacker News

Fighting spam with Haskell at Meta (2015)

engineering.fb.com

41–50 of 85 posts

Re: Fighting spam with Haskell at Meta (2015)

#41
I recall hearing about this a while back, and how the team at Meta had implemented hotswapping to deploy new rules, without redeploying the entire executable, even though the rules were expressed in a Haskell DSL.

Unfortunately, I have never seen hotswapping of Haskell code anywhere else. All I can find is this library [0] by Simon Marlow.

Together with Cloud Haskell [1], hotwapping would allow to create pretty flexible distributed systems à la Erlang/OTP.

[0]: https://hackage.haskell.org/package/ghc-hotswap

[1]: https://github.com/haskell-distributed/distributed-process

Re: Fighting spam with Haskell at Meta (2015)

#42

I recall hearing about this a while back, and how the team at Meta had implemented hotswapping to deploy new rules, without redeploying the entire executable, even though the rules were expressed in a Haskell DSL. Unfortunately, I have never seen hotswapping of Haskell code anywhere else. All I can find is this library [0] by Simon Marlow. Together with Cloud Haskell [1], hotwapping would allow to create pretty flexi…

It's worth noting that Simon Marlow is at Meta, and indeed is also the author of the present article.

Re: Fighting spam with Haskell at Meta (2015)

#43
post #27

I worked on this project for a week during the FB team matching process. I had previous Haskell experience, but what struck me was how irrelevant that was. To their immense credit, they had managed to use Haskell to write an entirely entreprise focused, "boring" business rule backend serving millions of QPS, and people who were not Haskell fans could easily use its sensible DSL to accomplish their goals. Way too many…

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 more normal people not into this as a hobby.

Here is how to read a text file in Haskell (I assume a standard way):

https://stackoverflow.com/questions/7867723/haskell-file-rea...

From a Python tutorial:

https://www.pythontutorial.net/python-basics/python-read-tex...

I could be biased, but it certainly seems like Python has a lot less conceptual hurdles here. You basically specify a filepath and then for loop through each line and print. The Haskell solution requires more steps and theory.

I know Haskell is a very awesome and cool language and super powerful for all kinds of uses that Python may be inferior at (example compilers). You'll get no argument there. I'm just pointing out that I think wide adoption may be difficult. I drank the koolaid and read dozens of blog posts and a couple of Haskell books and really wanted to make it work. I'm an engineer and like math and puzzles and learning new programming languages...and yet I couldn't make it that far (without sinking a whole lot more time into it than I had) and ultimately gave up.

Re: Fighting spam with Haskell at Meta (2015)

#45
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…

> 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.

Re: Fighting spam with Haskell at Meta (2015)

#46
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…

The Haskell version parses the contents of the file. One answer also explains how to lazily read the file to process it as it's read, using the ByteString package. I think part of the overhead here is due to this lazy processing, plus the fact that there are basically 3 String in Haskell: String, ByteString and Text.

The python version simply loads the whole file into memory. The equivalent Haskell would be to call Data.Text.IO.readFile. What would the python version of the lazy parsing / processing of a file look like ?

Re: Fighting spam with Haskell at Meta (2015)

#47
post #46

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 version parses the contents of the file. One answer also explains how to lazily read the file to process it as it's read, using the ByteString package. I think part of the overhead here is due to this lazy processing, plus the fact that there are basically 3 String in Haskell: String, ByteString and Text. The python version simply loads the whole file into memory. The equivalent Haskell would be to call D…

There were several Python versions shown at the link and the latter one that I was referring to does not read it all into memory. It loops through each line in only three lines of code, not like 1/4 of a page.

I tried just pasting the code into the window, but never learned how to format HN on mobile. Sorry for the confusion. After the colon there are indents, so 3 separate lines.

with open('testfile.txt') as f: for line in f: print(line.strip())

Re: Fighting spam with Haskell at Meta (2015)

#48
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'd say a lot more is going on there conceptually than the Python code. Imagine through the eyes of a beginner. You have some main do thing, then you appear to read it all into memory and assign a variable, then you do a bunch of composition to words and readInt and map it to print?

With the python version, you see the file handle as a variable and then for loop on that iterable and you can print each line or parse it however you want. Even when I was learning to program and had no clue what an iterable object was, there seemed to be an obvious three line idiom for processing text files that was easy to use.

Re: Fighting spam with Haskell at Meta (2015)

#49
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.

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.

Re: Fighting spam with Haskell at Meta (2015)

#50
post #46

Earlier quoted context omitted.

The Haskell version parses the contents of the file. One answer also explains how to lazily read the file to process it as it's read, using the ByteString package. I think part of the overhead here is due to this lazy processing, plus the fact that there are basically 3 String in Haskell: String, ByteString and Text. The python version simply loads the whole file into memory. The equivalent Haskell would be to call D…

There were several Python versions shown at the link and the latter one that I was referring to does not read it all into memory. It loops through each line in only three lines of code, not like 1/4 of a page. I tried just pasting the code into the window, but never learned how to format HN on mobile. Sorry for the confusion. After the colon there are indents, so 3 separate lines. with open('testfile.txt') as f: for…

I think Haskell seems harder because it's built on another set of abstractions (laziness, typeclasses) where Python abstractions (iterators in this case, plus the with statement for resource acquisition/cleanup) are more common, but I could be wrong (I've been working with Scala for close to a decade now so functional style looks more familiar that imperative now.)

(I also always forget how to format comments, the ref is here: https://news.ycombinator.com/formatdoc )

Post reply on HN