Hello Haskell, Goodbye Lisp (2009)
newartisans.com
newartisans.com
> Can you give an example of something you can
> implement with a Lisp macro, but you can't
> implement with Haskell?
Much of that discussion is worth reading. The other submissions don't have much discussion.[0] https://news.ycombinator.com/item?id=516208
With Clojure, If you understand the JVM type system and performance, you can also write high performance DSLs using Clojure macros. https://github.com/clojure/core.logic allegedly is a project along these lines, but I haven't looked too much into it. It heavily uses Clojure protocols (which map to Java interfaces) for performance. I had been working on a code generator for Clearley, which sits neglected on my hard drive, but is able to perform just a little slower than unoptimized hand-written parsers. Since in Clojure compile/runtime separation is optional and off by default, you can use Clojure to generate Clojure code, making life a lot easier.
Lisps generally run in an image, meaning you have full access to he full state of the program including the compiler/macro expander/etc, which you can run at runtime.
So what about a program that reads a protocol off the wire, expands/compiles it to x86_64 assembly, and communicates over the wire with it (all in the same process and without calling any external compiler).
Or maybe a program that collects runtime performance statistics and uses some stochastic method to improve the 'hot' pieces of code.
genFoo :: String -> DecsQ
genFoo name = [d| instance Foo $(return t) where quux = $(return f) |]
where f = VarE . mkName ("quuxify" ++ name)
t = ConT (mkName name)
genFoos :: [String] -> DecsQ
genFoos = foldl' (liftM2 (++)) (return []) . map genFooHe still loves Haskell: http://newartisans.com/category/haskell/
Everything I've observed suggests that Scala has a far greater rate of adoption than Clojure, and Scala's usage is still basically irrelevant compared to that of the major entrenched languages. I'd put the adoption of Haskell closer to that of Scala than I would to Clojure.
Even though these languages have been around for decades, they are just recently being spliced into the mainstream via lambdas, immutability, etc. So I could easily see Haskell make a comeback.
http://www.indeed.com/jobtrends?q=clojure%2C+haskell%2C+scal...
But they both lag Scala.
http://www.indeed.com/jobtrends?q=clojure%2C+haskell%2C+scal...
Maybe on Silicon Valey startups.
In Europe I see a lot of Scala, Haskell, F# taking up in the finance and insurance areas for data modelling.
The boring enterprise is all about Java, C# and VB variants.
I do like Clojure, and it is the most successful Lisp dialect but it is far from thriving.
How do these look in Haskell?
- The syntax is clean and extensible. (Function application is `f(x)` in C, `(f x)` in Lisp, and `f x` in Haskell.)
- The core language is small, with a suprising amount of functionality implemented as library functions. (Not surprising to a Lisp programmer, though.)
- You can define your own infix operators, specify their precedence, and their fixity. (Left, like most mathematical operators, or right, like the exponentiation operator).
- Because of Haskell's lazy evaluation, there is no distinction between special and non-special forms, so you don't need macros to build up syntactic sugar for your DSL. (Special forms, such as the C short-circuiting operators `&&` and `||`, only evaluate as much as is necessary, which is what Haskell does across the board.)
- But if you really want macros or quasi-quotation, they're part of the language. (Macros are named Template Haskell.)
- There is also built-in syntactic sugar which can be re-used for your own instances of common program patterns, such as monadic do-notation, monadic comprehensions, and arrows.
There are many examples of Haskell DSLs online. A particularly amusing one is Lennart Augustsson's embedding of BASIC in Haskell, proving beyond all doubt that Haskell is in fact an imperative language, and all this talk about purity is poppycock. [1] [2]
Haskell is also great for performance. GHC 7.8.2 is now ready to use, with the Mio high-performance multicore IO manager merged in. [3] The composable nature of Haskell also lends itself to surprisingly powerful optimisations. [4]
Now, generating code at runtime and integrating it (interpreted, or even compiled) into the running image is definitely a strength of Lisp, and other under-appreciated artefacts of a future past, such as Smalltalk. I do not know how Haskell fares in this area, but I would like to find out.
[1]: http://augustss.blogspot.co.uk/2009/02/regression-they-say-t...
[2]: http://augustss.blogspot.co.uk/2009/02/more-basic-not-that-a...
[3]: http://haskell.cs.yale.edu/wp-content/uploads/2013/08/hask03...
[4]: http://research.microsoft.com/en-us/um/people/simonpj/papers...
http://chrisdone.com/posts/common-lisp-haskell
But regular, syntax-extending macros aren't possible. E.g. you can't write AIF, there is only quasiquotation. But if you're just worried about DSLs, then that is indeed possible. There's a culture of avoiding template-haskell in favour of using combinators, so you will sometimes have to stomach ugly DSLs with awful operators and silly names. On the other hand lazy functions are like compiler macros, so they compose better than Lisp macros, which generally compose horribly.
As far as parallelism, sure Haskell can give that for free. The cost is you have to be pure about everything, which just seems obnoxious to me...especially when you don't necessarily care about parallelism or performance.
With lisp, I can use macros to make parallelism just as natural as programming regular lisp. Yes, I have to be explicit about when I'm being parallel and when I'm not. But that doesn't seem like such a big deal to me, and sometimes you want explicit control over your threads.
As far as community, I have no doubts the Haskell community is great. But so is the lisp community. There are a lot of bright people who jump at any chance to help out others, and in the past 5 years the CL implementations and community-built libraries have been making leaps and bounds.
This isn't to say Haskell isn't a great choice for many, many applications and requirements. But it's not a replacement for lisp, just as lisp isn't a replacement for Haskell. They are two different beasts that are great at different things.
Haskellers agree, that's why we have Template Haskell. We use it for all sorts of things, like automatically implementing typeclasses (interface'ish) at compile-time.
> parallelism, sure Haskell can give that for free
Not really.
>The cost is you have to be pure about everything
Nonsense.
Boom, mutable variables:
http://bitemyapp.com/posts/2014-03-25-when-nested-io-actions...
>sometimes you want explicit control over your threads.
You can have that in Haskell. You can use green threads or OS threads and optionally pin OS threads to a particular CPU to avoid context-switching.
So you can know what you're talking about next time, my recommended guide for Haskell:
https://gist.github.com/bitemyapp/8739525
The concurrency primitives in Haskell are broad and deep, check this book out: http://chimera.labs.oreilly.com/books/1230000000929
--- an ex-Lisper
I like your guide, but is this really necessary? This isn't the first time you've been aggressively hostile to people expressing a preference for Lisp over Haskell, either.
Also you can't express a preference (up or down) for something you've never used.
I'll elide the snark next time, but I'm not going to stop correcting false statements or sharing learning resources.
> I have no doubts the Haskell community is great.
You're not making a strong case for it, are you? ;-)
Would be nice if the culture could shift a notch or two towards, "know nothing -> say nothing" though.
http://cs.kent.ac.uk/people/staff/dat/miranda/wadler87.pdf
A paper by Phil Wadler about why ML languages are better than Lisp ones for teaching.
http://newartisans.com/2009/03/hello-haskell-goodbye-lisp/#c...
The author's reply to Weinreb can be found here:
http://newartisans.com/2009/03/the-jvm-and-costs-vs-benefits
Haskell is never going to go mainstream. Stop pushing it, because it's getting really tedious.
All the tutorials and theory make sense, but making the jump to what I can do with other languages still seems a big one.
Git-Annex https://git-annex.branchable.com/
A real world thing I did this week (which unfortunately is proprietary so I can't share), was a distributed configuration system for our cluster. It uses the RabbitMQ library[1][2] and Acid-state library[3] to have a per-node config-DB and uses RabbitMQ's guarantees for delivery of updates to the nodes. Messages are serialised using Aeson[4], the Haskell JSON library. I implemented a vector-clock versioning system on top of the Acid-state store to allow the clients to do conflict resolution. It really was a joy to write (around 350 lines of code). The C# client less so, 1000s of lines of boilerplate.
I think there's something really impressive about haskell; I tend to have significantly more trust in the code I write because mostly I know the edge cases don't exist. 9 times out of 10 if your code compiles it will work. Although be prepared for the compiler to hate you when you first start. The beatings are worth it though.
There's some basic code samples in the links:
[1] https://github.com/hreinhardt/amqp
[2] http://videlalvaro.github.io/2010/09/haskell-and-rabbitmq.ht...
http://johnmacfarlane.net/pandoc/
http://git-annex.branchable.com/
You are welcome :)
While Haskell has seen some usage, of course, we really haven't seen any major and widely-used non-compiler software developed using it. It's perfectly legitimate to point this out, and using very obscure counterexamples doesn't change this reality.
There's a difference between pointing it out and being a jerk while pointing it out.
Hence the downvotes.
It may be niche, but it's not unknown. If you need to convert markdown/rest/latex/etc to pdf/html/epub/etc, Pandoc's gonna come up.
http://steamcommunity.com/sharedfiles/filedetails/?id=107105...
Having a small amount of influence within a rather obscure field ends up translating to basically no importance in practice.
There are many examples of very large and critical software systems implemented in languages like C, C++, Java, C#, Perl, Python, Ruby, and others. We just don't see anything like this when it comes to Haskell, however. The examples that do exist are quite minor in reality, and this will naturally make some people skeptical about Haskell's practicality.
And Haskell predates Python, Ruby, JavaScript, Java and C#. It has had a very long time to become more widely used, yet we just haven't seen this happen. It's not like people don't know about it; many students, academics and practitioners have been exposed to it for years now, and it does get a fair amount of hype for a language that has experienced limited use in practice.
I just don't think it offers enough benefit for the cost involved with learning and using it. If the balance were better, we'd see it being used. But that isn't the case, so it sees minimal usage.
Google searches with Xmonad would then find no matches with Xmonad and crash or freeze?
Five years on, they posted it again, because maybe there's some new suckers out there.
First of all, you are right. Haskell is never going to become as common as C or Java, and I don't think anybody is claiming that it will. It is a language that is designed around theoretical concerns rather than being pragmatic. But that is exactly what makes it so valuable to learn.
There are some relatively niche situations where it might be a good choice, but those are few and far between.
We've seen the most useful and practical features offered by Haskell make their way into other more mainstream languages over the years. The more theoretical features haven't made this transition because they really aren't all that practical.
At this point, most programmers would be better off learning more about security, cryptography, databases, networking and other everyday topics than they would be by learning about the more theoretical functionality offered by Haskell.
Just curious. How much Haskell/FP experience do you have?
Functional programming does offer some benefits, in some cases. I'm not suggesting that it doesn't. And while I don't think it'd be harmful to know Haskell, I'm not convinced that the benefit it would bring is necessarily worth the effort involved, especially for programmers who are already busy with work and other commitments.
He's merely pointing out the very real fact that Haskell's adoption is quite limited, and the fact that there really isn't much truly critical software written using it, despite the hype surrounding it and its age.
I'd say it has made more of an impact by influencing other, more pragmatic languages than it has by software written using it.
Just because not a lot of programmers understand the language yet doesn't mean that programmers in the future can't learn it and take advantage of it. I hope they do, because just by programming in haskell, you automatically rule out entire classes of bugs.
Well, they certainly did that.
By the way, I don't know Haskell, but I am writing this comment from XMonad. :)