About the 4D Language
The 4D built-in language, consisting of more than 1300 commands, makes 4D a powerful development tool for web, mobile, or desktop applications. You can use the 4D language for many different tasks—from performing simple calculations to creating complex custom user interfaces. For example, you can:
- Programmatically access any of the record management editors (order by, query, and so on),
- Create and print complex reports and labels with the information from the database,
- Communicate with other devices,
- Send emails,
- Manage documents and web pages,
- Import and export data between 4D applications and other applications,
- Incorporate procedures written in other languages into the 4D programming language.
The flexibility and power of the 4D programming language make it the ideal tool for all levels of users and developers to accomplish a complete range of information management tasks. Novice users can quickly perform calculations. Experienced users without programming experience can customize their applications. Experienced developers can use this powerful programming language to add sophisticated features and capabilities to their applications, including file transfer, communications, monitoring. Developers with programming experience in other languages can add their own commands to the 4D language.
What is a Language?
The 4D language is not very different from the spoken language we use every day. It is a form of communication used to express ideas, inform, and instruct. Like a spoken language, 4D has its own vocabulary, grammar, and syntax; you use it to tell 4D how to manage your application and data.
You do not need to know everything in the language in order to work effectively with 4D. In order to speak, you do not need to know the entire English language; in fact, you can have a small vocabulary and still be quite eloquent. The 4D language is much the same—you only need to know a small part of the language to become productive, and you can learn the rest as the need arises.
Why use a Language?
At first it may seem that there is little need for a programming language in 4D. In the Design environment, 4D provides flexible tools that require no programming to perform a wide variety of data management tasks. Fundamental tasks, such as data entry, queries, sorting, and reporting are handled with ease. In fact, many extra capabilities are available, such as data validation, data entry aids, graphing, and label generation.
Then why do we need a 4D language? Here are some of its uses:
- Automate repetitive tasks: These tasks include data modification, generation of complex reports, and unattended completion of long series of operations.
- Control the user interface: You can manage windows and menus, and control forms and interface objects.
- Perform sophisticated data management: These tasks include transaction processing, complex data validation, multi-user management, sets, and named selection operations.
- Control the computer: You can control serial port communications, document management, and error management.
- Create applications: You can create easy-to-use, customized applications that run stand-alone.
- Add functionality to the built-in 4D Web server: build and update dynamic web pages filled with your data.
The language lets you take complete control over the design and operation of your application. 4D provides powerful “generic” editors, but the language lets you customize your application to whatever degree you require.
Taking Control of Your Data
The 4D language lets you take complete control of your data in a powerful and elegant manner. The language is easy enough for a beginner, and sophisticated enough for an experienced application developer. It provides smooth transitions from built-in database functions to a completely customized application.
The commands in the 4D language provide access to the standard record management editors. For example, when you use the
QUERY command, you are presented with the Query Editor (which can be accessed in the Design mode using the Query command in the Records menu. You can tell the command to search for explicitly described data. For example,
QUERY([People];[People]Last Name="Smith") will find all the people named Smith in your database.
The 4D language is very powerful—one command often replaces hundreds or even thousands of lines of code written in traditional computer languages. Surprisingly enough, with this power comes simplicity—commands have plain English names. For example, to perform a query, you use the
QUERY command; to add a new record, you use the
ADD RECORD command.
The language is designed for you to easily accomplish almost any task. Adding a record, sorting records, searching for data, and similar operations are specified with simple and direct commands. But the language can also control the serial ports, read disk documents, control sophisticated transaction processing, and much more.
The 4D language accomplishes even the most sophisticated tasks with relative simplicity. Performing these tasks without using the language would be unimaginable for many. Even with the language’s powerful commands, some tasks can be complex and difficult. A tool by itself does not make a task possible; the task itself may be challenging and the tool can only ease the process. For example, a word processor makes writing a book faster and easier, but it will not write the book for you. Using the 4D language will make the process of managing your data easier and will allow you to approach complicated tasks with confidence.
Is it a “Traditional” Computer Language?
If you are familiar with traditional computer languages, this section may be of interest. If not, you may want to skip it.
The 4D language is not a traditional computer language. It is one of the most innovative and flexible languages available on a computer today. It is designed to work the way you do, and not the other way around.
To use traditional languages, you must do extensive planning. In fact, planning is one of the major steps in development. 4D allows you to start using the language at any time and in any part of your project. You may start by adding a method to a form, then later add a few more methods. As your application becomes more sophisticated, you might add a project method controlled by a menu. You can use as little or as much of the language as you want. It is not “all or nothing,” as is the case with many other databases.
Traditional languages force you to define and pre-declare interface objects in formal syntactic terms. In 4D, you simply create an object, such as a button, and use it. 4D automatically manages the object for you. For example, to use a button, you draw it on a form and name it. When the user clicks the button, the language automatically notifies your methods.
Traditional languages are often rigid and inflexible, requiring commands to be entered in a very formal and restrictive style. The 4D language breaks with tradition, and the benefits are yours.