An interview with Sam Halliday
00:00
00:00
  • September 12th, 2018

A Q&A Sam Halliday, Author of Functional Programming for Mortals with Scalaz

00:00
00:00
1 MIN
In this Episode

Sam Halliday is the author of the Leanpub book Functional Programming for Mortals with Scalaz. In this Q&A, which was conducted over email, Leanpub co-founder Len Epp talks with Sam about his background, his work, an amazing project to create educational materials in South Africa, the truth about what he thinks about open source, his book, and at the end, they talk a little bit about his experience as a self-published author.

The very brief audio of an introduction to the Q&A is here. You can subscribe to the Frontmatter podcast in iTunes or add the podcast URL directly.

Transcript

Hi I’m Len Epp from Leanpub, and in this Leanpub Frontmatter podcast I’ll be interviewing Sam Halliday.

Sam is a technical leader, chartered mathematician, and software engineer, with a Ph.D. in Mathematical Physics. He has experience in a number of industries working for some huge organizations, including Disney, Morgan Stanley, and the UK's Ministry of Defence.

Sam is the author of the Leanpub book, Functional Programming for Mortals with Scalaz, in which he argues for the merits of the Functional Programming paradigm to readers presumed to be skeptical of it or curious about its merits.

In this interview, we’re going to discuss Sam's background and career, professional interests, his book, and at the end we'll talk about his experience using Leanpub to self-publish his book.

So, thank you Sam for doing a Q&A for the Frontmatter Podcast.


Len: I usually like to start these interviews by asking people for their origin story. I can see from your profile you've studied in lots of different places - Northern Ireland, South Africa, Scotland. Can you tell us a little bit about where you grew up, and how you found your way to doing a Ph.D. in Mathematical Physics?

Sam: I grew up in the outskirts of Belfast: I was a teenager when the conflict was calming down. I was brought up on a healthy dose of Star Trek TNG and that is where I got my passion for physics, engineering and astrophysics.

I was the first person in my family to stay in school past the age of 15, and to go to university, which was gratis in those days. I felt like I had a real opportunity nobody before me had been given so I put my head into the books.

A friend from my hometown had family who emmigrated to South Africa in the 70s and they offered me a place to stay, so I visited on a cheap flight, and fell in love with the country and the people. I arranged a visit with the University of Cape Town and found a crazy old professor who wanted to find out what was at the center of the galaxy. It was a no brainer to take him up on an offer of a research Masters. I did well in my undergraduate exams and was accepted.

While I was in Cape Town, it was quite clear how unbalanced and unfair the education system was. They had recently broken down apartheit but many schools had neither the funds nor the teaching experience to educate the next generation. We had kids coming up to us at open days wanting to learn physics because they had no textbooks. So we set about creating a free textbook for mathematics, physics and biology. I created the first draft of the physics book, and did some work on the mathematics book. I made sure that we used a copyleft license so that the books would not only be gratis, but the students and teachers would have the freedom to do what they wished, including creating their own books and exercises.

We were laughed off the stage at a teacher's conference by the publishing establishment. But the books, after much rework, were eventually blessed as an official curriculum textbook, and the government printed and shipped millions of copies reaching every school in the country. Mark Horner, who did much more than I did, set up Siyavula.com to ensure the continuation of the books, and to provide further education services.

While I was in South Africa I became increasingly interested in the more theoretical side of physics, and that led me back to the UK for a funded PhD. But I found that String Theory was not addressing any relevant problems, so I became more interested in Operations Research, a subject concerned with the application of mathematics to real world problems, and since there were no companies doing that in Scotland, I created one.

Len: What does it mean to be a "chartered" mathematician?

Sam: Achieving chartered status in any profession denotes to the wider community a high level of specialised subject knowledge and professional competence. I was nominated by an esteemed colleague, who was a fellow of the institute, after about a decade of solving real world problems. One of the most frustrating things about being an industrial researcher is that our work is not published, so we'll take any recognition we can! I have had the unpleasant experience of seeing my work independently rediscovered by academics, years afterwards, and published in a prestigious journal.

Len: I gather you're a big supporter of, and contributor to, open source software. How did you get into open source, and why is it important to you?

Sam: This is a common misconception. In fact I stand in opposition to "open source". It is a way for some greedy companies to exploit intellectually curious engineers without paying them. The Amazon Software License is a clear example of an "open source" license that does not respect its users or contributors.

Len: You're also a self-described "Free Software / education zealot." Why?

