Wednesday, August 09, 2006


Are Those Comments?

Yesterday my co-worker and I were struggling to get data into and out of our embedded system because of a lack of PC software. We have several Linux boxes but they all have some security software that prevents us from accessing the serial port unless the administrator sets up a configuration file. The Windows boxes come installed with Hyper Terminal which is great for displaying data received from a serial port, but not so good at sending data into a serial port. Our options were:

1. Call the administrator to have him set up a mini-com configuration file
2. Call the administrator to have him install Procomm assuming we have a license.
3. Code it in Eiffel!

I told my co-worker I was going to code it in Eiffel and I'd be back in 10 minutes. 15 minutes later I arrived with a full duplex terminal I developed using secom. The program was fully tested and came equipped with proper error and exception handling. It was fully configurable via command line parameters. And it almost worked the first time (the embedded system wanted CR/LF when I was only sending it LF).

In all fairness most of what I needed (command line parsing and error handling) was already coded in a secom example. I just modified this example to get what I wanted. It's possible I could have modified some C++ program I had that did most of what I needed. But for some reason, more often than not, I just don't get this kind of reuse from my C++ code. Chances are something would have snagged me if I was re-writing a C++ program. And it's not that I haven't tried to write good C++ code, I have! Anyway, the best part of this story is my co-worker's response to seeing the code: "This is Eiffel code? Are those comments?" To which I responded, "No man, that's code." "Woa."

The component model of software is a necessity for the advancement of software development. Without it we are doomed to make the same mistakes over and over. Eiffel supports the component model very well (or at least it lays a rock solid foundation). The advantage of the Eiffel language and style is that they support a truly open approach. Joe Coder can quickly get reuse from Eiffel code because it is designed to be so reusable, to anyone. So keep those reusable components coming!

I love this!!
An alternative scenarion, with some Eiffel programmers I know, might go:

C++: Are those comments?
Eiffel: What are comments?
C++: Thos lines beginning with two dashes.
Eiffel: - Oh. No - that's the Eiffel "Disable instruction" operator.
C++: Oh. Is that anything to do with Design by Contract?
Eiffel: What's Design by Contract?
C++: (puzzled tone) - I thought Eiffel used assertions a lot?
Eiffel: What are assertions?

(posted by Colin Adams)
I love this too!

I recall Bertrand Meyer once saying that when people ask him what the syntax of Eiffel looks like, he shows them a code example. Sometimes people have replied "But there isn't any syntax!" because you just write down exactly what should happen and it happens.

(To anonymous: I thought those two dashes were just consecutive negation operators :-)
I suppose two negatives cancel each other out, so it is a kind of no-op.

But more seriously, we should not talk about Eiffel code.

Machine-code was code, so was Assembler.
C and its descendants have such poor syntax that one can understand people referring to them as code.

But Eiffel is rather legible. It is language - not a code.
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?