Klaus Thul

From Objective-C to Java

May 7, 2009 · Leave a Comment

One of my plans for KTdict is to write a “buddy” desktop application. It would have essentially the same functionality, but provide the possibility to synchronize flash-cards and dictionaries between iPhone and desktop.

Question is which programming language and GUI-framework to use. It would be quite easy for me to write this as a Mac/Cocoa-application, but this would leave Linux and Windows users out.

So I ended up reading a book about the Java programming language (so far I seriously used C, C++ and Objective-C) and got a first small program to run, so I can provide my first impressions here.

First thing I noticed it that Java and Objective-C are semantically much more similar then Java and C++ or Objective-C and C++:

  • Inheritance scheme is the same: Objective-C and Java use single inheritance with the addition of protocols / interfaces (C++ has true multiple-inheritance).
  • Both languages have simple types (int, float, …) and objects, they don’t make everything an object.

Main differences between Objective-C and Java are:

  • Java isn’t a superset of C, so features like converting integers to pointers are gone. It isn’t possible to write low-level code in Java.
  • Java has no type “id” like Objective-C and it is not possible (one might argue also not necessary) to do dynamic typing.
  • Java compiles to byte-code for a virtual machine, not binary-code for a hardware processor.

Java is likely the language least prone to programming errors I have ever used. It is very clear, that the designers of the languages rather compromised on power then on safety. Also, I like the idea of having a cross-platform GUI-library (Swing).

But I haven’t decided yet what to do. Currently, Java is the most likely choice, but I am also considering simply writing a Mac-only app in Cocoa (lowest effort for me) or to check other cross-platform frameworks like Qt.

Categories: Software

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment