Entity view (Content)

Comparing Drupal to a Programming Language

By hnagra
Feb. 17, 2014

Although Appnovation started out as a Drupal development shop, we also support many different languages, technologies, and frameworks. The nature of this industry is always in a state of flux and serving the needs of your clients requires the ability to adapt and implement the most appropriate solutions as needed. Keeping on top of the latest technologies allows you to evaluate the best solution to the problem.

There are many technologies available to us and we need to be able to switch to different technologies when appropriate. Although there are many different aspects to programming languages and frameworks, there are commonalities that we can look for and learn in order to master a new technology. Computer programming languages are used to solve problems and provides you with many tools in order to do that.

Here are some basic aspects of computer programming languages and some related functionality in Drupal.

When we program we are usually looking at state and behaviour. State refers to the data (what the information is at a given time) and behaviour refers to the code (what the program does).


One of the basic components of programming languages is the variable. The variable represents state and is used to store data. Data can be stored in memory for short term use or saved to a physical medium for long term storage. We use variables for many things such as temporary placeholders for data used in calculations.

  • In Drupal we store long term data in a database to which we create, read, update, or delete (CRUD) using either core, contributed, or custom modules. Most of the data in Drupal is saved as nodes. Nodes are a basic unit of content in Drupal and comprise of a database table entry that includes an unique id number, a type (classifying the node), and a title. These basic units are saved in one table (the node table) and can be extended with fields; fields are saved in separate tables for each field. This allows us flexibility in creating new types of content but gives us the ability to easily make changes to all content.


Behaviour is the functionality of the code. We use code to carry out instructions in a specified order. Instructions are carried out in a specified sequence, with loops to perform repeating instructions and conditional statements to specify which instructions to execute based on whether a condition is true or false.

  • In Drupal the behaviour is executed by PHP code. The framework is created in PHP and we also use PHP to write modules to customize that behaviour.
  • Core modules are the base modules bundled with the Drupal framework. These modules give us our basic Drupal functionality and allows use to interact with our data. Contributed modules are modules that are shared with the community, and address specific needs not addressed in the core modules. In many cases the core and contributed modules can address the needs of basic web development. For a more customized site we require custom modules that are written to address specific needs.

Conditional Statements

Conditional statements allow you to perform different behaviour based on whether a condition is true or false. This allows the program to react to input and deliver an appropriate response.

  • In the Drupal system the equivalent to conditional statements is the Rules module. The rules module allows you to perform actions based on events. We can do things like send out an automated thank you email when a user has posted 50 messages to a forum, or raise a users permission level when they have been a member of the site for a certain period of time. Rules gives us a lot of power to automate actions based on conditions that we set.

Reusing code

Most languages have libraries that contain prebuilt functions that have been found useful to many users. This allows us to use established code that has been proven in use rather than trying to recreate the code ourselves every time.

  • One of Drupal's greatest strengths is it's community, and Drupal's equivalent to libraries are modules that are uploaded to the drupal.org site and can be downloaded and used by the entire community. While this doesn't always give us exactly what we need, we can always patch the code with our needed functionality and submit it for approval to the community. This way it becomes incorporated into the community module and allows others to access and improve it.


Although the importance of the interface can sometimes be overlooked, it is one of the most important pieces of a program. Without an interface there is no way to input or output data. The most commonly known interface is the Graphical User Interface (GUI). The GUI is a friendly interface for people to interact with machines. There are many other interfaces as well, which is especially important with web technology. We interface with the database, the user, other web sites, and APIs that allow us to harness the power of other systems.

  • Drupal has an excellent user interface that can be easily modified and enhanced. We don't need to code the interface from scratch since Drupal comes with an interface and allows us to use forms to modify them.
  • Drupal also allows us to connect with files containing content information and makes it easy to import and update data using data files such as .csv files. These files can be stored on a server and Drupal will update the content at a scheduled interval.
  • Often we have to communicate with other systems; Drupal has a Services module which allows us to communicate with other systems, and use web services. We can access REST services and make a request to another system and receive XML data in response to our request.

Writing code for Drupal is very exciting because it is such a powerful framework with many aspects to consider. Drupal development ranges from the base level of writing PHP code to create and modify modules, creating the user interface using HTML and CSS, and to the higher level of creating content types and rules. Although Drupal development may seem complicated we can understand it when we look at the different aspects of it and master them individually.



Post Tags: