I have been working on AtomPub and coding a prototype over the past few evenings to get Apache Abdera talking to CouchDB. I know there is an experimental adapter in Abdera for CouchDB, but it does not use CouchDB the way I need to.
I decided to write my own provider, workspace manager, adapter, etc. I have been using couchdb4j, the Java library binding used to talk to CouchDB, and json-lib, a JSON library for Java.
Why, it has been really especially extremely very painful!
HTTP and JSON, REST a bit, and to a lesser degree XML, are supposed to be technologies that make your life easier as a programmer and as a server. But with Java, it’s the other way round. What should be easy, becomes complex. I am very disillusioned about the suitability for the Java language in pretty much any domain related to HTTP.
With Java in HTTP, you have to jump API hurdles, pull hundreds of dependencies, and end up with stack traces deep as a black hole. Yeah, it works, mostly because of the amazing development support and tools for Java, such as Maven and Eclipse. But that alone does not make Java a viable technology for programming HTTP.
Java has it uses, and it is a good programming language. I don’t think I’d ever code C++ again if I could use Java. But that’s more on the number crunching, for the Hadoop of this world.
I’ll stay with my PHP, Ruby and Python while I can. Perhaps it’s also time to learn a functional programming language like Erlang.
What exactly is the problem with Java? Are you referring to some bad library problems?
I think it’s mostly a library issue, due to bad core library design, and partially a language issue itself.
For example, JSON is a first class citizen in the web world. Manipulating JSON in Python, Perl, Ruby and PHP is a pleasure, but not so much in Java.
Likewise for XML manipulation. Having worked on Apache Xalan-J and XSLTC I can tell you that the biggest issue Java has processing XML is a much higher CPU cost due to garbage collection, as the amount of strings that need to be created and released is simply huge.
Likewise for REST support, or simply client/server HTTP libraries. In Java, you need to use Apache Commons libraries to be able to play with verbs, headers, and control exactly the interaction. That’s a JDK library issue by itself, that the designers valued more certain APIs than others. It’s perhaps anecdotal, but support for HTTP is built-in into the core language libraries in PHP and Python.
Last, but not least, web programming design patterns are complex in Java and need to be spelled out, where as in Python design patterns are actually built into the language.
Good points. I agree. I would include nio in the same bucket. NIO is great, but needs some higher-level APIs to make it more productive to write code.
Bruno, if you allow me, I think you are ripe for erlang and the OTP design patterns.
The combination of cheap processes, message passing and pattern matching is wonderful.
What is interesting in this language is that you don’t actually need to abstract and do high level architecture and UML and whatnots.
Want to access an url ? http:request(VERB …)
Want to do it asynchronously ? pass the {sync, false} parameter to the call. The call will return immediatly and the http process will the reply message when it’s arrived. It’s just a matter of pattern matching to handle it.
Process pooling : pg2 module will pool the processes you’ll give it, and it’s distributed.
I could ramble on. (There are a few things that could be better, but that’s not the gist of my comment
). I admit I’ve never had so much fun before while coding ; erlang is instant gratification.
@Eric, lol, most definitely ready. I love learning programming languages, and have started reading the Pragmatic Programmer’s Erlang book. I’ve set Erlang as my “new language to learn” of the year (Scala was my language for 2008). Working with ejabberd and couchdb, that was really the immediate consequence.
I am still unsure at this early stage how far I am comfortable taking the Erlang stack. Mochiweb and Yaws look pretty cool, and I might end up there. Any views on either one?
Mochiweb appears to have a good momentum currently. I don’t know it very well, though webmachine built upon it seems to be very interesting. http://code.google.com/p/webmachine/
Yaws : I did play with it a little. But I use it more for picking the useful web functions (url_encode etc) which are not part of the standard distributions.
Currently I use and develop for the ejabberd webserver. It’s good enough for making REST architectures. (built an atompub server with it).