Live data from Hacker News

Why isn't Haskell popular in industry?

palgorithm.co.uk

71–80 of 145 posts

Re: Why isn't Haskell popular in industry?

#71

Not to answer the question, but I can provide some reasons why I am not going to learn Haskell. I must say up front that I know next to nothing about the language, and my reason my sound very irrational, superficial and plain silly, however: it just looks ugly. That's it. I cannot imagine myself sitting all day and staring (or writing) something that looks like explosion on a regexp factory with ruins of Perl fallen…

Really? How beautiful it is is exactly what keeps drawing me to Haskell even though I have more invested in the dynamic language camp. >max = head . sort Due to the laziness, the above will find the max entry in O(n) time, just like your hand written loop would. How can you not find that beautiful? Now I do agree that they often seem to use too many symbols that look like other symbols but the few times I've investig…

I love haskell and understand your point. Laziness is beautiful and allows to express things in a simple way and also improve the reusability of the code etc.

However I think that you didn't pick the best example.

I tried out:

>head $ sort [1 .. 10000000]

6 secs, using ~2g of heap! (actually is should be a reverse sort)

and the "hand coded loop":

>let mx (x:xs) m = if x > m then mx xs x else mx xs m; mx [] m = m >mx [1 .. 10000000] 0

3 secs, heap usage stays negligible low and constant.

Something is clearly not behaving as you depicted.

(of course my 'loop' code is not the exact equivalent of the last.sort composition, since it requires a 'minimum' parameter to be passed in advance, which not all types have. On the other hand it works also for the empty list)

I also have the feeling that, unless special compiler optimization (a very 'specific' one, I fear), the simple application of the 'head' function to a sorted list would stop when the first result element is produced, which is not after O(n). Granted, you don't have to wait for a full sort, since the sorting algorithm could guarantee that the rest of the list contain 'lesser/bigger' elements only and thus stop. But keeping track of all this should be space consuming, in respect to a simple linear scan.

Anyway the space problem of the "lazy" solution is a bigger issue than the number of comparisons.

I'm not a haskell master, but if I got it right, one of the mayor problems of lazy programming is that in some situations it can degenerate to a huge amounts of "unevaluated thunks", which are frozen computations yet to be performed, but which require some state to be held in memory (like function arguments, I guess).