Sam: I much prefer the Free Software movement, and I refer to all the public software that I release as "free software", not "open source". The Free Software Foundation's goals are to ensure user freedom, meeting the criteria that a user can:

  1. run the program as they wish, for any purpose
  2. study how the program works, and change it
  3. redistribute copies
  4. distribute copies of their modified version

I believe these criteria are essential for a free and innovative society, whist also being compatible with the goals of commercial organisations.

The tech industry needs to wake up to the fact that almost every company is built on the backs of volunteers. We need a way for free software contributors, who may subscribe to the "open source" propaganda, to be properly reimbursed for their efforts.

I apply the same philosophy to education: financial circumstances should not dictate what somebody can and cannot study. It is so rare to find an eager mind that is open to learning: our society should not be making it difficult to learn, by putting financial barriers in the way.

Len: While researching for this interview, I found my way to your GitHub page, where you mention in your profile that you've moved to GitLab. Why did you decide to get off GitHub? In your profile, you mention the Free Software Foundation guidelines.

Sam: Github has been a double edged sword. Whilst it has made it easier for free software contributors to collaborate and share ideas, it has also made it easier for corporates to exploit their work and for end users to demand support and attention: something that is not a part of the deal that I signed up to.

Gitlab is Free Software, whereas Github is not. I feel it would be hypocritical of me to use a non-free solution when I could instead use a free one. I am a paid up subscriber, of course! :-) Free as in freedom, not free as in beer.

Len: One of the fun things about this podcast is that I get to interview authors from all over the world, and ask them for a local's perspective on political events our audience may have heard of, but only experienced in the headlines. In that spirit, and partly because I lived in the UK for nine years myself, I've been asking people from there about Brexit. I believe you're the first person living in Scotland that I'll have asked about this, which is particularly interesting, partly because of the independence referendum held in Scotland not too long ago. What are your thoughts on how Brexit will affect the industry or industries you're working in?

Sam: I voted against Brexit. I hold dual British and Irish citizenship so it felt very aggressive that people were voting to throw out half of me.

My wife and I put plans in action to leave London as soon as the result were announced. Many people I know in the tech industry are making similar plans.

I prefer to consider the second order consequences on the tech industry, rather than the immediate ones, which are all quite unpleasant. We already see many talented people leaving the UK, so perhaps companies will need to become more remote worker friendly in order to attract talent. If they are still relevant.

Len: And, if you're willing to indulge us and share them, what are your own thoughts on Brexit more generally?

Sam: It is clear that the politicians misled the public, and that many things will be worse, especially for the most vulnerable in society.

But life goes on and there is nothing I can do about it, so I largely ignore everything I read.

I have the utmost confidence that British political incompetence will see us through whatever challenge we face.

Len: You've had a ton of experience working for very big and in some ways imposing institutions, including Disney, Morgan Stanley, and RBS (the Royal Bank of Scotland). It's hard for me to narrow down what I'd like to ask you about, but as I used to work as an investment banker in London, I thought I'd ask you about what always was a bit of a mystery to me, which was the tech side of complex trading mechanisms and tools. Insofar as you're able to, could you talk a little bit about that kind of work, and what it's like? Is it particularly high pressure, with so much money on the line, and in such a competitive space?

Sam: I can't go into details, in respect for the confidentiality I hold with my customers, but I can say that I do not find these environments to be as high pressure as they are reputed to be.

My approach is to get as close as possible to the business, to fully understand their objectives and pain points, so that I can incrementally deliver something that helps. The vast majority of engineering work is drudgery, so it helps to be part of a solid team that knows it is moving in the right direction.

The most rewarding roles for me have been when there has been a desire for dialogue. A lot of pressures can be put down to the style of communication, or lack thereof.

About the Book

Len: What is Scalaz?

Sam: Scalaz is a library extension to the Scala programming language that allows the developer to use principled functional programming techniques.

Len: You mention in the book that it's meant for people who may be skeptical about the Functional Programming paradigm. Can you maybe explain a little bit about what Functional Programming is, why people are skeptical about it, and why they should consider embracing it?

Sam: Scala marries Object Oriented Programming with Functional Programming. The vast majority of Scala developers, myself included, come from a Java background which implies an understanding of the Object Oriented approach but a fear of the unfamiliar when it comes to Functional Programming. As a result of this divide, the Scala community can be quite volatile.

There are many problems with the object oriented style, which I have discovered the hard way, that I feel are addressed by functional programming. I believe that functional programs are more likely to be correct, can be more easily tested, are more modular and are also easier to maintain. Fundamentally, there is a lot less to keep in your head as a developer when using functional programming.

