Archive for 2007

JavaScript Rising

Wednesday, July 11th, 2007

In this post I wondered why no one (that I knew of) had proposed using JavaScript as a server-side language, and developed tools to support it. Well, they say it steam-engines when it comes steam-engine time. A lot of other people had the same idea; and unlike me, some of them did more than just blog about it.

Googler and blogger Steve Yegge (whose keynote at OSCON I am going to miss, dammit) made a splash by porting Rails to JavaScript — specifically, the Rhino JavaScript-on-Java interpreter that is bundled with Java SE 6. He calls it “Rhino on Rails”, the clever bastard.

In an effort to increase developer productivity at Google, Steve tried to convince the company to adopt Rails (and consequently Ruby) as a programming language. When that fell on deaf ears (Google really does not want to increase the number of languages that must be supported by their infrastructure), Steve decided to do what any other frustrated programmer would do: he ported Rails to JavaScript. Line by line. In 6 months. Working 2000 hours. Steve is a coding stud.

And he is not alone: witness Project Phobos.

Phobos is a lightweight, scripting-friendly, web application environment running on the Java platform.

It comes with a set of plugins for the NetBeans IDE that cover the complete development process. These include a fully-featured debugger; wizards to help you get started faster; a palette of Ajax widgets that can be dropped on a page, thanks to jMaki; and the ability to generate a standard web application for deployment on any servlet container or Java EE application server.

Currently, the primary language supported by Phobos is JavaScript. By leveraging JavaScript on the server, Phobos allows developers to use the same language on the client and server tier of a web application, eliminating the impedance mismatch that characterizes other approaches to Ajax.

Digging farther back in Steve Yegge’s archive, one finds he has been thinking along these lines for some time:

JavaScript is probably the most important language in the world today. Funny, huh? You’d think it would be Java or C++ or something. But I think it just might be JavaScript.

For one thing, despite JavaScript’s inevitable quirks and flaws and warts and hairy boogers and severe body odor, it possesses that magical property that you can get stuff done really fast with it…

See, JavaScript has a captive audience. It’s one of those languages you just have to know, or you get to miss out on Web programming, and in case you hadn’t noticed, thick clients are like Big Hair these days. Most non-technical people I know pretty much live in their browsers, and they only emerge periodically to stare in puzzlement at iTunes or a game or something, and wonder why isn’t it in the browser, because everything else useful seems to be. It’s where the whole world is. To non-technical people, of course. Which is, like, practically everyone.

What other language is supported, in a reasonably cross-platform manner, on the Windows, MacOS X, and Linux native APIs, the Java virtual machine, the .Net virtual machine, the Parrot virtual machine, the Flash runtime, the Silverlight runtime, and 99% of the web browsers in the world? (And, oh yeah, what’s that new thingamajig from Apple? I vaguely remember reading something about it. Can’t seem to recall the name…) In other words, JavaScript not only runs on every platform of interest; it is the only language that runs on every platform. [1]

JavaScript isn’t winning the fight to be the Next Big Language; it’s already won.

[1] Actually, I don’t know if it runs natively on PlayStation3 and XBox 360. But given the little-bitty interpreter and the great big storage media, the games could ship with their own JS runtime and not miss the space.

Transporting a Virus Across State Lines

Tuesday, July 10th, 2007

Flew to Oklahoma City on the morning of the Fourth. Traveling early seems to be the way to go; I made it in time to go see the fireworks, and on the trip back (also in the morning), I had decompression time before going to work… if I had gone to work as planned (more on that below). I dislike both air travel and early rising enough that motivating myself to get out of bed to go to the airport is a bit of a challenge, but I somehow managed it.

My friends and I sat on the Robinson bridge across the Oklahoma River (still seems funny to call it that; it was the North Canadian when I grew up there) and watched fireworks. There was a professional display over the ballpark in Bricktown, but that wasn’t what we were watching; the amateur pyromaniacs were out in force, and they kept some pretty impressive fireworks going more or less constantly for over an hour. Gary remarked that there were small towns around whose professional shows couldn’t match what we were seeing from the folks by the river.

Anyway, I got to visit with my mom and with Paul a bit, got the brakes fixed on my mom’s car, and got her PC beaten back into shape (Windows updates, Firefox update, reinstall the firewall, scour off all the adware, etc.) All in all, a pleasant visit. I also got my mom to try Indian food, and she liked it. (Gopuram on NW 23rd; highly recommended.) Finished it with movie night at Leonard’s, where the theme was Dinosaurs. (There are actually a few good dinosaur movies out there. Those aren’t the ones we watched.)