(http://www.haskell.org/haskellwiki/Thunk)

or in this case, the space usage is caused simply because the list has to be materialized in memory instead of be simply traversed and generated on the fly. (but 2g seems slightly too much).

Anyway, the point here is that the two methods are not equivalent.

I think that understanding the impact of laziness on space is an issue that certainly increases the learning curve, as it requires time to master this and other optimization techniques if you want to get predictable performances from haskell.

(BTW, I actually use haskell for work, perhaps in a slightly conterintuitive way. I use haskell for quick prototyping ideas and solutions. Sometimes I get inspired by the solution I end up with haskell and translate it in clojure or java (work requirement), or at other times I have to rewrite it completely, but the possibility to quickly prototype in haskell really helps me a lot. I would love a stable ghc JVM backend.... it would change my life)

Re: Why isn't Haskell popular in industry?

#72
Well I've read comments so far and I did not see anyone mentioning this.

I program both on desktop and on web.

On desktop I program C# which is mediocre and recently I have started using C++ with Qt. Qt has huge advantages over C# (QtCreator is IDE that is going to be better in time than Visual Studio, currently it lacks few features, but still I find it usable). On both languages I have my set of libraries which you can't find everywhere else and make my life easier.

On web I use php and sometimes I use Rails. Each has advantages, I use php cause I've used it since php3 so a lot of historical baggage. On each I have my set of code and libraries I use the most.

So lately there's a whole new languages and frameworks coming out. Why should I spend my time porting my libraries to Haskell? Do I get significant advantage coding in it? No, because I use mostly my own libraries.

Re: Why isn't Haskell popular in industry?

#73
post #57

Earlier quoted context omitted.

Perhaps the reason that Haskellers don't describe monads as "just sections of the program that are imperative" is because that statement is _not_ true. A monad is a very nice container abstraction - period. The IO part of Haskell just happens to leverage monads. One of the benefits of which is an explicit marking of impure methods in the type signature, but there are others. Monads are used in plenty of purely functi…

Can you give an example of where monads are not used to interact with stateful things? That would be helpful to me.

The Maybe and List monads have nothing to do with state, and are very common in programs.

Let's use the List monad to determine someone's roommates.

    > import Control.Applicative
    > import Data.List
First, the data:

    > type Person = String
    > type Address = String

    > addresses :: [(Person, Address)]
    > addresses = [("jrockway", "123 Fake St."), ("jrockway's cat", "123 Fake St.")]

    > people :: [(Address, Person)]
    > people = uncurry (flip (,))  addresses
And some helper functions around this data, a function to return all addresses for a person, and a function to return all people that live at a certain address:

    > assocFilter :: Eq a => a -> [(a,b)] -> [b]
    > assocFilter p xs = snd  filter ((==p) . fst) xs

    > addressesForPerson person = assocFilter person addresses
    > peopleAtAddress address = assocFilter address people
To find a person's roommate, we have to chain two computations. First, we have to find zero or more places where a person lives. Then we need to find who else lives at each of those addresses. With the List monad, this is not much code!

    > roommatesFor :: Person -> [Person]
    > roommatesFor person = do
    >     address      peopleAtAddress address
The monadic combinator >>= (which is hidden by do) does all the looping for us, so we don't have to explicitly write it out.

BTW, you can just cut-n-paste this into a .lhs file and run it, if you want to try it out.

Re: Why isn't Haskell popular in industry?

#74

Every language has a catalyst that pushes it from obscurity into mainstream use. Whether it be a project (Ruby on Rails), a programmer (Linus Torvalds -> C), a company (Google -> Python), or a library (Boost -> C++), there is always a force behind adoption. Most languages undergo a "fad period", where it's hip and cool to write in it and people just do it because other people do it. Clojure is going through this righ…

Was C really obscure before Linus Torvalds released\popularised linux? I'm fairly young so I have no knowledge of this, but it feels wrong.

edit: just noticed a discussion about this exists already. That'll teach me to read all the comments in future :)

Re: Why isn't Haskell popular in industry?

#75
post #71

Earlier quoted context omitted.

Really? How beautiful it is is exactly what keeps drawing me to Haskell even though I have more invested in the dynamic language camp. >max = head . sort Due to the laziness, the above will find the max entry in O(n) time, just like your hand written loop would. How can you not find that beautiful? Now I do agree that they often seem to use too many symbols that look like other symbols but the few times I've investig…

I love haskell and understand your point. Laziness is beautiful and allows to express things in a simple way and also improve the reusability of the code etc. However I think that you didn't pick the best example. I tried out: >head $ sort [1 .. 10000000] 6 secs, using ~2g of heap! (actually is should be a reverse sort) and the "hand coded loop": >let mx (x:xs) m = if x > m then mx xs x else mx xs m; mx [] m = m >mx…

I found this article referencing the O(n) complexity for the 'head . sort'

http://apfelmus.nfshost.com/articles/quicksearch.html

As far as I can understand from the blog and and the cited mailing lists, it works but it requires a carefully coded sorting method, otherwise O(n log n) as expected.

Re: Why isn't Haskell popular in industry?

#76
post #47

Haskell is not popular because to be popular you must cater to the average Joe. And to cater to average Joe your foremost goal must be not making him uncomfortable about himself. Never forget this. And since most average Joes just work to pay their bills, they don't give a damn about technical superiority, you know.

I'll have to correct you a bit. Judging by the article, Haskell currently isn't usable for work. So why should average Joe choose half-finished product? So why even the brightest hacker choose it when he already has all the tools he need?

Re: Why isn't Haskell popular in industry?

#77
post #70

Earlier quoted context omitted.

I don't know how familiar you are with Haskell... but anyway: Say you're working with the Maybe type, which is often used to represent operations that might fail, such as a map lookup, for example. data Maybe a = Just a | Nothing We're using two functions defined like so (feeling unimaginative at the moment, forgive me): x :: String -> Maybe String y :: String -> Maybe String We want to use them together. Someone who…

I appreciate that. I am actually familiar with Haskell and the Maybe monad. Are there use cases for Maybe where you're not interacting with some sort of IO?

Oh yeah sure all the time, Maybe shows up a lot. It becomes more useful and less of a pain once you realise you can deal with it using monad operators. From the standard library a list operator and a map operator:

  elemIndex :: a -> [a] -> Maybe Int
  lookup :: k -> Map k a -> Maybe a
Say we have a map of lists of string, for some reason. We need to find the index of the element "foobar" in a particular key, so you could write:

  lookup key map >>= elemIndex "foobar"
(a simple example for the sake of brevity)

Not very impressive, but monads aren't anything groundbreaking after all, they're just utilities that make our lives easier. There are more complicated operations that come in handy later, but they are quite straightforward once you get a grasp of the container metaphor.

Re: Why isn't Haskell popular in industry?

#78
post #61

Earlier quoted context omitted.

Dons, I know you are devoted to Haskell and will not take any criticism of it lightly. But I am not your enemy. I am willing to praise it myself when it is more suitable. Not when you try to spin it. You and your supporters succeeded in bombarding every article that even mentions Haskell the wrong way with snide comments, and probably won over a few hobbyists. At the end of the day though, the managers making the dec…

The only thing I ever saw Don Stewart "bombing" were factual evidence. And what he destroys by truth should be annihilated anyway (P. C. Hodgell). "Don Stewart said so, it must be true" actually isn't such a bad heuristic (as far as Haskell is concerned). From what I've seen, Don is quite cautious.

The only thing I ever saw Don Stewart "bombing" were factual evidence.

This is not surprising coming from someone involved with Haskell. Do I really need to point to you the bug ticket that it was only 8 months ago that you could use something other than GMP? http://hackage.haskell.org/trac/ghc/ticket/601

Even with the option to dynamically link, it still doesn't change the fact that it was the __default__. And what a scary default that was. Company lawyers don't like to touch anything related to GPL with a 10-foot pole, for the reason that it is really up to the jury to decide what is a "derivative work" even if you only link dynamically! Maybe if you live in France, or have a 5 person company, this is an acceptable state.

Anyway I am done, you and Dons win, are you happy? I simply have no ulterior motive or incentive to defend my findings against organized groups who have their livelihoods and PhDs based on Haskell.

Re: Why isn't Haskell popular in industry?

#79
post #53

Earlier quoted context omitted.

You mean max = last . sort ?

No, using head is what causes the result to be O(n) even though sorting should be more complex. By only using the first entry, only the first entry will actually be found by the sort. I assume you're pointing out that I have my sort backwards but I was being intentionally as ambiguous with this part because it's not relevant to the point I was making.

I understand that lazyness could make it only sort as much as needed to get the first element in the sorted list.

Yes, it's triggers my Rainman instincts to point out that 1. It should be max = last . sort 2. Or min = head . sort 3. You are making assumptions on the sorting algorithm to make it possible to short-cut the evaluation.

K-MART! K-MART! :)

