Hacker News new | comments | show | ask | jobs | submit login

Interesting that despite having what looks to me like Haskell and CL expertise, Slava's RethinkDB (various article describe as a "founder") seems to be written in C++.

What do Haskell or CL implementation lack to be competitive with good old C++ there?




When writing a database, performance is extremely important. Languages like C++ give you manual control of the computer's resources, which means you can count on predictable performance and memory management. Why is this important? All of your database code must be written with the performance characteristics of your data structures in mind. You need to know how long certain operations or memory swaps will take so that you can optimize data throughput.

While CL and Haskell can be extremely fast and even outperform C++ in certain situations, the lack of manual resource management makes them ill suited to writing a database system. There are few, if any, applications where this matters so much.

-----


So what unpredictable performance characteristics do CL & Haskell exhibit, that languages like Java or Erlang do not?

Consider Neo4J, Cassandra, CouchDB, Riak, Voldemort, all major players in the current NoSQL world. All use Java & Erlang.

Just how much computation does your database need to do, unless it's some special in-memory database like Redis? If you have your data on ordinary disks, you'll spend most of the time waiting for them.

-----


Space leaks are a big problem in Haskell that many neophytes and experts alike get massively caught up in—laziness is a double-edged sword.

-----


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...

-----


For example, the RethinkDB coroutine engine is written in assembly. We couldn't come close to the same level of control in any other language. For systems programming C and/or C++ are still kings.

-----


Hopefully Rust will soon become a viable alternative.

-----




Applications are open for YC Summer 2016

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

Search: