Monday, February 25, 2008

Practical Erlang Mini-Interview

I’d like to thank Francesco Cesarini and Mike Loukides for taking a momen to answer a couple of questions about O’Reilly’s upcoming ‘Practical Erlang Programming’ book. I think getting answers straight from the horse's mouth is a lot better than the other rumours I’ve posted. Hopefully, I’ll be able to pin Francesco, Jan, and Mike down for some more questions as the book progresses.

You talk about this book being less broad, but deeper than Programming Erlang: Software for a Concurrent World. What does this mean to you?

Francesco To me, it means the ability to ensure that everyone, regardless of background and previous knowledge of programming languages, is able to pick up the book and learn Erlang. Having taught Erlang to everyone, from corporate clients to university students, I know where they struggle and where the problems have been throughout the years. On one side, this resulted in our training materials evolving. On the other, it resulted in our teaching methods and hands on examples evolving. We are going into all of these details, explaining in depth areas we know readers will struggle with. We will be using many more examples, both from our training material and from our lectures, where we ask the delegates to use the shell as we explain the theory.

Why now? What makes you think the market is ready for another book on Erlang? What’s changed?

Francesco Erlang is expanding exponentially. Concurrency and SMP together with Joe’s book have pushed it to its next level. This has resulted in a critical mass which is helping us generate even more users. The market is ready not for one or two books, but for many books, as they generate traction and help each other. My hope is that this will result in an even greater critical mass.

Mike I tend to sign books on technologies that I want to learn about, or that I think I need to learn about. We tend to cover this up with lots of stuff that we call market analysis, but ultimately, that’s what it comes down to.