Edit: How nice of you to downvote...

Re: Why isn't Haskell popular in industry?

#80
post #65

Earlier quoted context omitted.

Why is Haskell not a good fit for glue? That's what I use it for, and it works great -- my programs are short, efficient, and easy to write and test. My first Haskell project for work was initially a C++ project, but it was too hard to use C++ as a glue language, so I switched to Haskell. I would have used Perl, but Haskell works better on Windows and has an easier-to-use FFI. I actually ended up spending more time t…

After having written that, I realized it was more nuanced than that. Haskell's good for parsers, for example. I am actually working on one for a proprietary logfile format right now (it will "convert" said logfiles into SQLite .dbs). But if you have preexisting libraries for system A in Java and system B is CORBA then you would be mad to put Haskell in the middle, the impedance mismatch is too great.

This is a software-engineering-in-general problem, though, not a Haskell problem. If you have a bunch of components that can only communicate in a very specific way, then all the components have to communicate in that very specific way. This limits flexibility and "working with the system" becomes the main engineering problem. I think this is why most software dev teams explode to needing 10 teams of managers to manage a million developers -- because so many "irreversible" decisions were made that the application becomes workarounds on top of workarounds. Haskell is not going to magically eliminate bad planning and the fear of refactoring. And similarly, it's not going to make it easy to keep adding shit on top of the shit pile, like Scala or Clojure would. (Not to dis on Scala or Clojure specifically. I've actually never seen anyone do this; they just add more Java 1.4.2 on top of their existing Java 1.4.2-only mess. It would be me that added the Scala or Clojure :)

I actually have a problem like this right now; I'm starting re-development on an application whose components talk via CORBA over an ultra-expensive and ultra-overengineered proprietary message bus. My plan is to write a bridge between the proprietary message bus and JSON-RPC (or something like that) in Scala, and make the rewritten components only talk JSON-RPC. Then, when everything is rewritten, there is no more super-expensive-message-bus requirements, and we shut it off. Now we have the ability to write components in any language.

(Also, the reason this doesn't count as adding shit on top of shit is because eventually the ugly bridge will go away. That only exists to make the rewrite into a refactor. You have to have a scaffolding, or all the shit will collapse on top of you and make a big mess. :)

Now I know the reply is going to be, "well, not everyone can just replace their proprietary crap with something simpler and more generic", but again, that's not a Haskell problem.

Post reply on HN