What REST has to be

7 Comments

I’ve been getting a lot of concern internally at Red Hat as I’ve been pushing for all our products and projects to have a RESTful interface.  Some scorn that there’s no way you can model such complex interactions with PUT, POST, GET, and DELETE.  Many see it as yet another bullshit rehash of distributed protocols.  This is what I promise them:

  • Simplicity
  • Low footprint requirements.
  • True interoperability.  (SOAP interoperability is a joke).
  • Flexibility.

If REST and our RESTful interfaces do not have these properties, then I’ve failed.  I really don’t care in the end if any of the architectural principles of Roy’s thesis are broken as long these requirements are met.  Pragmatism has to be the most important thing here.  We can’t fall into religious and academic debates on the purity of a distributed interface.

Yet another reason to avoid Apache.org

4 Comments

I find  it strange how Apache.org allows for competing projects as they don’t really position themselves as a Sourceforge or Google Code.  I know I’m pretty stupid for creating buzz about a competitor, but IBM and HP have launched a new JAX-RS effort at Apache.org.  The thing is, the Apache CXF project already has a pretty good certified JAX-RS implementation.  If I were Sergey or Dan I’d be pretty pissed.  This just solidifies my opinion that Apache.org is a horrible place to host an open source project or to build start an open source business.

Not only do you have to worry about some Apache bureaucrat pulling rank on you or disallowing you to commit too much work to a project, you also have to worry about sharing your already diluted brand with a  competing project.  With a competing project the “Apache” in front of your project’s name ceases to add any value to the uniqueness of your project.

BTW, I don’t mean to pick on IBM and HP.  I’m just annoyed at Apache.org.  While it may be a great place for big vendors to collaborate at a neutral site, Apache.org is just a horrible place for the little people of the world.

I also shouldn’t pick on Apache.org so much.  They are a good organization with a good message and good ideals.  I just want to encourage future OSS developers to try and go at things on their own.  Learn to promote their project on their own without relying on the Apache brand.  Its better for them in the long run.

Be Liberal with OSS Commit Access

7 Comments

Commit access allows an independent open source contribute access to your project’s source tree.  Over the years I’ve found that it is best to be very liberal when granting commit access to my projects.  If the developers has submitted a patch that has solved a particular problem that even remotely shows they understand how my project is designed, I grant them access.  Think about it.  Somebody that has posted a patch has: learned how to download the source, has learned how to build your project, has stepped through your code to find and understand their bug or new feature, and most importantly has shown a tremendous amount of initiative.  Contributors are usually very honored when they are granted commit access.  It gives them a sense of ownership and pride.  They are usually relatively careful because they are so afraid that their code is out in the wild and can be viewed by anybody.

Sure, you may have a lot of turnover on who commits or not, but you sometimes get somebody that wants to stick around for the long term.  Especially if you start to give them more resposibility on the project and respect their abilities.  Sure, being so liberal often leads to poor commits and you having to rewrite some things.  The real value here is the unit tests and blazing the initial trail if we’re talking about a new feature.  As long as the potential contributor has unit tests that go along with their bug or feature patch, I’m usually more than happy to welcome them to the community.

What are your experiences?

BTW, liberal policy is my own.  Other projects at Red Hat may or may not be as liberal.

Success for Apache or for ASL?

3 Comments

This is an add-on to my previous post…

Now this Spring acquisition is it really a big win for Apache as Matt says?  Or is it really only a (minor) win for the ASL license?  I would say the latter.  When has there been a business success story for any project hosted at Apache.org on the magnitude of the SS, JBoss, or MySql?  I don’t think the Gluecode guys or ServiceMix guys got much money.

This goes to an original point I made some time ago that Apache.org is a horrible place to build a business as Apache owns your brand.  I know that’s how they like it and to each his own.

Your OSS License Is Mostly Irrelevant

2 Comments

I was reading Matt Asay’s blog on how the Apache license has made its first big business win with the Spring/VMWare acquisition.  In my experience, I don’t think the OSS license you choose has much bearing on an open source business model.  Red Hat/RHEL proved you could build a business and launch an IPO off of GPL-based software.  JBoss proved that you could make a lot of money and get acquired for a lot of money off of LGPL-based software.  Now Spring, at least, has shown you can get a healthy acquisition of ASL-based software.  We now have successful businesses that use the wide spectrum of OSS licenses.  GPL->viral, ASL->non-viral, and LGPL->somewhere in between.

I think what this has shown is that brand is the most important factor in creating an open source business.  If you have a strong brand, it really doesn’t matter if somebody tries to steal your secrets or even fork your project.  Case in point is RHEL.  I remember Larry Ellison stating that JBoss and Red Hat weren’t worth the price tag because Oracle could just steal the code.  Well, they tried it with OEL and have yet to dent Red Hat’s growth or revenue.

I do think though that license can only be a factor to protect you becoming an Apache or Eclipse fork.  Both Apache and Eclipse are strong organizations with strong, instant-brand recognition.  If your OSS license is Apache.org or Eclipse.org compatible, there’s nothing stopping a company or individuals from forking your project and setting up shop at one of these organizations.  Sure, it is a lot harder to build a business off of a project that is hosted at Apache.org or Eclipse.org because you’ve given a large portion of your brand to these organizations, but a fork like this can do a lot of damanage to your own brand.