Just before leaving for Gopuram, I started to feel a bit off in my stomach. (Thus, the restaurant was not to blame for what followed.) I ate too much, of course — it’s a buffet for pity’s sake, and I am but a weak-willed mortal — and left feeling stuffed. The stuffed feeling stayed with me all through Dinopalooza, and left me restless all night. And I started to feel an ache in my lower joints, which is my body’s way of telling my I have the flu.

Still, despite the restless night, I was feeling semi-human in the morning, so I packed up and took the flight home. I got home, plopped my bags in the hall, and after checking in with my mom by phone, laid down to catch up on sleep; I felt like crap, but chalked it up to lack of sleep. But waking up hours later, still feeling like a reanimated corpse, I realized that the damn virus wasn’t done with me yet.

Woke up during the night with chills. Teeth-chattering. Got it together enough to turn the airco off, add an extra layer of shirt, and get back into bed. When the chills eventually passed, and it got close to time to decide whether to call in sick or not, I took my temp: 101.6. Who knows what it had been earlier, when the virus was riding high?

Even without the fever, work would have been a dicey proposition; I was wrung out. I emailed an out-sick notice, and crawled back under the covers, and spent all morning and half the afternoon asleep.

Anyway, I’m better (even if my digestion isn’t quite right yet) (don’t ask), and I did a day at work without incident.

I suppose I should go unpack now. But Livvy-kitty has decided that my bag full of dirty clothes is her new favorite pillow, and I don’t think I’ll take it away from her just yet.

Brendan Explains the Value of Forking

Saturday, June 23rd, 2007

Okay, I have nothing really to add on this, but this blog entry by Brendan Eich, inventor of JavaScript, was simply so brilliant I had to point it out:

Forking is an extreme point in a continuum of options that exist with open source. The option to fork must exist as a feedback mechanism, but it need not be used in order for users to gain benefits not available with closed source and proprietary standards. Forking can be the right thing, or it can be a kind of mutually-assured-destruction option that keeps everyone acting in the interest of not forking.

Forking is not evil. The right to fork is a feature, not a bug. (And this makes Sun’s long-standing resistance to open-sourcing Java — recently overcome, happy happy joy joy — out of “fear of forking” seem especially short-sighted.)

Modularity and OOP

Saturday, June 23rd, 2007

Coding Horror: Your Code: OOP or POO?

From the comments:

generally, people need to use module-oriented programming, but the lack of support by most mainstream language of the day makes them rely on object-oriented programming instead, calling for all possible abusements.

My own career followed an unusual trajectory. Because of where and when I got my Master’s degree, I was exposed to Ada 83; and because of where and when I worked, I had a chance to actually apply it, before I ever did any C++ programming.

Ada 83 was the first standardized version of the Ada programming language, and it was a curious beast. It’s one of the few examples of the transitional phase in software development, after language designers had learned of the value of modularity and information hiding, but before object-oriented programming set the world on fire. (The only other example that comes to mind is Modula-2, another creation of Pascal’s designer, Niklaus Wirth.)

Pascal — the language from which Ada derived its basic syntax — ruthlessly enforced the principles of structured programming, and taught a generation of comp-sci graduates (including me, class of ‘85) the value of those principles. Ada did the same with modularity and information hiding; data and subroutines were grouped into packages, interface modules controlled interaction between packages, and the visibility of package components could be finely controlled. This appealed to me, as it reinforced the ideas I’d picked up from my senior-year courses in software engineering, using the text Structured Design, by Edward Yourdon and Larry Constantine: maximize cohesion (keep closely related things within the same syntactic unit) and minimize coupling (make sure interactions between units are few in number and explicitly defined).

The idea of all this being to make maintenance easier, by allowing program components to be modified in isolation, without breaking other modules that interacted with them. Unless the modifications resulted in changes in the (narrowly and explicitly defined) interface, changes would not propagate to other modules. (Bertrand Meyer’s “design by contract” principle took this idea further still.) That was the theory, anyway; but practice actually approximated theory, if not perfectly. Modularity is one of the few ideas that everyone (now) agrees is a Good Thing.

All the tools to do modular programming are present in C; you can declare your interfaces in .h files, and keep everything else private using the ’static’ keyword. But typical C programmers of that time didn’t know that one should program that way, and the language design didn’t make it the path of least resistance. (Top-level functions have linkage unless you explicitly say otherwise; the compiler doesn’t disallow referencing declarations in .c files or defining declarations in .h files, no support for namespaces, etc.) So it wasn’t typically done that way. But knowing Ada, and knowing the rationale behind it, made me a better C programmer; my programs followed modular conventions, and strictly controlled visibility. (And when C programming is still done these days, that is the typical practice.)

All of these principles got swept up into the meme-complex known as “object oriented programming”; and since the industry transitioned from the kinda-sorta modular C to the object-oriented C++, without a fully modular language in between, people credited OOP with benefits that weren’t really intrinsic to OOP, but were intrinsic to — for want of a better buzzphrase — module-oriented programming.

OOP was oversold. You had to live through it to get an idea of how intense the hype was. The industry was convinced that non-object programming was evil; that hybrid programming, such as was allowed in C++, made baby angels cry. So one of the design criteria for languages like Java was that everything had to be an object, for better or worse. The basic usefulness of hybrid programming eventually led to the development of the Singleton design pattern and EJB session beans, and other semantic dodges that let programmers escape the ideology in order to get their job done.

As you might guess, I am not too impressed by the object-oriented everything ideology. Inheritance and dynamic binding are useful tools, but organizing your whole tool stack and API around them is a mistake. I prefer languages that allow hybrid programming (like Python, JavaScript, Perl, and C++); though I’ll allow there’s something to be said for languages like Ruby, where the object metaphor is so thoroughly baked in that you can choose to ignore it.

This is another reason I’m intrigued by the Scala programming language; while nominally as thoroughly OOP as Java, the Singleton pattern is baked in; you can just declare an Object, using the same syntax as for declaring a class. The distinction between this and a plain old Module is inconsequential.

I’m hopeful. After nearly twenty years, the industry and the profession seem to be recovering from the “object-oriented everything” mania. It’s about time. I wouldn’t want to do without classes and objects; but I’d rather have more than that hammer to work with, so that I can deal with whatever un-nail-like projects come along.

(Other People’s) Thoughts on Concurrency

Friday, June 22nd, 2007

Actors that Unify Threads and Events (Lambda the Ultimate)

Threads Considered Harmful (O’Reilly Radar)

Threads Suck (Brendan Eich)

Conclusion 1: Concurrency is massively important for the future, and threads are a lousy way of addressing it.

Conclusion 2: The Languages of the Future are ECMAScript and Scala, because (among other reasons) their creators are doing concurrency right.

Open Question: What about .NET? Obviously, ECMAScript (JScript) will work there, but will Scala be rehosted to the CLR? Or is there another language that can carry the standard (static typing + type inference + shared-nothing concurrency + closures + functions as first-class objects) on that platform?

XML + ECMAScript: It’s not silly, it’s the Future.

Friday, June 22nd, 2007

Silly season [dive into mark]

Mark’s rant is red and meaty, just the way I like it, but in the end I have to disagree.

The fundamental wisdom at work here is not, “stay away from proprietary platforms”; it’s “don’t marry the platform… any platform”. If you think that open source is insurance against your technology choices going wrong, I have to ask: how many job openings do you see these days for Tcl/Tk hackers? And doesn’t Perl seem to be going down the same path? (And no, I am not a Perl hater; on the contrary, I am a Perl lover who’s feeling kind of unrequited these days…)

I’ve been itching to dig into Flex (darn SCWCD certification still to do first…), and I feel fairly confident that the time will not be wasted. After all, at its base Flex is just ECMAScript and XML. Learning Flex is, in fact, good practice for programming the next generation of browsers: it’s the first available implementation of ECMAScript 4, the standard to which the browsers will eventually hew. And learning a new XML dialect is something that a professional programmer is going to have to do over and over and over in the decade or so to come. So where’s the risk?

That Adobe is going to hose the runtime? Backward compatibility with gazillions of Flash apps is their main selling point; and keeping it free-as-in-beer is how they (okay, Macromedia) established their amazing level of market penetration. Why the hell would they give any of that up? And they are open-sourcing the SDK, so no sale there either. Where’s the downside, honestly?

(Now Silverlight is another matter; Microsoft has neither an installed base to appease nor any commitment to open source anything; the only thing keeping them semi-honest is, well, competition from Adobe. So I’ll be steering clear of that.)

The User Interface of the Future

Friday, June 22nd, 2007

This will be no revelation to some, but it’s becoming increasingly clear how user interfaces will be done in the future. We will specify UI components and layout in a markup language (old flavor: HTML; new flavor: XML), and we will use ECMAscript to add behavior to these components.

How many variations of this are there out there now?

The only (new) system taking a different approach seems to be JavaFX — which is kind of funny, given Java is XML’s home turf, more or less.

I wonder if we’ll see something similar for Mac OS X (beyond the widget API) and Linux — presumably separate versions for GNOME and KDE.

