Drupal vs Java

Submitted by Jochus on Tue, 08/05/2012 - 20:19 | Posted in: Java

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!

Comments

Submitted by Damien (not verified) on Fri, 01/02/2013 - 09:16
 

So here are what you miss in Drupal:
- Build/release management tool: Check drush make
- Integration with IDE: I'm using Aptana (base on eclipse), full integration with Drupal
- GUI library framework: Have you check YUI or ExtJS ? I'm sure you
- Object oriented programming: Yes, it's a different approach in Drupal. But check Drupal 8 which will integrate some OO components of Symfony framework.
- 3-tier architecture: You should probably rethink how you create your differents modules.
- Amount of stable frameworks: Modules are not framework. Drupal is the framework. And if a module is not stable, nothing is blocking you to digg into it.

I agree, Drupal was created at first as a blogging system. It has been improved a lot and is now a CMS/framework.

If you would like a powerfull PHP framework for Business Application, which will not do any Magic as Drupal does go with Symfony. Full OOP, using namespace, Dependency Injection, etc ...

Happy Coding.
- Damien

Submitted by Jochus on Fri, 01/02/2013 - 09:39
 

Hi Damien,

Thanks for your clear answer. I'm now totally back into the Java world, so I don't know how much progress there is now on Drupal:

(a) Build/release management tool: I have been working with drush make, but it was really difficult to configure it to work with different developers
(b) IDE: thanks, I didn't test that IDE
(c) GUI: I didn't know YUI or ExtJS
(d) OO: an upgrade to Drupal 8 was (in my previous company) not really an option (they are still on D6 and there are a lot of customizations). The person I worked for didn't really see the advantages of OO, so it was rather impossible to integrate OO in Drupal
(e) 3 tier: it has nothing to do with modules or hierarchy of modules. Nobody separates the database calls from the service calls (look at the contrib modules). I'm still convinced you need to separate them :-) ...
(f) Stability of frameworks: when I'm using a framework like Seam (Java) or JSF (Java), everything is working fine. I hate it to spend hours digging into a module, flagging bugs in an issue queue which eventually, will never be solved ...

Anyways, things might be changed now. I'm now away from the Drupal world for almost 10 months. But I must say, I'm happy to be back in the Java world.
Jochen

Add new comment

The content of this field is kept private and will not be shown publicly.

Full HTML

  • Lines and paragraphs break automatically.
  • You can caption images (data-caption="Text"), but also videos, blockquotes, and so on.
  • Web page addresses and email addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <cpp>, <css>, <html5>, <java>, <javascript>, <php>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.