Why SQream Technologies Loves Haskell Code

By Ami Gal

5.27.2014 twitter linkedin facebook

What exactly is it about Haskell that the SQream developers enjoy so much? In order to get a better idea, we’ve asked a few of our Haskell developers to share their thoughts on this unique programming language.
“Basic Facts” with Jake Wheat, Lead Haskell Developer

Jake Wheat


Q: What is Haskell?
Haskell is a general purpose programming language. General purpose means that it is like C++, Java or Python – you can more or less implement anything with it without too much trouble. This is unlike languages like SQL – which may or may not be Turing complete – but there are many things which you cannot reasonably implement in SQL and other special purpose programming languages.
Q: Why is Haskell a good choice to use at SQream?
Haskell comes from a family of languages which are particularly suited to compiler implementation. Haskell also has particular strengths in writing parsers compared with most other languages, which is also critical for our product.
Also, Haskell has been used at SQream from the start.  From day one, the SQL statement compiler was written in Haskell. The first prototype was pure Haskell with OpenCL kernels.
Q: How is Haskell used in the SQream Big Data product today?
Haskell comprises about 1/3 of the lines of code in the database server program. The other 2/3 are C++ and CUDA. Since Haskell is much more expressive than C++ and CUDA – loosely speaking Haskell contributes much more functionality than C++ and CUDA.
“Haskell for software development” with Ori Brostovski, Haskell Developer

Ori Brostovski


Q: How does Haskell create better quality software?
Haskell programs are more immune to human errors. The language is better geared at preventing mistakes which other languages are unable to detect. For example, in many cases if you write a line that is wrong in Javascript, the program will continue to run happily and misinterpret the line. In Haskell however, the line will “cry” before it gets a chance to run.
Q: What makes Haskell so easy to use?
I’m not sure that I would call it “easy” to use – I would say that it’s safer. In the long term, if you’re a structured person, it could give you good results.
I’d say that Haskell is consistent with itself, more than the other language and once you become proficient in Haskell it becomes easier to read code. Haskell is also very terse. People look at a piece of Haskell code – say 5 lines – and it takes them 30 minutes to understand. But the matching C++ lines will be 50 times in size and will also require 30 minutes or even more because you have to scroll up and down to memorize the code.
Also, a major benefit of Haskell allows programmers to see the whole picture easily. For example, a normal programming language can have a piece of code that says, “activate process XYZ,” then ignore it’s output and continue. In Haskell though these things are more explicit and most procedures won’t change anything from the outside. You only have input and output with Haskell.
“Why I use Haskell” with Ben Esh, Alex Baranovitch & Arnon Shimoni
Haskell Developers

SQream Haskell Developers


 
Q: What made you want to learn Haskell?
Alex: I have a mathematical way of thinking and Haskell, being a functional programming language, is based on the same ideas. Many conventional languages are more oriented to technical details rather than the essence of things, they evolved as buildups of hacks. You feel buried in details when programming in these languages. In Haskell, you can express concisely what many other languages do in a verbose manner (compare these implementations of Quicksort in different languages), so you get the whole picture right away with Haskell.
Another reason for my choice is that the language is organized in such a way that the compiler is capable of doing some of routine work for the programmer. One of such things is type inference: you are not required to write type signatures for your functions. Another one is lazy evaluation: you specify the expressions, but they are evaluated only if/when needed. Thus, compiler/run-time frees you from the burden of handling all possible flows of execution, which makes Haskell a declarative language and improves modularity of code.
Q: Has learning Haskell changed the way you think about coding?
Ben: Yes – Haskell forces you to think about your code more because it encourages you to use small functions. Instead of a large chunk of code, Haskell is composed of small functions that you can easily reason with. Once you verify a simple piece of code, verifying the actual complex code requires less testing.
Haskell also encourages productivity because you have to think about what you want to do instead of how to do it. This is especially true at SQream when everything is based around modeling complex optimizations. I think that it would be really hard to achieve this optimization in other languages. I remember when I started working at SQream, the thing that really amazed me about Haskell was that it was difficult to get your code to compile at first. Once you do though, it actually works – I don’t know any other language that comes remotely close to that.
Q: What is your favorite Haskell feature?
Arnon: If you write something in Haskell and it passes the first step, which is compiling, then it’s guaranteed 90% of the time to work as you wrote it. Usually, in other languages like C and Java, things will compile but will give unexpected results when you run it. Haskell is very strict with types though and it forces you to correct mistakes before running the actual program. This means that it’s also a lot more difficult to crash a Haskell program then a C or Java program.
 
Find out more about how we are using Haskell for Big Data – Follow SQream on twitter for daily Big Data tweets, like our Facebook page, join us on LinkedIn and find us on Google+. Be sure to check out our Roojoom’s too! Leave your comments below – we can’t wait to hear what you have to say!