Case in point, remember 2003 when a few JBoss developers split with the old JBoss Group company and tried to first fork JBoss, then finally ended up creating the Geronimo project?  In retrospect, I think Apache’s LGPL aversion saved us from Geronimo being an outright fork of the entire JBoss codebase.  In the end, I think we still would have won out based on both the leadership, company structure, engineering organization, and the brand Marc Fleury built, but I think it would have damaged us a lot more than a few defectors leaving the company.

All and all what OSS license you pick should be a personal choice rather than a business decision.  Since Red Hat and JBoss’s brand is uber-strong nowadays I’ve seriously considered licensing projects like RESTEasy under ASL to be Apache.org friendly.  Still, on a personal level I’ve always preffered LGPL as its a nice middle-ground between GPL and ASL from an idealistic position…

Polyglotism is the worst idea I ever heard

40 Comments

Let me first start off being a little facetious with a little tongue in cheek…I’m an American.  I have no need to speak another language because well, I speak English.  99% of the civilized world speaks English so WTF should I ever learn another language?  Case in point, I minored in German in college.  For two semesters I went over to Munich and worked at Deutsche Aerospace so that I could learn German better.  The thing is, besides the fact that my coworkers spoke damn good English to begin with, all the documentation they put out was in English, the units used were feet, pounds, miles.  When the French came over to work with us, we also spoke English.  So what is the freakin point of learning German?  I was pretty damn disappointed that I wasted all this time in college learning German when in reality it was just a freakin useless exercise…

Which brings me to the point of this blog.  Polyglotism in software has to be the worst idea I ever heard.  The idea of it is that you use the language that is best fits the job.  Some say this is a huge boon for the developer as they will become more productive.  In practice though, I think this is just a big excuse so the developer can learn and play with a new language, or for a language zealot/missionary to figure out a way to weasel in his pet language into a company.  Plus, you’d probably end up being average or good at many languages but a master of none….But lets pretend that it is a benefit to the developer.  Developers need to realize that there are implications to being polyglot.

Maintenance Nightmare

So, you’ve added a Ruby module to that big flagship Java application or product your company is so proud of.  You did it fast.  It works. And management loves you for it.  They love you so much for it, they’ve promoted you to software lead and now you are running a brand new project.  Now that you’ve left your polyglot project, somebody needs to take over your work.  Unfortunately, your group is a bunch of Java developers.  For any bug that needs to be fixed, these developers need to be retrained in Ruby, a new Ruby developer needs to be hired, and/or a Ruby consultant/contractor needs to be brought it.  Multiply this by each language you’ve introduced to your project.

Refactoring Nightmare

The JVM is pretty cool now.  We can run Ruby on it, Python on it, and even PHP on it.  Your JRuby apps can work with Java APIs.  Same with Jython and JPHP.  Great.  So now your developers can use any one of these language to build out extensions to your Java app.  But what happens when you want to refactor one of your re-used Java libraries?  OOPS!!!

Installation Nightmare

Ah, so you’ve weathered through the maintenance and refactoring nightmares and you’ve finally shipped your product.  Hmm, but you’ve just added the complexity of installing multiple runtimes on your user base.  Its not hugely bad if you’ve used the JVM as your base virtual machine.  But you still need to package and install all the appropriate Java libraries, Ruby gems, and Python libraries on the appropriate places of your user’s machine.  You also need to hope that all the desparate environments don’t conflict with anything the user has already installed on his machine.  And that’s just with languages running in the JVM.  Imagine if you used vanilla Ruby, Python and Java all as separate silos!

Support Nightmare

A support call comes in for your product or application.  Its obviously a bug, but where is the problem?  Is it your application code?  Your JVM?  Your Ruby VM?  Your Java library? Your Ruby gem?

All and all, let me put it this way.  We all work in multi-national environments.  What if each developer documented their projects in their own native language, because lets face it, they are most productive in that language.  Where would we be?  Doing what’s best for oneself isn’t always best for the big picture.

JAX-RS Javadoc support

Leave a comment

Stef Epardaud has put together a nice framework that can write Javadocs for you with a JAX-RS spin.  See his project for more details.

To WADL or not to WADL

12 Comments

I edited this to be correct.  I incorrectly assumed that WADL didn’t support HATEOAS.  Apologies Marc Hadley

A friend, colleague, and old mentor of mine, Steve Vinoski (he also introduced me to REST) talks a little bit about his RESTful experiences with his current development team.  It is cool to hear that this stuff is working in action specifically:

For example, I just finished a meeting a couple of hours ago where some client code needs to interact with a particular part of my system via HTTP, but wants XML instead of JSON currently provided.  Simple — it’s just a different representation of the same resources…..[snip] Can you imagine the hoops one would have to jump through with typical RPC-oriented systems [snip]?

He also goes on to talk about how client developers asked for a “REST-like-interface”:

