robjsoftware.org

A blog about software – researching it, developing it, and contemplating its future.

Archive for the ‘offline apps’ Category

What’s Gilad Up To?

leave a comment »

The legendary “computational theologist” Gilad Bracha is on the verge of another divine revelation.

Gilad, as many know, was for years one of the gurus of the Java language design, delicately dancing on the infinitely thin edge between semantic integrity and linguistic flexibility. Until, that is, he got tired of the need to continually choose between poor alternatives and quit Sun last year. Since then his new blog, the cheerily named Room 101 (one of my must-reads), has been putting forth all kinds of evidence about his new venture.

It’s clear that it’s a startup, and that they’re working on a new language. But what kind of language? And for what purpose?

Start with Gilad’s previously-mentioned-here paper on Objects As Software Services. This paper discusses the possibilities of downloadable software objects — with behavior and state — that can provide offline functionality, transparent synchronization to the server when reconnected, and dynamic upgrade. He goes into some detail on the language properties these objects would benefit from — specifically, reflective tracking of field accesses (via a mirror-based reflective mechanism), and a typing semantics that is flexible enough to allow code upgrade without entering classloader hell.

In more recent posts on Room 101, we’ve seen other pronouncements of what good languages look like. For one, his excellent recent post on why constructors are considered harmful, which is because they are far too tightly coupled to the specific class in which they’re declared. Most of the time you want object creation to be a matter of policy, but constructors are pure mechanism — all you get is the instance of the class you’re specifying, which is totally inadequate in most cases (the majority of cases where you want an object that fulfills some interface, but you want the framework to pick the appropriate class, since it knows more about the classes involved than you do). The canonical solution here is factory methods, but Gilad considers most of the factory method idioms in, e.g., Java to have many of the same problems — you can’t override a static factory class, you can’t extend or replace it. He suggests instead a mechanism for encapsulating object-creation methods within a parameterized class definition, allowing full virtualization of object creation without the overly tight coupling to the class itself. So Gilad’s seeking a language that has the structural purity of Smalltalk, with some of the warts removed.

There’s also his post on why tuples are good, which is relatively straightforward as Gilad’s posts go. Again, tuples give you a single language mechanism that covers a variety of important uses. We’re seeing a real focus here on The Right Thing. It must be a blast for Gilad to be working with a clean sheet of paper after a decade in the immensely constrained Java space.

Finally, there’s his post on why message passing is good. This is not going to be any surprise to anyone who’s enamored of message passing languages, such as Erlang and (at least at the distributed level) E. Pure message passing gives you a degree of isolation and security that more tightly coupled languages can’t match. It also has a very real performance cost — we don’t yet know how to build an optimizer that can make a message-passing loop be as efficient as an inlined C++ function-call loop — but Gilad’s main concerns, as we’ve seen, are linguistic flexibility and expressiveness for use cases including distributed programming and dynamically upgradeable software objects, not achieving the maximum possible performance for typical modern architectures (which has always been one of Bjarne’s key goals).

Also, Gilad recruited Peter Ahé away from Sun, and Peter’s spilling some beans of his own.

So putting all this together, what do we have? Gilad is working on a new language that:

  • is a pure message-passing language (a la Self)
  • refines Smalltalk’s metaclass structure to allow parameterized factories and basic constructors to be implemented as virtualizable instance methods
  • supports a flexible enough typing structure to enable dynamic upgrade of the code of stateful objects
  • has a mirror-based reflective mechanism suitable to allow, among other things, logging of all object field accesses for subsequent orthogonal synchronization
  • has tuples :-)

It’s going to be very interesting to play with this language of his once it’s done. And it even looks like he’s hiring, so things may be pretty close to public visibility! If nothing else, his new venture is going to provide a lot of food for thought. New languages always have a hard time achieving critical mass, but with Gilad’s sense of history and design skills behind it, this new one has a much better than average chance.

Written by robjellinghaus

2007/07/27 at 03:35

Open source update: Maven is not my friend

leave a comment »

Next in the Offline Blogger Editing saga. If anyone mentioned in this post would rather I shut up, please let me know.

Catch-22 with Maven: how can you create a project that has a dependency on another project that hasn’t been stored in some repository somewhere?

I’d love to land my GWT/JSF integration work. But the Ajax4JSF team really likes Maven for some reason. And my code relies on GWT 1.4, which isn’t final yet. So there’s no way for me to check in a Maven build that uses it, because there’s no repository in the world that has it.

Feh. I like what Maven is trying to do, but I would love there to be some middle ground here. Gavin King wants to do lunch next week to talk about the GWT/Seam stuff, though, which is cool.

Meanwhile, Rob Hanson is working on a GWT/Gears ORM implementation, and Ryan Dewsbury (author of the legendary gpokr.com, as well as a book about GWT applications) already has a GWT Blogger client written and working as part of his book. So it looks like gluing those two together would be an offline Blogger client in, like, no time. Ryan’s looking into how soon Addison-Wesley will approve the source for some kind of release, Rob Hanson’s going to have code working by Monday.

Given that the Maven stuff is slowing me down on finalizing the GWT/JSF stuff I did, it may be that Hanson and Dewsbury are going to put this offline Blogger-editor thing to bed before I can get my head out of my butt. Which would be fine — GO GUYS GO! There’s always more code to write, and no sense being selfish :-D

Written by robjellinghaus

2007/06/08 at 06:04

Posted in GWT, Java, offline apps

Pluggable types, objects as services, and Google Gears

leave a comment »

Warning: rambling language research post ahead!

I admit it, I am a static typing weenie. Having gotten hooked on autocompletion, real-time code error highlighting, and advanced refactoring support — IntelliJ is my king — I find that it’s hard to imagine doing without.

But that’s not to say that type systems aren’t sometimes a real pain. Particularly ornery is all the machinery around making changes to the type system. Not all of us can be Scott Blum (GWT compiler ninja), and compiler hacking is not a well-known art. But without access to compiler internals, type-system hacking is very hard to come by.

Gilad Bracha, while he was at Sun, had some interesting things to say about pluggable type systems. Now, that paper is somewhat of a gripe fest, in that while it may be clear what he’s complaining about, it’s not entirely clear what to do about it. What does a pluggable type system actually look like?

I occasionally scour the recent proceedings of the ACM for interesting papers. (Any language lawyer who’s not a member of the ACM’s Digital Library is seriously missing out. Also, I’ve got to catch up on Lambda the Ultimate.) Recently in OOPSLA 2006, Andreae, Noble, Markstrum, and Millstein gave some real body to the theory with their paper on JavaCOP, a framework for building pluggable type systems in Java.

One of their examples is a @NotNull annotation to mark variables that can’t have null assigned. Check out their syntax for verifying that no bad assignments happen:

rule checkNonNull (node <<: sym) { 
where(requiresNonNull(sym)) {
require(definitelyNonNull(node)):
error(node, "Possibly null expression "+ node+" considered @NonNull");
}}

Working through this, this defines a constraint on all symbols that have the requiresNonNull property (which they implement with the @NotNull annotation on the symbol). All such symbols further require that the AST node assigned to them definitely has a non-null value. Their system implements all this as a layered extension to javac, that is able to check eight or so extended type properties in no more than double (at worst) the compile time.

Very interesting stuff, which points (to me, anyway) in the direction of generalizing the research to re-express Java's whole type system in rules like this. In other words, they're starting from Java and layering more type rules on top, but they could also work downwards and re-engineer Java's existing rules in their framework.

What would be the ultimate goal here? Well, giving more flexibility to juggle the nominal versus structural issues that Gilad talks about would be one reason. Another reason would be found in a more recent Gilad paper (apparently presented at Google last fall), about implementing offline objects that provide local support for centralized software services.

