Well, I had the possibility to "taste" from both worlds. I started at Dolmen (which is now known as RealDolmen). I got a specialized training in all kinds of Java frameworks. After 3.5 years, I was getting really pro in some of the JBoss frameworks (Seam, Hibernate, Richfaces ...). Also, EJB and JSF are frameworks which have almost no secrets left for me.
After RealDolmen, I started at Pigeon Paradise. A company very close to home, which gave me the possibility to have more free time to learn more things on my own. I had the possibility to play with Drupal at PIPA. I was really looking forward to this new technology. After a 1.5 year, I got specialized in Drupal 6. I've created a lot of custom modules, together with 2 other Drupal developers. I do have a lot of experience in working in a team on Drupal projects.
So, as you can read, I had experience with both worlds. I would like to compare the 2 "worlds" in this blogpost.
Drupal
The power of a scripting language
The main advantage I see on Drupal is actually an advantage of PHP. It's a scripting language (Java needs to be compiled to a binary file, afterwards, you can run that binary file in a JVM). When you develop in PHP/Drupal, you don't need to compile your source code. And most of all, it's very, very easy to just do whatever you want to do.
For example:
$content = '';
$result = db_query("SELECT foo FROM bar");
while ($row = db_fetch_object($result)) {
$content .= theme("list-item", $row->foo);
}
return theme("list", $content);
So what you can see here, is a wrap of a database query, some (simple) business logic and a call to a theming function. It's really possible to program amazingly fast. If you made a typo, you fix it, save the source file, push F5 in your browser and tadaaaaa ... the new result.
Design pattern: Model-View-Controller
In my opinion, Drupal has an implementation of the MVC pattern. The hook_menu() is actually the controller and delegating all the requests to the correct page callback. In the page callback, you can perform some business logic and you can ask the theming function to wrap your model in a pretty jacket.
But there are things I'm missing in Drupal, and ... which Java is having.
Java
Build/release management tool
This issue came up because Java has a buildtool like Maven or Ant. Drupal has Drush. Drush is nice, but it needs some "team" features to control Drupal projects. It's not simple to control the lifecycles of custom Drupal modules, or the core of Drupal. I noticed D.O. has some kind of releasemanagement, but I wasn't able to set it up for our company. You cannot easily create branches, tags, trunk, ... You need a whole custom setup to achieve this. I once gave a presentation about this for drupal.be. Please check some files here: http://www.jochus.be/site/files/. It's hard stuff, because the core has his lifecycle, but contrib and custom Drupal modules have them too. You must keep them seperated.
Integration with IDE
Eclipse (or IntelliJ, or whatever Java IDE) and Java just match... They match great. There are so many nice plugin to integrate (such as JBoss Tools for JBoss frameworks), which can make development so easy. It actually makes programming very fun! In Drupal, I was missing some great plugins. I also worked with Eclipse (and PHPDesigner), but the IDE isn't just integrated with your project. If you want to debug your PHP application, it takes a while to set up the server as client side. In Java (well, actually ... Jboss), this debugging is going very easy, especially with Eclipse.
GUI library framework
Well, I have been using Richfaces a lot. I must say: I really miss this framework in Drupal :-( ...
RichFaces is an open source Ajax-enabled component library for JavaServer Faces, hosted by JBoss. It allows easy integration of Ajax capabilities into enterprise application development. RichFaces is more than just a component library for JavaServer Faces. It adds:
- Skinability (easily change and update application look and feel)
- Component Development Kit (CDK) to assist in constructing JavaServer Faces components
- Dynamic Resource Framework
- Both page wide, and component based Ajax control components.
And of the things not mentioned above: the UI components WORK in different browsers. Drupal is still missing this GUI layer to easily create some pages. I'm not interested in writing custom HTML elements, nor in moving an input element 5 pixels to the left in Chrome, but 5 pixels to the right in IE ... No, I just want a < rich:tree > or < rich:datatable >. And this component should work in whatever browser you're trying to open it!
Object oriented programming
Drupal 6 isn't written in OO. I've noticed Drupal 7 got some improvements on this issue, but still ... there's a hugh lack of OO design. I miss this a lot. OO has following advantages according to me:
- simplicity: software objects model real world objects, so the complexity is reduced and the program structure is very clear
- modularity: each object forms a separate entity whose internal workings are decoupled from other parts of the system
- modifiability: it is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods
- extensibility: adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones
- maintainability: objects can be maintained separately, making locating and fixing problems easier
- re-usability: objects can be reused in different programs
3-tier architecture
For me, the greatest "pain-in-the-ass" in Drupal. I do think you need to separate database calls and service calls. In a certain project of my previous company, I noticed the same query turning up 3 times in 3 different files, but they were actually doing the same :-/ ... I do think you should create DAO's. Combine all functions which are related to a specific domain object and group all queries together into one single interface. Next, call the function on this interface from your service layer. And let your service layer call your view layer. The link service/view layer is kind of present in Drupal, but Java just beats Drupal by using JPA (Hibernate) / EJB / Seam / JSF and Richfaces.
Amount of stable frameworks
In Java, I think there are 2 famous frameworks to work with: Spring projects and Seam projects. And that's it. There's a lot of information about these frameworks on the internet. And some really large communities.
In Drupal - you are looking for a specific kind of framework, you can find a lot of "frameworks". They are called contrib modules. For a specific kind of functionality, you can have 4 or 5 contrib modules. But none of them actually does what it has to do. And the most painful thing: some contrib modules are just placed online, but there's no working community behind the product any longer. So if you have some issues/problems/questions, nobody can help you out.
Conclusion
For me, Drupal isn't ready to handle real business applications. It's a good product, but I would only recommend it for really simple projects. To summarize Drupal: get input data from the user, store it in the database and retrieve it afterwards. I sometimes miss the complexity of programming in Drupal. Like BPM, a service bus layer, SOA, ORM, ...
I also think I didn't receive much time/space to discover all those things as a Drupal developer (or to start implement them - if you don't have it, you can try to create it) in my previous company. I cannot blame them: they are not an IT company. Their core business is selling pigeons, not creating a Drupal product and all other kinds of tools to work with it. If I want that, I should start at Acquia :-). I do think Drupal can achieve that level (which is Java having now) after a lot of effort. But it's gonna need time and coordination. And a lot of patience ...
Anyways, after 1.5 year working real hard on Drupal, I had to give up. I was getting too much frustrated in the way of working. It might have been my previous company's way of working, I don't know. But I knew I was missing Java. And after 1.5 years, I switched back to Java. I'm now programming for almost 4 weeks back in Java, and believe me: I HAVE BEEN MISSING THIS A LOT!