Yeesh….

…I’d forgotten what a crawling horror C++ is. It would be really, really nice to create a good, portable version of the Objective-C standard library (the Foundation Kit) that would let this become a language of choice for more than just OS X.

But I suppose nowadays everyone wants to code Java instead. Which, I’ll confess, solves some of the problems of C++, but it seems to leave a lot of the basic nonsense intact. As Hans has pointed out: The beauty of Objective-C comes from the fact that almost no “boilerplate” is necessary. Your code simply does the things it needs to do. C++ and Java both require a great deal of code that’s just doing routine tasks like making sure exception handling is working properly. A great deal of repetition, more opportunity for bugs, and code becomes an illegible mess. Ultimately, both of these languages have the feel of early attempts – a lot of radical new ideas (in each), but they really don’t feel like final, production-quality products. Objective-C does. It’s an amazing difference.

Mrph. OK, end of rant.

Advertisements
Published in: on April 22, 2003 at 15:28  Comments (12)  
Tags:

12 Comments

  1. Java doesn’t approach Objective-C’s level of elegance as a language, but it’s still much better than C++. I also want to put in a good word for Java’s foundation classes. Once you get to Java 1.3 and later, the collection, thread, and similar classes are pretty polished.
    But… BUT…
    Java’s AppKit-level frameworks – AWT and Swing both – are where Java’s own signature crawling horror stuff takes over.

  2. Yes… when I swear about Java, please remember that I tend to forget that people are coming to it from C++. After C++, it’s an amazing improvement, especially in its more recent incarnations.
    But oy. You would think that by now, computer science would be a sufficiently advanced field to have non-crawling-horror languages fielded…

  3. Further things to consider:
    Much of Java’s boilerplate, it’s pedantic attitude towards casts, declarations, and exception-throwing-catching, is because one of its design goals was to create a language that could be used to create *safe* code. Code sufficiently safe that it could be run *unsigned* in a virtual machine in a web browser, in a manner that the user could trust.
    That’s a hell of a design goal, and one that entails making compromises.

  4. Oh, quite. And that’s really a strength of Java. But lately I’ve been seeing it get used for a lot of purposes that have nothing to do with that design goal, more as a language of convenience, and that’s where safety turns into cruft. Java is really a special-purpose programming language, and it makes nasty noises when used for other things.

  5. <rant>
    “java” is too fucking overloaded a term. Are you talking about the “core language”? The “core classes”? Appkit shit? the JVM? And all of those fucking things can change randomly depending on if you’re using 1.1, 1.2, 1.3, 1.4, 4, or whatever the hell they’re numbering them as these days. Of course, there’s no guarantee that some classes won’t become deprecated Real Soon. Grr. Seethe.
    </rant>
    Objective C is so much less crufty as a language on its own, but the NeXtHeAdS have created their own library of horrors (not to mention the UI that’s like swilling a fine carbonated glass of urine.)

  6. Also, don’t underestimate the value of freely available libraries and development tools.
    A co-worker and fellow Objective-C fan was telling me that back when it was new, the makers of Objective-C tried to sell it, while the makers of C++ gave it away. That, as well as an overriding concern for code efficiency, kept Objective-C from gaining much of any market traction.
    Even now, it doesn’t have much presence or mindshare. People that happily slog away at C++ templates will take one look at the bracket-notation of an Objective-C call and say “That syntax looks icky – I’m not touching it with a ten-foot pole.”
    And then comes Java, with its promise of Write Once, Fun Everywhere (deliberate misquotation), and its strictness and noise are so much less obfuscatory than C++ that it’s not even funny. And when you consider how many C++ headaches are completely sidestepped because Java uses GC…
    and voila, lots of people use Java instead of C++.
    Your opinion that Java is a special-purpose language is an interesting point, but I’m going to put a different spin on it – I think Java really is a general-purpose language… but C++ isn’t. C++ isn’t even a language at all. It’s really a kitchen-sink set of language facilites from which you can take hand-chosen subsets and assemble your own tailored, subtletly-ridden programming languages.
    If you took C++, took out templates and multiple inheritance and operator overloading, added an interface mechanism and a garbage collector, and then tweaked the compiler to be a bit stricter, you’ve got Java.

  7. Nice rant.
    And yes, “java” is an ambiguous, overloaded term. But given that this post was from one Cocoa-head to another, that gives the conversation some extra context that de-obfuscates what I was saying.
    By “As a language”, I’m referring to the Obj-C and Java languages, independent of their class libraries.
    By “foundation classes”, I mean those parts of the Java class libraries that directly parallel the facilities of the Cocoa/Foundation framework.
    By “AppKit-level frameworks”, I mean those parts of the Java class libraries that directly parallel the facilities of the Cocoa/AppKit framework.
    What’s ambiguous about any of that?
    Of course, it’s all just a statement of my opinions, without any supporting evidence. Take it with a grain of salt.

  8. Oh, nothing you said was ambiguous.
    It’s saying “java” without explicitly stating the quaternion of versions – since all too often they can all be independently different from each other – that bugs the hell out of me (version compatability aside.)

  9. Well, when I used the term “Java” I was being intentionally open about the version – but my thoughts were primarily about the more recent ones. And I had the same language/foundation-level kit/application-level kit division in mind as Hans; my comments were primarily about the language, although with all of these languages the separation between the language and its foundation kit is a bit blurry at times.
    My main beef with Java is that it doesn’t have any sort of unifying ideology that prevents cruft from accumulating. One nice feature of Objective-C is that basic behaviors for classes, objects and so on are sufficiently well-defined that padding to protect against poorly designed code fragments isn’t really needed, or at least not nearly as much as in other languages. Essentially, many more things can be counted on to behave predictably; I can’t imagine anyone writing a book on “Effective Objective-C programming” that spends most of its time on how to avoid subtle failures of your code.

  10. I think I’ve got to agree with your analysis of C++. Java, I think, could have been a general-purpose programming language, but it was designed originally with a special purpose in mind. It became popular for general uses because it has so many of the features that C++ is noticeably missing, like memory management. It seems like chance that the same language that happened to first fix these problems also happens to have been a special-purpose rather than a general-purpose language.
    What we really need is a language that takes C++, removes templates etc etc like you just said, but doesn’t add in optimization for a particular problem such as safety. I think Objective-C goes a long way towards achieving this – but as you also pointed out, really stupid marketing thwarted that.

  11. In my crotchety old age, the environment of a language means more and more to me. While I think Ruby is an incredibly nifty language, I also think it’s more effort than it’s worth to program in it because the interfacability is nasty (unless you can create a self-contained installation, et al.) Java is even worse, though, because of the active confusion between the language, the environment, and everything in between. Most commercial packages I’ve seen do in fact require their own JRE to run properly. The main problem with C++ is getting the damn code to compile and to have correctly anticipated all the zillions of corner cases that the language allows – but once those are taken care of, it’s usually OK. objective-C seems like the least amount of effort of java/C++/objC.
    Of course, I program most things these days in perl. 🙂

  12. Amen to all of that.

    Of course, I program most things these days in perl. 🙂

    I was wearing a suit to work today, and gods help me, I felt like I should be programming in COBOL…
    (Moral of this story: Suits psychologically good for meetings, interviews and the like. Suits psychologically bad for actually trying to get work done.)


Comments are closed.

%d bloggers like this: