Dear Loyal Java Fan,

20 02 2009

Why is it that, to you, “Object Oriented” is a synonymous colloquial abbreviation for Absolutely everything must be inside of an Object, even if it kills me, so help me God” ?

Callbacks.  Yes, I’m perfectly aware that Java can implement callback routines (via an implementation of a prototype Interface, or Observer, or whathaveyou), but are *YOU* perfectly aware that a simple callback function/method sometimes doesn’t need all the verbose scaffolding that Java makes you jump through?

In fact, the very reason why a “callback function” was designed as it was, had to do with the fact that it was a single “function” (or “method”, if you prefer).  It was not a “callback object”.  There’s a good reason for that.

You’ll probably argue that I’m just accustomed to the C-style callbacks, and that Java’s are just as well.  And yes, this is me insulting Java.  Java is not perfect.  Accept that fact.  Java’s style is cumbersome.

Because Java’s OO framework only really support pointers to objects, you’re actually incapable of passing a function/method reference as a callback function, for the host method to execute arbitrarily.

The task is simple: call a routine, pass a function which defines behaviors.  Frankly, there’s no reason for there to be a whole object enveloping this function.  After all, it’s just a function.  Its only purpose is to define some routine.

It feels like Java is rather OO “trigger happy”.  And because of this, setting up a quick callback method (to pass into another method to execute) becomes a friggin beast of a task.  This guy describes a 3-step process for accomplishing the task.  One part is an interface, another implements that interface and solidly defines some methods, and then there’s the executing class, which takes in an ‘implemented’ interface and can run a particular method from the object created in step 2.

That’s all well can good, but… all I want to do is pass an arbitrary callback to be invoked later on.  I don’t want to create an interface, implement it, and then write an invoker class (which, by the way, only invokes some hard-coded method from the object it is given).  The only way to simplify it is to try to abbreviate with an anonymous inner class on your implemented interface.  Sure, it’s more “inline”, but it’s still way more time consuming than a simple function reference.

Consider this thread, where the thread starter fears the very reality that I am also annoyed with: “don’t know how in Java (other than possibly wrapping up the function in an object ? – good grief please say it isn’t so !

And then the typical Java junkie reply comes in the very next comment: “If you fear objects, you shouldn’t program in Java.” and then later “What, you’re averse to using objects in an object-oriented language?”  Quit being so dense, you idiots.  He doesn’t fear the objects themselves.  Instead, he (and I) fear the fact that every aspect of Java annoyingly forces you to make an object out of something that should be far simpler.

(And then props to the guy who said “you post some example code of how ‘you’ would implement the Observer Pattern in C++.” … psst.. who’s he quoting when he put the single quotes around ‘you’?  You don’t place emphasis with quotes, man.)

The point at hand is that a language can be object oriented without being disgustingly anal about wrapping everything up into class definitions.  It is for this very reason that coding in Java slows you down.  Dear God, just pass a function reference and be done with it.  And it’s more flexible, too.

Don’t complain that passing function references makes the code harder to debug.  I personally find well-documented code to be *far* more valuable than needlessly stupid class objects littering my project.





Finite Dreams 0.1.23

5 08 2008

I’ve recently taken on some 3d programming with a set of libraries called “panda3d“.  They’re quite nice, and I’ve been impressed with it all so far.  The main interfacing language is Python, although many of the libraries themselves are written in C++, for speed’s sake.

Ever since (about) highschool, I had this vision of creating my own RPG.  Originally, my naive idea was to make a sequel to the beloved SNES game Chrono Trigger, but then it hit me one that day that…

A) I’d be an idiot for trying to make a “sequel” to a copyrighted video game produced by a largely successful company based out of Japan

B) I felt silly for trying to be “new” and “on the edge of discovery” while only (at best) attempting to extend the ideas of a genius other than I.

C) You don’t just “make a sequel” to your favorite video game.  That’s childish.

While all of the above sound pretty similar in nature, all three hit me differently, and I ultimately decided to completely redo the “story” that I had invented.  I had been drawing characters for use in the game for a long time, yet I still decided that even those needed a make over.

And over the next 3 years, the idea for Finite Dreams (FD) had been in the making.  (The name is kind of tentative, since I came up with it a while back, and I don’t think that I like it much anymore.)  Games from all over the spectrum (a few of the more relevant examples: Kingdom Hearts, Dark Cloud 2, and Final Fantasy XII) had developed ideas at the same time as myself, and I constantly found myself playing a brand new game that had come up with my ideas before I had.  *grr*

But now, I’m creating “my” game.  I’m not recreating someone else’s ideas, or implamenting them differently, or even doing them “better” than in some other game.  I’m making my own ideas, and it’s coming along nicely…  Unfortunately for me, I had to begin learning Python, but now I love it.  It makes me *hate* Java all the more.  *shudder*  ooooOoooOOOo, Java, how I loathe you.  But the guys at work hear me rant enough about Java, so I shan’t do it here.

I’ll be sure to post some actual content eventually.  For now, I’m getting the engine up and running.  While I’m a one-man team, I do hope to make some good progress, even if it takes me ages.  I’m an artist, muscian, programmer, modeler, and storywriter, all wrapped up into one.  I love every single one of those elements.  I can’t wait to hit every milestone along the way.