[snip] A document listing all resource URIs, and for each one, the HTTP verbs that apply to it, the representations available from it, and what status codes to expect from invoking operations on it….[snip]for a proper RESTful system, you don’t need a document like that, at least not the type of document they’re asking for.

My guess is that his developers are looking for something a WSDL-like document, or something like WADL. What Steve is getting at is that you don’t need a WADL because HATEOAS allows you to discover how to interact with your services.  In abrowser-based, HTML-based world, this is definately true.  HTML documents are self-describing and renderable by your browser.  Humans can look at a rendered page and now how to interact, serf, and fill and post forms.  Machine-based clients are different though.  They usually exchange more machine-friendly formats like XML and JSON.  They can’t make dynamic decisions and need to know ahead of time what interactions are available and how to perform the interactions.  The de facto way of doing this has been to embed somethign like an Atom link into a document:

<order id="123">
   <amount>$123.45</amount>
   <atom:link rel="CANCEL" href="http://orders.com/orders/123/cancelled"/>
   <atom:link rel="PAYMENT" href="http://orders.com/orders/123/payment" type="application/xml"/>
   ...
</order>

In Atom land, interactions are defined as named, logical, relationships which provide a URI and expected type.  While machine-based clients are not going to be able to make many dynamic decisions on a self-describing document, there are a lot of advantages to HATEOAS that Craig McClanahan talks about.

The thing is, I think Steve’s developers are right.  They need some kind of “RESTful like interface”.  I do agree that you don’t need a document that describes status codes.  The status codes exchanged between a RESTful client and server for a given HTTP operation is well defined by the HTTP specification.  Users should not try to override the meaning of a given status code.  The thing is, even with links, you still need to document which relationships will be available, what they do, and what formats the linked URIs expect.  As a client developer, you need to know this information ahead of time.  For state-changing interactions, you also need to know whether you need to do a PUT or POST.  This is extremely important information because PUT is idempotent and POST is not.  For those URI’s that take query parameters, you will need to define what query parameters there are and what values they expect.  Finally, on error status codes, you will need to know whether or not the server will return a representation that describes the error and what type it will be.

WADL allows you to define all this stuff.  It allows you to define URIs, their media types, what methods they expose, what query parameters,  what, if any representations are returned on failures.  It also allows you to define links and how they relate to other resources.

<resource_type id="vdc">
  <method name="GET">
    <response status="200">
      <representation mediaType="application/vnd.order+xml">
        <parameter name="CANCEL" path="/order/link[@rel='CANCEL']" style="plain">
          <link resource_type="cancel"/>
        </parameter>
        <parameter name="PAYMENT" path="/order/link[@rel='PAYMENT']" style="plain">
          <link resource_type="payment"/>
        </parameter>
      </representation>
    </response>
  </method>
</resource_type>
<resource_type id="cancel">
   <method name="PUT">
      <failure status="400" mediaType="aplication/vnd.error+xml"/>
   </method>
</resource_type>
...

I’ll admit, I am squeamish about WADL.  One of the things I liked about REST is that I wasn’t stuck writing WSDL documents and being dependent on a bloated SOAP stack.  WADL is just as verbose as WSDL.  I like how you can have any link structure you want in your documents and map it using XPath or some JSON equivalent.  Its just so damn verbose!  I still think something like this encourages an RPC-like approach to system design.  So what do we do instead?    Since HATEOAS is so close to the dataformat, awhile back, I talked about using XML schema to define your interface and link relationships.  Subbu also talks about expanding Atom links with a template, which should satisfy the query parameter problem.  I would also suggest adding allow and failure-type attributes to Atom links.  Allow being what HTTP methods are allowed, and failure-type specifying the media type that would be used with any failure responses.  So, here would be an example:

<order id="123">
   <amount>$123.45</amount>
   <atom:link rel="CANCEL" href="http://orders.com/orders/123/cancelled"
                           allow="GET, PUT" failure-type="application/vnd.failures+xml"/>
   <atom:link rel="PAYMENT" href="http://orders.com/orders/123/payment" type="application/xml"
                            allow="GET, PUT" failure-type="text/plain"/>
   ...
</order>

I think this covers the bases.  Thoughts?  Viable?

The Dali Lama is a Pats fan

Leave a comment

Saw this in the Boston Globe today.  The Dali Lama is a pats fan!

patslama

Oracle and Java

5 Comments

Let’s face it.  We all knew Sun would get acquired.  The question was just when and by whom.  Now that its happened, and Oracle is the winner, I must say I like the situation better than if IBM had bought them.  Just from a EE specification perspective, IBM was always a bit reactionary when it came to anything new.  On EE 5, Oracle was a staunch ally in our push to get JPA through and a part of EE 5 (and thus retiring CMP and making JDO obsolete).  On EE 6, we’ve met a bit of resistence from them when it comes to the-spec-formally-known-as-Web-Beans, but they’ve been at least open to the idea.  Who knows how the Oracle business guys will want to deal with Java.  That is the wildcard IMO.  Should be fun… Interesting times.

Older Entries Newer Entries