News for hackers. Stuff that matters.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by GhotiFish on Sunday April 07, 2013 @12:08PM (#5507615)
I agree, auditing Haskell's performance characteristics is not easy. Then again, nothing in Haskell is easy.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by ufo on Sunday April 07, 2013 @12:21PM (#5507651)
While its true that lazy evaluation makes it harder to think about performance (specially memory use), the flipside is that it makes it easier to reason about programs at a higher level and you have more freedom when defining abstractions.

For example, in Haskell you can freely rewrite common subexpression with a let whenever you want and in whatever order you want.

    --original
    (f x) ... (f x)

    --let
    let y = f x in y ... y
On the other hand, if your language has side effects these sort of transformations are not always safe.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by plinkplonk on Sunday April 07, 2013 @12:56PM (#5507782)
having side effects and having lazy evaluation are distinct features though. One can conceive of a strictly evaluated haskell-like which isolates side effects in monads and is still largely composed of pure functions.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by ufo on Sunday April 07, 2013 @05:51PM (#5508922)
> having side effects and having lazy evaluation are distinct features though

Fair enough, but lazyness also plays nicer with things like `if` and `&&` that comput things lazily. (Without lazyness you need to add lots of wrapper anonymous functions).

Another thins is that, from a hystorical point of view, the only reason Haskell managed to be so pure in the first place was the lazyness. If your language is not lazy its very tempting to add sideeffects.

Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by tome on Sunday April 07, 2013 @03:05PM (#5508245)
One can conceive of it, and yet it's never been done. Curious.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by colanderman on Sunday April 07, 2013 @03:41PM (#5508390)
Yes it has. Mercury is a perfect example of a purely functional language which is not lazy. I/O is made functional via a uniqueness typing system.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by tome on Sunday April 07, 2013 @03:47PM (#5508434)
Right, so it uses uniqueness typing and not monads presumably.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by nilkn on Sunday April 07, 2013 @03:15PM (#5508281)
There is Idris: http://idris-lang.org/

It seems similar to what plinkplonk is talking about.

Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by tome on Sunday April 07, 2013 @03:41PM (#5508394)
Hmm, I always thought of Idris, Coq and Agda as proof assistants rather than programming languages, but perhaps that's just me being unimaginative.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by cyrus_ on Sunday April 07, 2013 @04:35PM (#5508643)
Idris is explicitly billed as a programming language. You can do pretty sophisticated programming in Coq too (Coq can be reasonably straightforwardly compiled down to Ocaml, Haskell and some other languages.)
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by tome on Sunday April 07, 2013 @06:30PM (#5509037)
I'd better spend some time checking it out then!
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by gtani on Sunday April 07, 2013 @03:18PM (#5508287)
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by tome on Sunday April 07, 2013 @03:43PM (#5508406)
I'm not really sure how "pure" Disciple can be considered to be, and it doesn't use monads does it? Perhaps I'm being ignorant though.

Mu is a great example. I wish there was more information about it publically available.

Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by miga on Sunday April 07, 2013 @12:15PM (#5507632)
Writing short and clear code in Haskell is definitely easy. As for optimization - it quite often does it for you too!
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by GhotiFish on Sunday April 07, 2013 @01:00PM (#5507793)
!!!

I have never met a single person who has said this, let alone capable of following through.

If you are capable, I am envious of your determination/natural talent. Or alternatively I and every programmer I know are idiots. Actually both seem like possibilities.

Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by nilkn on Sunday April 07, 2013 @01:10PM (#5507823)
> Or alternatively I and every programmer I know are idiots.

Most programmers haven't taken the time to actually learn Haskell.

Haskell only seems hard at first because it incorporates a lot of ideas that other languages do not. For a lot of developers, learning Haskell is a little bit like learning to program from scratch all over again.

In that sense, yes, I guess it's hard, but so was whatever language you learned first.

Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by mbel on Sunday April 07, 2013 @02:05PM (#5508010)
> For a lot of developers, learning Haskell is a little bit like learning to program from scratch all over again.

I find this to be the greatest joy of learning a new paradigm, everything is new and unknown, so even simple things are fun (again).

Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by miga on Monday April 08, 2013 @02:33PM (#5513568)
> Haskell only seems hard at first because it incorporates a lot of ideas that other languages do not. Indeed, even if you know Haskell, it may take years to master all classes in its standard library and most commonly used modules (like Parsec.)
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by swift on Sunday April 07, 2013 @01:25PM (#5507873)
I have to agree with the GP here. Haskell is actually an exceptionally simple, easy language to work with, once you get the basic concepts down. I have occasionally suffered some confusion in Haskell because of poorly documented third-party libraries, but the language itself is a joy.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by viraptor on Sunday April 07, 2013 @01:51PM (#5507970)
I'd add a qualifier that if you know what you're writing and you're writing from scratch, it's relatively easy. Modifying existing programs can present an interesting challenge.

For example once you have a working program and decide that actually some value could be read/written using a file instead of computed at runtime and the place you use it is 10 levels deep after calling a non-IO function, you've got two choices. Unsafe IO (then why not use it everywhere) or a minor program redesign. Haskell is the only language where I run into this kind of situation. (it's still quite simple despite this)

Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by mightybyte on Sunday April 07, 2013 @09:09PM (#5509475)
I'd actually argue that modifying existing programs is where Haskell really shines. Strong static types and purity allow you to know a LOT more about arbitrary bits of code than any other language in mainstream use today.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by tome on Sunday April 07, 2013 @03:07PM (#5508250)
If your program is well factored then it probably won't be hard to switch to IO ten levels deep. Bonus: Haskell makes refactoring easy!
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by viraptor on Tuesday April 09, 2013 @09:47AM (#5517992)
Yes, but what happens to apps which depend on this piece of code? Suddenly the signatures change and you affect everyone with a change which should be completely transparent for them.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by tome on Tuesday April 09, 2013 @05:02PM (#5521347)
It's hard to discuss without an example.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by ghc on Sunday April 07, 2013 @03:43PM (#5508407)
Haskell has a difficult learning curve, that is all. A person coming to Vim from a modeless editor might feel the same way, but nobody doubts that someone familiar with Vim finds it easy to use. It took me a couple of years to "get" Haskell, but once you do it is very easy write clear, concise code with.
Re:Haskell Beats C Using Generalized Stream Fusion [pdf] by gtani on Sunday April 07, 2013 @04:23PM (#5508585)
!!! I'm sure you're not an idiot.

Have you tried the School of Haskell, it incorporates the minimum viable skills for learning haskell (pulling code apart in the REPL, and understanding type signatures, pattern matches and compiler type check errors)

https://www.fpcomplete.com/school/how-to-use-the-school-of-h...