HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
Running a Startup on Haskell

Bryan O'Sullivan · InfoQ · 121 HN points · 2 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention Bryan O'Sullivan's video "Running a Startup on Haskell".
Watch on InfoQ [↗]
InfoQ Summary
Bryan O'Sullivan presents a case study of a small startup that chose Haskell for its server-side code, outlining the advantages and disadvantages of using Haskell to quickly create a solid solution.
HN Theater Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
Oct 31, 2011 · 121 points, 37 comments · submitted by puredanger
antipax
Haskell web frameworks are maturing rapidly and the language is a joy to work in, once you learn how to approach problems in it. Haskell has probably not reached the peak of it's popularity yet (and frankly it's overdue for some mainstream love).
viscanti
I think Haskell (and functional languages in general) will become increasingly popular as it is (they are) a powerful way to deal with concurrency and can easily take advantage of multiple processors. Languages are tools in a developers toolbox, and Haskell turns out to be a powerful one for several growing problems.
danieldk
It's not just that. Haskell has exceptionally strong typing and containment of mutable computations, making it much easier to write correct programs. When a module compiles, it's usually pretty bug-free.
pbz
How does the strong typing compare with Java/C#? Thanks.
tikhonj
Several things jump out immediately:

  - Haskell has exceptionally thorough type inference (almost all type declarations are optional).
  - anything impure (e.g. involving an I/O) is typed as such
  - the types are easier to read and tend to give a good idea of what the function in question is doing
  - much more complicated types are readable
  - idioms like Monads lead to a lot of code that is much more abstract and generic than anything I've seen in Java. There are tons of library functions that can work on lists, or IO things, or parsers, or random values...
Some things that I found particularly cool in Haskell: - functions (and even constants!) can be polymorphic on their return type. The function read, for example, always takes in a String but returns whatever type you happen to need. - You can easily express things like a "list of list": [[a]]. I don't even know how to begin writing a function like join in Java. (On lists, join takes a list of lists of something and flattens it.)

Overall, I've found Haskell's type system to be much more useful, and much less of a burden, than Java's.

That said, I'm just a college student with limited experience with either language. I've used Java more than Haskell but I've been using the latter more recently; I've never used C#.

Dn_Ab
The higher order monadic join concept cannot be implemented in java but a simpler function in terms of flattening a list of list is easy enough. In a functional language a simple way would be to fold over (++) append.

so in java a simple way would be to initialize an l = arrayList and then do a foreach on each list in the list of the lists and foreach element in each list add it to the arrayList l. Not as elegant, much more how instead of what but 4 noisy lines max.

C# has list.selectMany( _ => _ ) for that.

eru
> In a functional language a simple way would be to fold over (++) append.

Though you probably wouldn't want to do use that approach for performance reasons.

skybrian
Maybe it's better with more experience or when you're reading your own code, but I find that reading a Haskell program is often like reading a math paper - you can't skim it; you have to slow way down and study it, one line at a time, and look up the definition of each term as you go and think about what it means, and try out simple examples. And sometimes you don't have the background to understand the underlying concepts, so you have to study a prerequisite first.

So I think to like Haskell, you have to truly believe that more abstraction is better. It's very much a mathematician's language.

The thing is, when writing code, I don't want to write a math paper. When I'm done, I want it to be as smooth and easy to read and as obvious as an article in the New Yorker.

nightski
It has nothing to do with being a mathematician. There are common patterns as any language. Those patterns often end up as higher order functions. But at some point, it becomes very natural to read.
jerf
"When I'm done, I want it to be as smooth and easy to read and as obvious as an article in the New Yorker."

Your metaphor is apt; if your code is going to be that smooth, you need to learn Haskell to the same extent you know English for the New Yorker. The Internet suggests that the New Yorker is written for a "10th grade reading level", but of course the average American has between an 8th or 9th grade level.

It does get easier with practice to read the language, and what's left after that is whatever core difficult the code being expressed has regardless of the target language, the essential difficulty. Haskell can hardly be blamed for bringing that to the foreground where other languages stuff it in the background.