Now, if you read this paper after the recent shipment of Google Gears, it has all kinds of interesting ramifications. Gilad proposes a generic synchronization system implemented by reflective logging of local object modifications, supporting reconciliation on the server by change log replay. (This is actually very similar to the Dojo Offline model of synchronization, as presented at GDD07 last week. I wish there were a text post describing the model, because all these video posts and podcasts give me a pain. ) I'm not entirely convinced that model is as generic as he would like, and I will need to bang my head against data-based synchronization some more before I go to operation-based synchronization, but it's nonetheless thought-provoking.

Pluggable type systems come in when he discusses upgrading local code in a modular way. It looks to him like a fully static type system such as Java's has inadequate flexibility for changing shared type definitions at runtime. This is getting into the arena of major magic -- I'm personally very queasy about the whole concept of upgrading code modules that are in mid-execution. I'd prefer to treat that problem via an Erlang-like model of strict isolation through message passing -- the model that the E programming language implements. (And by the way, if you haven't bought into capability security yet, read one of Mark Miller's recent papers already and get with the program!)

At GDD07, I ran into Doug Crockford, who mentioned that he and Mark had discussed taking Google Gears' support for isolated worker threads and using it to implement securely encapsulated downloadable code. That squarely jibes with Gilad's recommendations, and is something that could be prototyped Real Soon Now. Of course, Gilad's whole pluggable-type machinery is definitely not on that agenda, but we must walk before we can run.

So where does this leave us? Seems to me there are several directions to pursue:

  • Gears provides a reasonably deployable framework for experimenting, not only with offline applications in general, but with an encapsulated framework for mobile code, and with the overall synchronization / update model Gilad discusses.
  • Pluggable type systems in general, along the lines of the JavaCOP system, provide a rich variety of new data points on the traditionally impoverished "static versus dynamic" axis in programming language design.
  • The right kind of type system to implement extensible, upgradeable local software objects -- particularly local objects with the ability to have their message formats, persistence structure, and inter-module interfaces -- is a huge open question, and pluggable type systems give us a much more fine-grained and flexible toolset for experimentation.

I find myself wondering what a JavaCOP framework built into the GWT compiler would look like....

(Does anyone have any links to work on JIT compilation for Javascript? If Javascript is moving in the direction of being a generic intermediate language, it'd be good to know how fast it can be made.)

Written by robjellinghaus

2007/06/05 at 06:13

Why Blogger Needs Offline Editing Support, and How To Build It With Google Gears

leave a comment »

I’m writing this in Notepad while riding the BART train on my normal morning commute into San Francisco. This commute takes about forty minutes each way for me. Since there’s no Internet, I can’t connect to work at all. Hence this is dedicated time for reading, or writing, or hacking on things that don’t need a full development environment (my laptop is a bit too old to cope with our entire code base from work anymore).

So of course blogging would be a natural. And sure, writing in Notepad is not torture. But it’s also not the right thing. What I want is to be able to write blog posts, edit them, save drafts, etc., etc., and then the minute I get back online, upload ‘em all to Blogger and worry no more about it.

To do that requires some kind of offline application with local storage. As my last post mentioned, I originally wanted to build such an offline app as a standalone Tomcat-based Seam webapp that would run in a local webserver. But Google Gears offers a much more direct route to the same destination.

So this post is a breakdown of how to construct such a client, based on conversations with various Googlers last week at Google’s Mountain View developer day.

The Requirements

Must-have requirements for an offline Blogger editor:

  • be a web application running in the browser (duh!)
  • support rich text editing at least at the level of Blogger’s own online editor
  • support authentication to Blogger
  • support local storage of some or all of the user’s blog posts
  • support creating, viewing, drafting, and editing of posts whether online or offline
  • allow synchronizing any offline edits to Blogger once back online
  • allow synchronizing of any posts edited on Blogger down to local storage
  • allow very minimal reconciliation of conflicting edits to posts on Blogger
  • require minimal installation of plugins or other application-specific software

Nice-to-have requirements for an offline Blogger editor:

  • support archiving / backing up of a user’s entire blog
  • support re-importing some set of content to a new blog that supports the Blogger API
  • support migrating content between blog services
  • support deleting postings ahd handling synchronization of offline deletes
  • provide a nicer browsing/reading UI (arguably Google Reader has this job sewn up already)

(Needless to say, the nice-to-haves don’t get done until all the must-haves are working!)

Explicit NON-requirements:

  • No need for this application to render any static HTML (the blog can presumably still be viewed and searched through Blogger itself; this app can be *just* an editor)

The API Implementation

Clearly this is exactly the kind of application Google Gears was created to support. So let’s assume we’re using Gears. Further, since I like GWT a whole lot, let’s also assume we’re using GWT.

I originally thought that this app could be built as a GWT/Gears webapp connecting directly to the Blogger API. Dan Morrill of the GWT team set me straight on that. The Blogger API is very pure in its REST-fulness, meaning specifically that it uses all the HTTP verbs. However, XMLHTTPRequest, the entire foundation of AJAX, can’t do anything other than GET and POST. So whatever we do is going to have to involve some kind of servlet bridge to the Blogger API.

(Possible workarounds for this: 1) get the Blogger and GData API teams to make GET/POST-only variants of their PUT/DELETE API methods; 2) get the browser vendors to implement PUT/DELETE support in XMLHTTPRequest. Clearly #1 is a lot more doable than #2 given the dreaded words, “legacy support”. You listening, GData team???)

Once we’ve accepted the need for some kind of bridge servlet, we’d better make sure that bridge servlet is fairly scalable and generic. Whoever is hosting this bridge servlet is going to have potentially a lot of traffic. So the bridge servlet needs to be stateless, re-entrant, and as close to a simple pass-through as possible. It shouldn’t have per-session state; it should be just a message relay.

We’ll also need some GWT modules for communicating with the bridge servlet, including beans that map to the data objects defined in the Blogger API, and service interfaces that map to the Blogger API’s methods. And in fact, this suggests that the servlet itself should simply use the Java implementation of the Blogger client API, exporting a GWT-friendly version of it (via GWT RPC) to the GWT client application.

The persistence implementation

Gears has this lovely local SQL database. But how do we get things in and out of it? We could write to the JDBC-like Gears SQL API. But I have tasted Hibernate. And if I’m programming in GWT, then writing JDBC-like code by hand would be like going back to the pre-Hibernate days. And I can’t do it. I CAN’T DO IT, I TELL YOU! I can’t go back. I WON’T go back!

Now when I first started brainstorming this with Ray from timepedia.org at GDD07, we got wild-eyed and started contemplating porting Hibernate to GWT. Saner heads rapidly prevailed. It turns out that Bob Vawter of the GWT team is doing work on a GWT-generator framework for generating a variety of useful artifacts (starting with Javascript-library method exports) from GWT beans.

So let’s use his framework, only instead of exporting to Javascript libs, we’ll make it generate dead simple CRUD operations for our Blogger beans to the Gears data store.

It looks like some other folks on the Gears list have had similar thoughts. Check out this Gears ORM implementation. But since that’s not based on GWT, it’s not directly applicable. Still cool though! But let’s assume we’ll proceed with Bob’s stuff, just for fun. This is all still early days and all experiments still deserve love.

The todo list

So, what do we have?

  1. GWT beans mapping to Blogger API data objects.
  2. GWT service interface mapping to Blogger API methods.
  3. Bridge servlet implementing GWT service interface and using Blogger Java client API implementation to relay messages to Blogger.
  4. Simple persistence code generator (using a GWT compile-time generator implementation) to take the GWT beans and store them in the Gears local database.
  5. Business logic to implement the client-side synchronization to the Blogger server. (That’ll be another post, or maybe lots of them!)
  6. GWT UI code to let the user use all of this infrastructural goodness to meet the must-have requirements!

If we get it right, it hopefully lands in the Google GWT API project. And once Blogger does this, Calendar is next, and then some.

Sounds like a fun project, huh? Interested? Chime in in the comments. Or join this GWT-Contributors thread on the topic.

Onwards!

Written by robjellinghaus

2007/06/05 at 05:33

Follow

Get every new post delivered to your Inbox.