Space/Science — HabitableZone

Space/Science » in reply to re: "Write once, run anywhere" -- will never happen, not even with Java

"Write once, cry everywhere"

Oh, I don't want to get into language pissing contests either! I've had more than my fill of that, starting back in the days when the hot topic was which microprocessor, and thus which assembly language, was better. Intel segmented architecture versus Motorola's flat address space--it all seemed so life-or-death back then, meaningless now.

Java has significantly better client side cross-platform performance than just about anything out there. Server side, I've never not been able to write test and deploy on arbitrary platforms.


No, no, no...It's logically just the opposite, simply because there is a much wider array of possible environments on the client side. At one time or another, just about every computer ever built, running every OS ever written, with every bizarre Web browser anybody's tried to make work, running an unknown version of the JRE, will try to connect to your Web site and run your Java applet. Conversely, on the server side, people standardize on server environments, and grow by cloning machines in clusters. You get one configuration tricked out in the lab, and write it up as your spec so it's reproducible.

eBay's server farm has thousands of machines, but almost half are Java application servers, another almost-half is NT file servers, and the rest consist of unique machines performing special functions. Each category of server is formally defined so that provisioning new servers is generally a matter of saying "gimme another X-type server". BTW, the server farm is so big nobody knows what all is in there. Every once and I while I'd get a broadcast email with the name of a server and asking if anybody knows what the heck it does, and if it's OK to decommission it.

I suppose it sshould be noted that a lot of platform -independence breaks come from platforms intentionally breaking JAVA as a move in their business model (Microsoft and Apple come to mind)


And it should be noted, in the interests of fairness, that Sun also is guilty of warping Java to use as a weapon against Microsoft. The dogmatic insistence that Java never be implemented to produce machine-specific binary, despite the obvious performance benefits, is solely intended to undercut Java's usefulness on the Windows platform. Remember the early days, with Netscape and Sun loudly proclaiming that Java-based Web browsers would render traditional OS-based PCs (read "Windows") obsolete? They were hoping that the tail would wag the dog, that Java itself would be so compelling that people would abandon Windows (and coincidentally Mac OS and everything else) to adopt Java platforms just to take advantage of the language. Never happened, of course, and instead of becoming the universal computing platform, Java's been self-relegated to niche applications like JSP servers and Web page applets. There are damn few standalone Java apps available for any platform. How's that Java-based challenge to Microsoft Office ("Star"-something, was it?) doing, eh? Politics has seriously crippled Java.

The main aspect of Java is what it brings to the table in terms of Object Orientation and software design- its perhaps the only modern and widely adopted language that was designed from the ground-up with an eye on Software Architecture issues.


Yesterday's news. Like I said, Microsoft harvested lots of lessons from Java to produce .Net, and it shows. Full credit is due Java: .Net is standing on Java's shoulders, but that's always the case--the wheel turns. Shortly I expect something new to come along to eclipse .Net. It's pointless to feel loyal to whatever's the latest and greatest, because the #1 slot is always up for grabs.

I have no experience with PHP, and little knowledge of it, so I don't have any strong opinion. I'd observe that the script-embedded-in-HTML paradigm's getting a little long in the tooth, and JSP and ASP.Net are demonstrably superior. I think PHP's real strength is that it's open source and there are vast quantities of scripts available for download. Same applies to Perl. Now that language I know, having written a 15,000 line Perl "program" on my first project. The thing is, it's probably the only language I actually despise. It's the only language I was never able to internalize, and had to rely constantly on references; Perl is weird and irrational, compared to all other languages, which I soon learn to speak as merely dialects of the underlying language of computers. But Perl just flat-out makes no sense. I've turned down contracts the instant they said the word "Perl".

And then there's JavaScript. I expected my comments on it to seem like I'm coming from way out in left field. Part of the problem with JavaScript is that it's gotten so little respect that most people have never bothered to dig deeply into it to learn to exploit it effectively. At eBay the JavaScript department was set up just a year ago, and fought an uphill battle to introduce the novel concept that JS can actually be engineered like a "real" language; up to then, JS was just something an HTML designer might use to casually hack out some special effect or for form validation.

It's as if most people have forgotten the concept of client-server computing, and the role that script on a Web page has to play to uphold its end of the bargain. If you need a "fat client" on the Web, you have no choice but to write it in JavaScript. So I've been strongly motivated to push the limits with JS to build sophisticated Web page UIs. My project at eBay was called "LiveAuctions", and it was a genuine thick-client Web app. There was the little Java applet for low-level communications with the server, and everything else, from message handling to UI animation to security was done in JS. About 200K of it, if I recall. Except for the fact that the HTML platform allowed better aesthetics, it's indistinguishable from a standalone app.

And here's an irony for you: The JavaScript part and the HTML (DOM) environment are perfectly cross-platform due to the availabilty of cross-platform Mozilla browsers. As I noted, it was the allegedly universal Java that screwed everything up for me. If I had it to do over, I wouldn't use any Java at all--modern browsers provide a component called HTTPRequest that lets you send and receive XML from a Web page, controlled by script. There are fewer and fewer justifications for Java applets as the browsers get more sophisticated. In essence, JavaScript is capable of supplanting Java for all client-side Web apps.

Applications aside, the depths of JS are truly fascinating. Despite popular misconception, it can be OOP, but with novel features like runtime composition--JS objects are inherently self-modifying. Then there's this thing I call a function generator, which is a construct halfway between a function pointer and an object--it's a function pointer that can, in turn, have member functions and properties, and can be uniquely instantiated with custom values. An example application is event relay handlers, plugged-in to an event source as a function, but internally storing an object pointer so that it can relay an event to the object.

That needs illustration:
function EventRelayGenerator( Obj, Func )
{
return function( Evt )
{ Func.call( Obj, Evt ); }
}

window.onload = EventRelayGenerator( Controller, OnLoadFunction );

The inner function pointer is what's stored in the window.onerror event source. Because of JS scoping rules, the inner function can access the Obj and Func args to the outer function, so that when the inner function is called it forwards the Evt object to the event sink object. Note Func.call--that's a function pointer that has a .call method for applying the function to Obj. Each time EventRelayGenerator is run, it produces a unique, customized, function pointer. Weird, eh? But sooooo useful!

I"m currently working on a project to give JS a packaging facility very much like Java's, complete with dot-delimited namespace and self-registering code packages. A fortuitous side-effect of packaging turns out to be the ability to make data and functions private--I can build a "hardened" Web page that resists attacks that today easily steal cookies, form data, and other sensitive info (the Zone has a tight-assed HTML filter primarily to prevent injection of malicious scripts through message posts that could be used in that kind of attack). Nowhere that I know of has anybody contemplated doing something so sophisticated to humble little JavaScript.

Wow, I warned you if you ask me about JS I'd run off at the mouth. I just realized I'm loading up Space with GeekSpeak stuff. Hope ModBob doesn't slap me upside the head!

Log in or register to post.

The whole thread (45 posts)