3 ms·
I have not worked with Java much. I have, however, worked with Pascal, C, Objective-C, Perl, PHP, and Ruby. When the Google Android SDK came out, I downloaded E
by qaexl 19y ago
I have not worked with Java much. I have, however, worked with Pascal, C, Objective-C, Perl, PHP, and Ruby. When the Google Android SDK came out, I downloaded Eclipse and its plugin and worked through the tutorials. Having been working with Ruby on Rails for nearly the past two years, it was a shocker at the amount of crap and copy-and-paste I had to do to get it working.
And that's with the tutorial crowing about how the SDK has tools to help you save time.
For example, in the SDK, you define resources in an XML file. The IDE/Android plugin will automatically build a Java file for you out of the XML file. This lets you reference the the code in there. And sure, the shift-ctrl-O to organize the library import is nice ... it is just that I never had to do that with Rails. And adding event callbacks via anonymous classes? It is incredibly awkward.
In my brief excursion into Java, I think the zinger, "Typically, when attacking Java (the most common sport in the software world today) people will pretend it has disabilities it doesn't have." is grossly misinformed. The examples of System.out.println("output here"); or the for loop example is trivial compared to the power of Ruby's eigenclasses and runtime code rewriting capabilities. While working my way through that tutorial, I kept thinking to myself, "I really should not have to deal with this crap."
When I was a teenager, I spent too much time coding with LPC, using the MudOS platform. This was before the Ultima Online dev team started soliciting ideas from rec.games.muds. LPC uses a C-like language, had dynamic array and hash syntaxes ported from Perl 3. You could use anonymous functions (though you could not serialize it), and reflection is built into the language. The pseudo-natural-language parser in MudOS was built to take advantage of the LPC's reflection capabilities.
Being older now, I went back through some of the LPC libraries on a whim. I remembered those good old days with a sort of fuzzy, nostalgic glow. At least until I looked at the code. Looking at it now, I know with something as capable as Ruby, the code would not have had to twist itself in such awkward ways, lots of copy-and-pasting. (And just so you know, copy-and-paste on MudOS systems meant using the built in command-line 'ed' editor).
"By contrast, I have dealt with Javascript codebases that were a nightmare to work with simply because the previous guy thought it useful to graft functions onto objects (or is it "prototypes") at runtime. Nice feature, if you're not inheriting it..."
This actually tells me quite a bit why you like Java instead of Javascript. I didn't really feel Javascript was a compelling language until I saw the prototyping feature. The point is not to inherit it so much as to mixin code. It is a very different way of thinking. To me, overly-designed class heirarchies are as ugly and awkward to me as the prototype/code mixin is to you.
In the example of writing that game, having code mixin gives you an incredible advantage. You can create game objects by mixing in different game properties. is_immune_to_poison. is_resistant_to_fire. reflects_magic :only => :fire. You don't need to set a bitfield or try to do multi-inheritance. And you would be able to define game content using the prototyping language (Javascript, Ruby, whatever) rather than writing a (breakable) parser to load up the game object definitions.
- mynameishere 19y agois_immune_to_poison. is_resistant_to_fire. reflects_magic :only => :fire. I find that a touch inscrutable, but to make an object have various behaviors certainly doesn't require subclassing. obj.addProperty(new PoisonImmunity()); obj.addProperty(new FireResistence()); obj.addProperty(new ReflectsMagic()); or, in one line: obj.addProperties(new PoisonImmunity(), new FireResistence(), new ReflectsMagic()); or, super-fast mode: obj.addPropertyFlags(POISON_IMMUNITY | FIRE_RESISTENCE | REFLECTS_MAGIC); or, pulling from some configuration file: obj.addProperties("poison_immunity", "fire_resistence", "reflects_magic")); ...maybe you're doing something I don't grasp, but it seems like another case of pretending that java has a disability that it doesn't.
- qaexl 19y agoNo, I'm talking about something different. I don't know Javascript well enough to toss off something, but the equivalent in Ruby looks like this: class MyBadassSword < GameObject is_immune_to_poison is_fire_resistant reflects_magic end When is_immune_to_poison is called, it reopens MyBadassSword and attaches more code to it. This is not a syntax feature of Ruby so much as using .include to append more code modules or rewrite definitions to it. The Java JVM supports this, but you have to jump through a lot of hoops to do that with Java itself. The POISON_IMMUNITY | FIRE_RESISTENCE | REFLECTS_MAGIC is exactly what I don't want to mess with. I'm not instantiating PoisonImmunity() class. I'm not using bit fields like POISON_IMMUNITY. (I specifically said in my previous post I was not talking about bit fields). I'm not talking about pulling strings from a configuration file.