Hacker Newsnew | comments | show | ask | jobs | submit login

Why can't we have the expressiveness of CL or Haskell with the performance of C++?



We can, theoretically. We just haven't yet developed algorithms that are clever enough to make the correct optimizations to code in enough of the cases where such optimizations are possible. There are patterns in our code that we humans can write out when we write our code in C++, but that we haven't yet formalized and implemented for the computer to do.

-----


We do, its called the D programming language.

-----


  map (head &&& length) . sort . group
  
  filterM (const [True, False])
Can you show how you implement these in D?

If you want, I can explain these or give other examples of expressiveness I don't think you'll find in D.

-----


Links explaining these Haskell code snippets:

http://stackoverflow.com/a/10410997/578288 – the `map` snippet converts a flat list into a multiset represented as a list of `(count, element)` tuples

http://stackoverflow.com/a/5378799/578288 – the `filterM` snippet returns the powerset of its list argument (http://en.wikipedia.org/wiki/Power_set)

-----


That is one of the best implementations of powerset I've seen in a while. Thank you for that!

-----


I think you mean group . sort

-----


Oops, quick-typing on my phone can have problematic results :-)

-----


That feels a little surprising to me. Last time I looked at D it was nowhere close to CL or Haskell in expressiveness? (It was certainly better than C and less complicated than C++).

Has there been significant improvements in the past couple of years?

-----


There really has. D 1.0 has 20 days of life left, and D 2.0 is really amazing. It has the C++ idea of "it's only there if you want it" but taken to an amazing degree. Yes, it's a little more verbose than most FP languages, but honestly, if you're interested in verbosity, go use J or Coke.

The thing I like about D is that there's no surprises, everything works the way you'd expect it to. You can guess at what code should look like, and chances are it'll work.

-----


Can you detail, or point to background info? There've been type system debates between proponents of Haskell, ocaml, SML, scala, and F#, i've never seen a D to Haskell comparison, and I've never seen D mentioned as a "free theorems" language. Maybe in this vid:

http://channel9.msdn.com/Blogs/Charles/Alexandrescu-Bright-M...

Here's a scala to haskell

http://www.cs.ox.ac.uk/jeremy.gibbons/publications/scalagp.p...

-----




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: