Blog Articles 176–178

Object-Oriented Spaghetti

Note: since writing this essay in 2007, my understanding of object-oriented programming and of separation of concerns has evolved substantially. I think that some of the concerns I raised in this essay are still valid, and that it is quite easy to create unreadable messes of objects, but no longer hold to as strong a version of the final conclusion.

A long time ago ago, Simula was created. From it came Smalltalk, and C++, followed by Java and a host of other languages sporting this new programming paradigm: object-oriented programming. Objects are everywhere — most new/modern languages, at least in the mainstream, are based on them — and are used for everything. In Java, all the core data structures are implemented in an object-oriented fashion.

I’m not convinced that all this is a good thing. In fact, I submit that excessive use of object-oriented principles leads to a new kind of spaghetti code, rendering programs perhaps as unreadable as when implemented with unscrupulous GOTOs. OK, maybe not quite, but it can still be pretty bad.

An important facet of programming and abstraction design is separation of concerns. Separation of concerns is the idea that different concerns or aspects of a program should be kept separate. One example would be separating the type-checking logic of an evaluator from actual evaluation logic. Or separating the business logic from the report generation in a business application.

Java and Pieces

Note: This article was originally a blog post entitled “Java stinks. Really.” I have since come to find Java a very good platform, and the Java language a reasonable and comfortable, if verbose, language to work in, so I no longer have the sentiment that it stinks. That said, the core criticism I make in this article still stands, and makes Java less useful in certain situations, and possibly less desirable for some programmers. The text, however, is unchanged.

I’ve never been a fan of those “Why XYZ is better than ABC language” posts that crop up all over the Internet. Usually, as soon as one is posted, someone else comes along and says that the first poster doesn’t have a clue, and frequently they’re right.

Also, I’ve been apprehensive of peoples’ attempts to compare Java and C++. I’ve said for some time that anyone who says that Java is just like C++ doesn’t know C++ and probably doesn’t know Java, and I’m still sticking by that. They’ve got syntactic similarity (a lot, in fact), but their semantic similarity (which is what I believe is actually relevant in language comparison) is slim. Java is much better compared for similarities with Python or Objective-C, although it is stricter than either of those languages (take my Objective-C statements with a grain of salt; I’ve only dabbled in and read about the language without actually using it for anything).

Lastly, I consider Java to be a decent language from a design perspective. It is extremely clean (to a fault) and has simple semantics (again, to a fault). It takes care of many messy things for the programmer, and has a large and largely-useful library base.

E-mail Signatures (GnuPG/PGP)

In God we trust—all others must submit an X.509 certificate.

 — Charles Forsythe

If you’ve gotten an e-mail from me recently, you’ve likely noticed a strange attachment accompanying it. Perhaps you’ve even reached this page from my signature, wondering what that file is and what you’re supposed to do with it. This page will serve to explain what these files are, and why they’re a good idea.

I cryptographically sign my e-mails (well, most of them anyway). It is a way of providing proof that I am the author of a message, and a way to verify that you have received an authentic message from me. Further, I encourage everyone to sign their e-mails; I will also willingly accept encrypted e-mail. Information on obtaining my keys is provided at the end of this document.