Category Archives: Software

Haskell: My New Favorite Language

I discovered Haskell not long ago. I even wrote a bit about my initial impressions of it.

This is an amazing language. It’s been a long time since I’ve had this much fun programming. The Haskell community is also great; there are more geniuses there than anywhere I’ve seen before.

If you’re new to Haskell, try reading Haskell: The Craft of Functional Programming, 2nd Ed.. Or, if you want something online, try Yet Another Haskell Tutorial.

Thoughts on Languages

I’ve lately been working with OCaml and Haskell. Both are functional languages, and I’ve enjoyed functional languages for some time. that’s one reason I used Python for so long — while imperitive, it has a number of features commonly found in functional languages, such as anonymous functions and certain types of list manipulations.

OCaml and Haskell are both appealing to me. OCaml can be compiled to byte code, native code, or interpreted. It is a blindingly fast language, often beating C++ for performance, and occasionally even beating straight C code. This is quite a feat for a functional language, and helped get me interested in OCaml to start with.

OCaml has a marvelous type system. It is strongly statically typed, but has type inference and polymorphism. In short, this means that the type system stays out of your way (unlike Java) while still catching type problems in advance (unlike Python or Perl).

OCaml also has an OOP system, which is powerful though a bit odd.

One annoying thing about OCaml is that you have different operators for integers than for floats, and for lists than for strings, and the list operators are more powerful.

Haskell is a lazy, pure language. Its typing system looks very similar to OCaml’s, but it extends it in several significant ways. One way is with the use of typeclasses, a great way around OCaml’s problem with different operators.

Haskell also has a nicer module hierarchy system, and has a stronger standard library in most respects.

Haskell is not as fast as OCaml, especially relating to string manipulation. On the other hand, it’s no slower than Python, and has some powerful ways to exploit its lazy lists. (Haskell lists are the same as OCaml queues, but are also used for strings.)

One thing OCaml has that Haskell seems to lack is camlp4. Haskell has template Haskell, but it doesn’t seem as versatile. Haskell also lacks overt OOP implementations, but the OOHaskell people would want you to believe otherwise. (I’m learning about that now.)

Battle of the VMs

There are a lot of virtual machine interpreters out there. Java was the first well-known one, but VMs are also used for .NET, OCaml, Python, and the new Parrotcode VM will likely be used for Perl 6.

I started a discussion on the OCaml mailing list about some other bytecodes OCaml could target, with very interesting results. OCaml interpreters or compilers already exist for both Java and .NET.

There’s more to this than meets the eye, though. There are many different languages supported by .NET even though the .NET CLR does not lend itself to many of them very well. There are also a number of languages supported by the Java JVM, and Parrot is looking to support a good number, too. So it appears that no VM is going to promise the mythical language convergence .NET was talking about. Rather, we’re going to have too many choices. I wish we could standardize on a single VM and go with that.

Foundations of Python Network Programming

Update 9/23/2004: There is now a page for this book on my homepage, Complete.Org.

My latest book, Foundations of Python Network Programming, is now available for purchase (Amazon, bn, AllDirect, buy.com). This book is designed to show you everything from fundamentals of networking and low-level protocol design to work with higher-level protocols such as IMAP, HTTP, and FTP. For more information, please see the letter to the reader from the book’s back cover.

This is not a basic reference like Python comes with. Rather, it’s a hands-on guide. There are over 6600 lines of example code and the text strives to show you the big picture. For instance, there are several different ways of getting directory information from an FTP server, and some are not documented for use this way. The chapter on FTP explains them and provides example code to illustrate. There’s also an Apress page with details.

Below is the book’s Table of Contents along with a partial list of the examples you’ll find in each chapter:
Continue reading Foundations of Python Network Programming