I’m emotionally reversed

Julie Lerman parsed from an email of mine that I :

  • am “kinda nervous” about Tina’s first mammogram since her mastectomy,
  • was “scared” by the 12′ tiger shark I saw while diving the other day, and
  • am “terrified” of installing a new hard drive

Apparently, I’ve got an inverter on my nervousness circuits.

(Incidentally, Tina just told me she got a clean bill of health on the mammogram.)

New F# Compiler Released; Thoughts on "Practical OCaml" by Joshua Smith

Microsoft has posted version (whatever the heck that means) of their F# compiler, which gives me an excuse to discuss the book Practical OCaml by Joshua Smith.

Practical OCaml is a new release from APress. My favorite technical book of last year was Practical Common Lisp, by Peter Seibel, and I hoped that Smith could duplicate the feat. It looks like the book has a different editorial team, but follows some similar structural advice. Even if nothing else, both books are reasonably sized (~400 pages, not ~1,000) and divided in a manner that makes them very appealing for those interested in learning a programming language.

My main motivation for reading this book (other than the hope that APress had discovered a way to bottle the lightning of language evangelism) was that “pure” functional languages are inherently parallelizable. That is to say, the language semantics are such that a sufficiently smart compiler could correctly take care of threading the computation over multiple cores/processors. Since I am of the belief that the manycore era is going to require a sea-change in programming approaches, I think it behooves those interested in the future to gain experience with such languages. Concurrency is treated only tangentially in Practical OCaml and I am under the distinct impression that OCaml is not inherently parallelizable (I believe this to be the case with F# as well). Nonetheless, it’s certainly true that concurrency is “easier to think about” when using functional approaches, so there’re still things to be gained.

What I didn’t realize was that OCaml is a very, very good language for writing domain-specific languages. It’s pattern-matching semantics are quite advanced and lex/YACC libraries (ocamllex and ocamlyacc) are part of the standard distribution. While I feel that tools like ANTLR and concepts like Parsing Expression Grammars have the potential to displace lex/YACC, there’s no questionthat lex/YACC is the dominant “species” in the world of compilers.

Having said all that, I’m afraid that Smith’s book is not nearly as persuasive as Seibel’s. I abandoned LISP long ago and Seibel made me reconsider that decision. I wanted to learn OCaml but could hardly sustain my enthusiasm through the first chapter. The first sentence of Practical Common Lisp is “If you think the greatest pleasure in programming comes from getting a lot done with code that simply and clearly expresses your intention, then programming in Common Lisp is likely to be about the most fun you can have with a computer.” That’s a good opening and I think accurately captures the undeniable aesthetic appeal of LISP. The first sentence in Smith’s “Why OCaml?” introduction is “It’s a fair question.” That’s a bad opening. At least, it’s a bad opening when followed by five paragraphs whose greatest substantive claim is “OCaml helps the programmer to easily express normal concepts and actually express difficult concepts.” If that doesn’t take the wind out of your sails, rest assured that it is preceded by “Returning to the title question, if I were to answer the question in more mundane terms, I would say that….” That’s the type of opening that calls into question the author’s precision.

The tutorial that follows is structured well-enough, but the concepts are not presented as well as they could be. Here is the complete discussion of the I-would-think-important concept of mutable variables:

It can be tempting to use mutable references, but I suggest that you resist that temptation. I have generally found that, except in a few cases, the use of a mutable reference could be removed by fixing my designs.

This is not a rule in any sense of the term because sometimes a mutable reference is really the best choice. File input/output (I/O) is a good example because file I/O is often a nonfunctional chore. Some other functional languages deal with these nonfunctional chores by using monadic computation, but that might not always be necessary.

You can hide mutable references in OCaml classes to make their use less problematic (this is discussed in more detail in Chapter 19).

This is on page 23 and is not preceded by a discussion of why mutable references are undesirable or what monadic computation is…I can’t resist: the index has only 1 reference for “monadic computation” and that leads to page 251’s explanation that:

Monadic computations and monads in general are creations that open up a small loophole for purely functional languages. Although a purely functional language cannot have functions with side effects, it can have values that describe and contain side effects. This boils down to computational sleight-of-hand that comes with a cool-sounding name.

Oh. Alright then. I started the book under the impression that issues of mutability might be fairly important to understanding a functional language, but apparently they aren’t.

APress is 1-for-2 with their Practical… series, I hope Practical Haskell comes up to bat next.

In the meantime, if you want a really good book I suggest: Practical Common Lisp.

Modified Snapshot Pattern

Here’s a good pattern to use when you have a domain object that combines non-varying and time-varying data. Perrin’s modified the original pattern to use generics: a good choice. (Why is it a good choice? Because objects that combine these two types of data are usually conceived of in a direct-but-composed way: we don’t think of a Product as changing it’s identity because it is or is not on sale, but we do think of a Product and its normal- or sales-price as a combination of two things. While it’s easily possible to express this type of structure using inheritance, making them parameters to a generic is a batter match with the conceptual model.)

Here’s a challenge (for explicitly typed languages: for those with duck-typing it’s trivial):

Design a Snapshot<T> such that you can query any property P in T for a given time. For instance, if you had Snapshot<PlayStation3> myPlayStation, you could query it’s price using code similar to this form:

Price p = myPlayStation.ValueAt(myDateTime).Price()

Hint: Would the problem be easier (or possible) if you were to use a CTP?

CodeGear and The Blogosphere

A few days ago was launched the biggest, most experienced, development tools company to be created since the dot-com era. A company that’s explicitly turning away from managerial buzzwords in order to concentrate on language implementations, libraries, and tool-chains that will cross platforms. The company includes people who developed some of the world’s fastest-working compilers, most famously productive environments, and pretty much invented the models for software components that dominate software development today. The way in which the company was launched is controversial, with a very public reversal of a very public plan. To me, it seems like a big deal

How did Slashdot, Techmeme, Lambda the Ultimate, and the blogosphere in general react to this launch?

Almost complete silence.

I don’t get it; I really don’t.

It’s not like I’m the world’s biggest fan of Delphi and I don’t get why the world doesn’t share my enthusiasm. What I don’t get is why there’s so much more blogospheric coverage of Sun’s choice of license for open sourcing Java compared to CodeGear. Heck, there’s more blogospheric coverage of the latest mapping “mashup” than there is of CodeGear.

CodeGear seems like a big deal to me. Yeah, Borland’s languages division has been neglected and lost status. Yeah, Borland’s decision not to sell raises huge questions about commitment and investment, but I don’t think the meaning of it all is so obvious that it doesn’t bear comment and discussion.

Perhaps I’m just of a certain age and am assigning to CodeGear a weight they no longer deserve; perhaps the blogosphere’s collective “meh” is an indication that people have no more faith in the former Borland division than they would in any other startup.

Time will tell. I expect fireworks from Scotts Valley — for better or worse.

Me vs. $540M Government S/W Project

There was a short piece on the news last night about a $540M travel reservation system developed to aid the Department of Defense manage their travel costs (in peacetime). Apparently, it doesn’t work (doesn’t deliver low fares) and even if it did work, it would take 20 years of projected savings to pay for itself. A congressman is trying to kill the project, and Northrup Grummin trotted out a project manager to say “This is a project that works and of which the American taxpayer can be proud,” while smiling incessantly.

Government software overruns are always scandalous. Back of the envelope: $540M / $250 / person/hour / 40 person-hours/work-week / 50 work-weeks per year = 1080 person-years of effort @ $250 an hour. The contract was granted 8 years ago, projected to go into service 4 years ago, and is “approaching full deployment.”

“DTS has processed more than 1.87 million vouchers since its inception, according to DOD.” That’s not far from the number of travel vouchers that have been processed by reservation systems that I’ve architected. At the risk of putting myself out of work, I’ve gotta’ tell you: travel reservation systems ain’t rocket science. It’s big databases, ugly data formats, and business rules. Business rules, of course, are expensive to get right and prone to change. Duh. But not person-millennia at $250 an hour. Nope. Uh uh. I know whereof I speak.

At what point does inefficiency shade into outright fraud?

Hey, isn’t there some kind of Federal “whistleblower / watchdog” reward? Like, if I investigated this and gave the government cause to withhold, say, $100M in payments, I would get a reward of, say, a couple million bucks?

Euphemism: &quot;in a stop sell mode&quot;

A client relying on a 3rd party service which we had been assured was available received an email today that said “[The service] is in a stop sell mode at this time as we are evaluating etc.”

I’m going to have to remember that the next time I approach a deadline: “I’m sorry, Dave, but that column is in a stop sell mode as I am evaluating content choices.”

No New Features

TeX and METAFONT have version numbers that asymptotically approach ? and e. This reflects Don Knuth‘s decision that it’s more important to create consistency with those tools than to add features. I’ve thought about something similar with programming language design: languages like Java and C# were very “teachable” in their initial releases. The addition of generics, if nothing else, makes them significantly harder to teach. Add closures, LINQ, type inference, etc. and you’re talking about something that, while not C++, has very different “teachability” characteristics, if nothing else. Plus, there’s the burden of supporting old decisions — like the confusing way that C# deals with finalizing resources (using, IDisposable, ~Class()).

Niklaus Wirth may have been on to something producing a family of languages (Pascal, Modula, Modula-2, Oberon) each of which incorporated his experiences and current thoughts, but which were clearly distinct efforts. I suppose that programming languages have become the brands, so we have Perl 6 and C# 3.0, rather than “the latest effort” from Larry Wall or Anders Hejlsberg. I can understand why dissociating a person’s name from a brand is good for the company, but I don’t know that it’s the best way to serve the industry. Maybe it could be like movies “From the people who brought you…”