1. Home
  2. Computing & Technology
  3. Java
photo of Paul Leahy
Paul's Java Blog

By Paul Leahy, About.com Guide to Java

Java Term of the Week: Declarative Language

Saturday December 13, 2008

You might have seen that JavaFX script is termed as a declarative language. What does that mean? Well, a declarative language describes what it wants to accomplish rather than focusing on how to achieve its goal. Writing a declarative program is not about specifying a sequence of statements to run one after another to create an application, but to write declarative statements that show a relationship between each other.

For example, if in JavaFX script I wanted to create a simple GUI, all I need to do is describe the elements of the interface with respect to each other. I can use declarative statements to place a couple of buttons and some text inside the contents of a scene. The desired GUI is created because its structure can be interpreted from the order of the buttons within the scene and the values of their variables.

Java on the other hand is an imperative language. To create a similar GUI we would need to use a series of statements that run one after each other (i.e., create a JFrame object, then create and explicitly add the JButtons and JTextField in turn).

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss
Community Forum
Explore Java
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Java

©2009 About.com, a part of The New York Times Company.

All rights reserved.