skybrian
If I learn Haskell well and start writing code that's idiomatic for that audience, I'm limiting my audience to the few people who also know Haskell (and the particular Haskell idioms I'm using). It's like writing in Esperanto instead of English. My ideal is more along the lines of the Python examples that Peter Norvig writes, which can be understood by pretty much any programmer, even if they're not all that fluent in Python.
chancho
Space leaks, stack overflows (foldl vs. foldl'), failed pattern matches (head []), etc. There are tons of bugs lurking in well-formed Haskell programs.
nightski
Tons being a vast overstatement. I mean, you could exploit these things to cause bugs, but really do you encounter them on a day to day basis? I know I rarely if ever have.
jsdalton
Does Haskell offer any tangible, practical advantages or benefits over other languages in the context of a web framework, aside from just "if you prefer a functional style of programming and you're working on a web project, here's a way to do it"?

I'd love for somebody to convince me why a Haskell approach to web frameworks is superior to Python/PHP/Ruby/JS beyond the usual "it's a matter of taste" argument.

supersillyus
For one, GHC gives you M:N threads with the runtime handling the async IO under the hood, making it possible to write code in a simple blocking style while still getting use of all your cores and having fast IO. This is also true for Erlang, Go, and a few others, though, and it's not terribly relevant for lots of simple web code, but it is a practical advantage.
jerf
"Does Haskell offer any tangible, practical advantages or benefits over other languages in the context of a web framework, aside from just "if you prefer a functional style of programming and you're working on a web project, here's a way to do it"?"

At the moment, my answer is "Not yet, but ask again in a year." There are tons of interesting things happening in the area of letting you have "performance, correctness, rapid development and prototyping, pick three", but they're still in the early phases yet.

jamwt
Haskell's advantages (and disadvantages) as a Web Framework are generally the same as in any other application domain: performance, concurrency, and correctness.
zura
While I agree regarding correctness and concurrency, I wouldn't emphasize performance, even for Java and .NET, whose GCs are more developed, tuned and tested in the production environment than Haskell's one.

Edit: And for Haskell, achieving needed performance can be quite tricky with regard to its laziness.

jamesbritt
There was some discussion on HN about the Snap Web framework benchmarks relative to some other frameworks: http://news.ycombinator.com/item?id=1380405

No .Net in there, though.

danieldk
Edit: And for Haskell, achieving needed performance can be quite tricky with regard to its laziness.

But Snap is driven by enumerators/iteratees (via the enumerator package), which make it much easier to do fast near-constant space IO.

I have built a web application that uses Snap to query large (parse) treebanks, and it was easy to make it performant.

looser
I only read the slides, but at one point the author mentions that they've built an hybrid app using (Haskell + C#).

Next, the author mentions about several limitations that C# has and that Haskell has a much better approach.

So, why use C#? Why not only use Haskell?

taudelta
He mentions that later on during the Q&A session
looser
Ok, thanks.
tome
Could you please repeat it here so we don't have to search? Thanks.
dan00
Their application is an extension of Outlook, which only has a dot.net API.
tome
I wonder why they didn't use F#.
dan00
Brian just didn't wanted to have another risk, because F# is less mainstream than C#.
jamwt
He answered that too: language maturity. He was unfamiliar with the .NET ecosystem in general, and the availability of help/expertise/examples etc was much greater for C# than F#.
bos
Our app consists of two parts: there's a client component that integrates into Outlook, and a server part that does all the actual heavy lifting.

The client-side code is written in C# because the .net APIs for Office are the easiest to deal with.

crasshopper
So no-one has built a QuickCheck for Ruby or Python?

I'd like to use this "property-based testing" he stressed.

fl3x
There are plenty of implementations linked from http://en.wikipedia.org/wiki/QuickCheck. (I'm not sure in what state they are though.)
dustingetz
anyone watch this yet? worth the 50 minutes? is there a transcript?
Unboxed
Absolutely!
rednaught
If you're interested in Haskell then yes it is a good presentation. In my opinion, Bryan is one of the more thoughtful speakers around.

Slides are here: http://bos.github.com/strange-loop-2011/talk/talk.html#%281%...

Navigation uses keyboard arrows.

He had a similar/same talk about a month prior and here is the video on Vimeo if you're not a fan of InfoQ's format:

http://vimeo.com/27192476 (Bryan O'Sullivan - Building Solid Distributed Applications with Haskell and Riak)

Unboxed
Terrific video! Thank you very much for posting! UP!
JoshTriplett
For anyone who'd prefer a direct video link rather than the infoq flash player: http://d1snlc0orfrhj.cloudfront.net/presentations/11-sep-run...

(Retrieved by setting my User-Agent to that of an iPad, which causes infoq to serve up a <video> tag.)

jamesbritt
Thanks for the link, and for the hack. That's quite handy.
HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.