I was really surprised to see that the Haskell talks at OSCon were not just well attended, they had all the top spots. We didn’t have anything going on in Erlang, but my guess is that it would have shared the top of the list with Haskell. It’s not entirely clear what’s driving this. In the Ruby world, there are clearly a lot of concurrency issues that Erlang can help to solve. (One of the things that convinced me of the importance of Erlang was Lucas Carlson’s drproxy, which is a distributed reverse proxy server written in Erlang.

But I don’t think the Ruby community is really driving the interest in Erlang or in functional languages. There have been many other things happening: Microsoft’s F#, functional features in Sun’s Fortress, the Scala language, etc. What seems to be driving the interest is the idea that functional languages are going to make it easier to exploit parallelism, in a world where a low-end laptop has 8-16 cores. We’re not there now, but give it a few years and we will be. I certainly feel that programming paradigms are shifting, and they’re shifting in the direction of functional languages. Erlang is benefitting from that shift—particularly since Erlang was designed from the bottom up with concurrency in mind.

Wednesday, February 20, 2008

More Book Rumours

I spent about an hour on the phone with a publisher yesterday (not O'Reilly or the Prags) talking about their plans for functional and concurrent programming books. I've got to say that I came away pretty excited about what they have in mind. I won't name names or post a lot of details, but here are three cool things that stood out:

  • They get the idea that there are two groups of people wanting to learn Erlang (Erlang programmers and programmers who want to learn more about Erlang's approach to concurrency) and they are targeting both camps.

  • They're talking about more than one book — I'm not sure how many though

  • Their first book is planned to be very hands-on, which I think is great.

Once they're a little bit closer to making announcements, maybe I'll have some more news to post. On a related note, I'm hoping to have some more information on O'Reilly's Practical Erlang soon too.

Wednesday, February 13, 2008

Not Just a Rumour

Just a quick update to yesterday’s post. I think we can confirm this rumour. As Mamut mentioned this presentation mentions the book. I’ve also heard back from Mike Loukides inside O’Reilly. I asked him if O’Reilly was really working on an Erlang book, and he told me:

It’s true. There’s not much that I can say right now—the Erlang book is still in the very early stages. So any predictions I can make about when it’s likely to be available are likely to be wrong. But they’re off to a good start, though.

Good news all around.

Tuesday, February 12, 2008

Books and Rumours of Books

Hot on the heels of the news that ‘Hardcore Erlang’ is no more I’m hearing rumours that O’Reilly is working on a ‘Practical Erlang’ book to go alongside their ‘Practical Haskell’ book. My informant has told me a couple of things:

  1. the authors are also involved in teaching Erlang classes

  2. there is going to be a website for the book soon

  3. the book is going to be deeper (though less broad) than Programming Erlang: Software for a Concurrent World

I’m hoping to get an interview with the authors as the book gets closer to publication. Until then, I’ll see what more information I can lay my hands on.

Wednesday, February 6, 2008

Feb 2008 Tidbits

Okay, here are a few quick bits about Erlang that I wanted to get up for people to see.

It looks like Erlang Training and Consulting Ltd is going to be busy with Erlang training in the US this year. They’ve scheduled seven courses spread over four US cities this year. If you’re in Los Angelas, New York City, Chicago, or Palo Alto (or close enough to make the trip), you might be in luck.

If those courses won’t work for you, you might also keep your eye out for the Pragmatic Programmers Erlang Sutdio. The only one scheduled so far is in Chicago, and is already full, but who knows where the next one will be—maybe you can talk the prags into bringing one to your home town.

Speaking of the prags, it looks like Joel won’t be doing the Hardcore Erlang book for them after all. As Kevin wrote over on his hypothetical labs blog, this is really too bad. I was looking forward to a follow up to Programming Erlang. The silver lining to this cloud is that Joel will be posting the content to his blog.

Monday, October 8, 2007

Reading SICP 1.1.6

This time around, I’ve decided to toss the translations for Ruby, Factor, and Erlang into the same post instead of trying to juggle multiple posts and point them all at one another. So, without further ado …

Section 1.1.6

Let’s take a look at section 1.1.6, the goal of this section is to look at conditional expressions through implementing an absolute value procedure. the book iterates through a couple of versions, trimming away fat. In each of my examples below, I’ve only shown the final product.

In Ruby, the code should look something like this:

def abs(num)
if num < 0
num = -num
return num

In Factor it looks like this:

: abs ( n -- n ) dup 0 < [ -1 * ] [ ] if ;

And in Erlang it looks like this (I’ve left out the administrative bits from the top of the file):

abs(A) ->
case ( A < 0) of
true -> -1 * A;
false -> A

Exercise 1.3

Esercise 1.3 asks the reader to write a procedure that takes three numbers and returns the sum of the squares of the largest two of them. In each case below, I rely on the previously defined square and sum-of-squares (sum_of_squares) procedures.

Ruby was pretty easy:

def sum_squares_of_larger(a, b, c)
sorted_nums = [a, b, c].sort.reverse
sum_of_squares(sorted_nums[0], sorted_nums[1])

Factor took me a while to figure out (mostly in trying to figure out how to build the array):

: top-two ( x,y,z -- x,y ) 3array natural-sort reverse first2 ;
: sum-squares-of-larger ( x,y,z -- x ) top-two sum-of-squares ;

I’m least sure of my Erlang code. I couldn’t find a good function for sorting the array, so I borrowed the qsort function from Programming Erlang. In any case, here’s my cut at it:

qsort([]) ->
qsort([Pivot|T]) ->
qsort([X || X <- T, X < Pivot])
++ [Pivot] ++
qsort([X || X <- T, X >= Pivot]).

last_two([H|T]) ->

sum_of_squares_of_list(L) ->
lists:sum([square(A) || A <- L]).

sum_squares_of_larger(A, B, C) ->

What I learned

The biggest thing I’ve taken away from this exercise so far is that I really need a good Factor book that covers both the language and the vocabulary. Along similar lines, Programming Erlang is a good book, but it could have spent some more time on basic programming (especially covering the provided functions in something other than an appendix).

Factor has been the language that’s been hardest to wrap my mind around so far. At the same time, it’s the one that I’ve enjoyed the most—I also think the word definitions have a sort of terse beauty. I think Ruby is probably the one that most programmers could just pick up and maintain though.

Next up, Section 1.1.7 “Square Roots By Newton’s Method”.

Thursday, October 4, 2007

Reading SICP in Erlang: Section 1.1.4

Ok, here’s my erlang take on Section 1.1.4 of SICP, or you can go look at my Ruby or Factor versions.

Unlike Scheme, Ruby, or Factor, I’ve got to put the code for the square and sum_of_squares functions1 into a separate file. I’m not going to explain the mechanics of the file, but we can take a look at the functions themselves.

square(A) -> A * A.
sum_of_squares(A, B) -> sicp:square(A) + sicp:square(B).

square has an arity of 1 (it takes a single argument), and returns the value of that argument times itself. Because mulitplication only works with numeric types, it will work for integers and floats, but will fail for non-numeric arguments.

To execute these functions we need to compile the code (see line 1 below). Then we just call the function (with its module namespace) and give it an appropriate argument.

1> c(sicp).
2> sicp:square(5).
3> sicp:sum_of_squares(3,4).

And that’s about all there is to it. Pretty simple stuff. Next up will be section 1.1.6 exercise 1.3.

1 In SICP they’re called procedures; in Ruby, methods; and in Factor, words. I just need to try to keep them all straight.