The back-end is still up for grabs, of course; I have yet to hear anyone suggest using ECMAscript for building business logic or web services. To tell the truth, I’m not sure why not; why doesn’t someone take the Tamarin runtime, or Mozilla’s Spidermonkey or Rhino, and build a general-purpose development environment around it? If we’re doing serious work in Ruby and Python, why not JavaScript as well?

Paging Miracle Max

Monday, April 23rd, 2007

Microsoft is Dead, according to Paul Graham.

Microsoft cast a shadow over the software world for almost 20 years starting in the late 80s. I can remember when it was IBM before them. I mostly ignored this shadow. I never used Microsoft software, so it only affected me indirectly — for example, in the spam I got from botnets. And because I wasn’t paying attention, I didn’t notice when the shadow disappeared.

Or maybe not?

Assertion that Microsoft’s ‘dead’ doesn’t compute

Plain and simple, Graham is wrong. There’s no way anyone could argue that Microsoft is dead. Just look at the numbers. When a software runs more than 90% of the desktops on the planet — and will for the foreseeable future — it’s simply not dead.

Oh, well, if USA Today says it ain’t so, they must be right. On the other hand:

Microsoft admits Vista failure

These two actions by Microsoft are proof of what I suggested three years ago. Microsoft has lost its ability to twist arms, and now it is going to die. It can’t compete on level ground, so is left with backpedalling and discounts of almost 100 times.

I bitch about Microsoft as much as anyone, but do I want them “dead”? No, other than in the sense that IBM is now “dead”: still around, still big, still profitable and influential, but no longer the tyrannical force in the industry they once were. Humbled and forced to play nice. In other words, “dead” in exactly the sense Paul Graham intended it.

The USA Today column is especially risible. The writer contorts Graham’s statement into a claim that Microsoft is “no longer innovative”. But if death is the lack of innovation, Microsoft was stillborn. They were never innovative. They were experts at taking ideas other people had come up with, commoditizing them, and driving the original innovators out of business. They were experts at milking every last drop of advantage out of the monopoly position that IBM foolishly handed them. They were conquerors, not builders. And now their conquering days are coming to an end.

Good riddance. And time for the folks in Redmond to start building Microsoft 2.0.

Why Twitter?

Wednesday, March 28th, 2007

The first law of Lazy Punditry is: If you have something to say, and wait long enough, someone else will come along and say it better.

I’ve been finding the Twitter phenomenon truly baffling. Why would I care to post an up-to-the-minute timeline of my life? Why would I care to follow such a timeline of someone else?

Like DrBacchus, I may eventually try out Twitter just to see if I really am missing something; but frankly, it’s not high on my list of things to do.

Programming Languages and Fad-Proofing Yourself

Friday, March 16th, 2007

Antonio Cangiano’s blog post, Haskell Eye for the Ruby Guy, is worth reading on its own merits; and it feeds into a series of blog posts I have brewing, and which will boil over and splatter all over this blog shortly. (Metaphors are meant to be tortured.) But one of the comments, by “Procyon”, particularly caught my eye:

There are only a handful of language that define all the current paradigms. If you know them, then you know ALL computer languages, given a couple hours to pick up their syntax.

Haskell, Scheme, C, Smalltalk (or Eiffel, or Java. OO is so overrepresented you have lots of good choices.), Prolog, Erlang, and Forth. Learn those and you will have fad-proofed yourself. All the fads for at least the next 10-20 years will just be combinations of these basic language paradigms — unless something truly revolutionary happens, but we will recognize that easily if it happens.

That’s it, in a nutshell; that’s what I’m after. I want to find out the deep ideas underlying the craft of programming, and be able to ride the ebb and flow of industry trends with some grace and wisdom.

From Procyon’s list, I still need Haskell, Scheme, Prolog, and Erlang. He also lists Forth, which I’ve never used; but I spent a fair amount of time writing code to generate PostScript, which is an NP-complete stack-based language that is clearly based on Forth. If that line item is meant to represent stack-based programming, I consider it checked off.

I learned OOP by reading the first edition of Bertrand Meyer’s Object Oriented Software Construction. Thus, I learned the principles in a pure implementation of the paradigm (Eiffel), then going on to apply that knowledge in a hybrid implementation (C++, Perl, Python, Java). I’d followed that pattern once before to good effect, learning the principles of modularity and information hiding in a (ruthlessly) pure implementation of it (Ada-83) and going on to apply it in C. Having had some success in this path, it sounds as though Haskell should be my next step: it is the purest available implementation of functional programming.

Of course, I still need to finish my Java certification goals first.