Len: What's a Monad?

Sam: There have been a lot of recent attempts to describe Monads in terms of everyday concepts: Monads are burritos, Monads are boxes, Monads are pipes, etc etc. I don't feel the need to dumb down my material so that it can be consumed by the general public.

The target audience of my book is the professional developer community, so I present Monads in a way that a professional developer can understand and appreciate, including a full chapter covering the variety of different Monads that are readily available for use.

Sorry if you expected another food analogy :-)

Len: You write in your book: "Earlier chapters encourage coding styles that we will later discredit: similar to how we learn Newton’s theory of gravity as children, and progress to Riemann / Einstein / Maxwell if we become students of physics." I can't tell you how much I agree with this approach. My brother's got a joke about how when people say something like, "It's Economics 101," they're actually betraying the fact that they don't understand that what you learn in your first year is necessarily wrong in a fundamental way, because it has to be in order for you to begin learning about the subject. This is similar to the concept of a "hermeneutic circle" in philosophy. Why is it that you adopted this approach in your book?

Sam: Thank you! I hadn't thought of it that way. The typical reader will be coming to this book with a lot of baggage from Java and Scala, and I felt that in order to reach a kind of middle ground, a lingua franca, I needed to compromise a little in the beginning.

For example, the typical Scala developer will know the "Future" construct, but this is not something that a functional programmer will use. In the first two chapters, I am quite liberal in my use of Future to explain a tangential concept, which is not unrelated to Monads. This may horrify some functional programmers, but it is just so that we can make the reader feel welcome and comfortable in this new world.

Len: Your book is "Copyleft." Can you explain what that means, and why you chose this approach?

Sam: Earlier we discussed Free Software and what it means to be free. Copyleft adds one additional condition:

  1. if you share this, it [will] still be free, including any changes.

As with all things, there are subtelties. My book uses a form of Strong Copyleft, which means that anything derived from the book must also be copyleft. This is like the GNU Public License that covers many of the tools used to produce the book: Emacs, Linux, git, etc.

There are also forms of Weak Copyleft, such as the LGPL, which is my preferred license when writing Free Software. This license says that you can include my software in a proprietary product, but the parts that I wrote, and your changes to it, must also be free. I think this is a fair arrangement.

Consider that you release some free software, and somebody sells you a product containing your software with some changes. You cannot see the source code or use the software as you wish. This is what can happen with licenses like MIT, BSD and Apache. But if you used LGPL or GPL, they would have to give you the same freedoms you gave them.

About Writing and Publishing

Len: Can you tell me how you found out about Leanpub, and why you chose us for your publishing platform?

Sam: I bought a book on holiday a few years ago, I learnt about leanpub through the introduction page.

Len: Leanpub was started by authors who were really opinionated about their > writing and publishing tools. What tools do you use in your writing?

Sam: I use GNU Emacs and write my book in org-mode, with figures in graphviz. It was easy to write a script that produced the Leanpub flavour of markdown from this.

I have several people interested in translating the book to other (human) languages and they are comfortable editing the Markdown directly in a text editor.

Len: Is engaging with people who have already bought your book (like getting reader feedback) important to you?

Sam: I think it was more important at the beginning of the book when I was trying to plan the structure. But as the book progressed, and I was soliciting feedback, I found that opinions were quite contradictory, so I retracted the request.

When I had decided on the audience and scope of the book, I was less willing to shift my approach, for better or worse. Some readers who gave feedback would not realise that a simple request such as "can't you just talk about X in chapter 2?" would require a complete rewrite because the reader doesn't yet know about Y and Z that are needed to understand X.

The greatest feedback is when people point out specific errors in the text, with corrections. I have a public issue tracker for this and I am grateful to anybody who takes the time to fill it out.

Len: If there was one thing you could ask us to do to improve Leanpub, what would you ask us to do?

Sam: Ethically, of course, it would be most excellent if your software were available under a strong copyleft license! It would have helped my workflow if I was able to produce PDFs locally. Although I would probably have gone down a rabbit hole and sent you patches to quirks as I found them.

Technically, I think it is good that you are continuing to focus on additional formatting options. There are some small things that I would have liked to do when writing the book, such as centering quotes on a page, or customising the Scala code highlighting.

From a reader perspective, I think a lot of my readers would appreciate it if they could pay with their local currency.

Podcast info & credits
  • Published on September 12th, 2018
  • Interview by Len Epp on August 30th, 2018