Functional programming often gets criticized as being slow, so I wanted to present an example where it is in fact several times faster than the equivalent imperative code1.
In this tutorial, we reimplement several of
wc's features in ATS. The core logic (as we shall see)
is relatively simple, and we end up with something that's competitive with
C with relatively little effort.
I figured I'd post this as ATS is quite difficult. Nothing contained in this file is advisable, but by the time you can figure out what's wrong, you won't need it!
Like my last post on ATS , this is far from a full-fledged tutorial, but I think it will nonetheless be instructive to students of ATS.
ATS is an obscure language, and perhaps justifiably so. It was exactly as I was warned (insane, idiosyncratic syntax; key features barely documented; no tutorials), but it was also beautiful, moving, and surprisingly practical.prev