location_city Online schedule Jan 24th 10:30 - 11:15 AM IST place Zoom 3 people 28 Interested
Haskell is a high-level, safe programming language often misunderstood as lacking performance when compared to lower-level languages like C and Rust. Many believe Haskell is unsuitable for systems programming due to these performance concerns. In this talk, we will present a real-world use case that demonstrates how Haskell can not only provide a concise, practical application but also outperform low-level languages like Rust in terms of execution speed.
We will use the Haskell Streamly programming framework to implement a recursive file system directory tree traversal, printing the entire directory structure. The core of the program is just a few lines of code, showcasing the conciseness and elegance of Haskell. We will demonstrate how the program can be written in various ways to suit different user requirements, such as implementing a breadth-first search (BFS) or depth-first search (DFS). The same program can also run in either a serial or concurrent manner with no changes to the underlying structure.
We will compare the performance of this Haskell program to the Rust "fd" utility, which is known as the fastest directory traversal tool, outperforming traditional tools like GNU ls and find. On a two-CPU system, we found that the non-concurrent version of our Haskell program performs at the same level as the concurrent version of the Rust program when traversing a directory tree with 60,000 files. Moreover, the concurrent version of the Haskell program is 1.5 times faster than the concurrent version of the Rust "fd" utility.
Outline/Structure of the Talk
The talk will be organized as follows:
- Introduction to tree traversal combinators in Streamly
- Writing a basic directory tree traversal program using Streamly
- Implementing BFS and DFS variants of tree traversal
- Alternative ways to write tree traversal
- Making the traversal concurrent
- Performance comparison with Rust’s "fd"
Learning Outcome
Haskell is known for its type safety. This talk will highlight two other key benefits of using Haskell—conciseness and performance. You will learn that real-world applications can be written in Haskell using high-level code that accomplishes more with fewer lines, offering great composability without sacrificing performance, and surprisingly outperforming lower-level languages. More specifically, you will learn how to perform tree (and graph) traversals in Haskell in an idiomatic way.
Prerequisites for Attendees
While we'll be using Haskell to demonstrate a tree traversal, only a basic understanding of tree traversal concepts is necessary to follow and appreciate the talk. A basic knowledge of Haskell is helpful but not required, as the high-level code is short and self-explanatory. However, to fully grasp the underlying mechanism and how everything works, familiarity with Haskell will be beneficial.