Declarative - Specifying what not how
Enhanced Definition
In the mainframe context, "declarative" refers to a programming or configuration style where you describe *what* you want to achieve rather than *how* to achieve it. The underlying system or compiler then determines the optimal execution steps based on these specifications. This approach contrasts with imperative programming, which explicitly details the step-by-step control flow.
Key Characteristics
-
- Focus on Desired Outcome: The primary goal is to state the end result or conditions, leaving the procedural implementation to the system.
- Higher Abstraction Level: Often involves domain-specific languages (DSLs) or constructs that abstract away low-level operational details.
- System Optimization: The compiler, interpreter, or runtime environment (e.g., z/OS, DB2 optimizer) can often optimize the execution based on the declarative specification, potentially achieving better performance than manually coded imperative logic.
- Reduced Side Effects: Declarative constructs tend to be more stateless and immutable, leading to fewer unintended side effects and easier reasoning about program behavior.
- Improved Readability and Maintainability: Code or configurations are often easier to read, understand, and maintain because they express intent directly, rather than a sequence of operations.
Use Cases
-
- JCL (Job Control Language): JCL is a prime example of a declarative language. You declare *what* program to run, *what* datasets to use, and *what* resources are needed (e.g.,
DDstatements for data definitions,EXECfor program execution). The z/OS Job Entry Subsystem (JES) then handles *how* to allocate resources, schedule the job, and execute it.
jcl //STEP01 EXEC PGM=MYPROG //SYSOUT DD SYSOUT=* //INPUT DD DSN=MY.INPUT.FILE,DISP=SHR- DB2 SQL: SQL (Structured Query Language) is inherently declarative. You specify *what* data you want (e.g.,
SELECT columns FROM table WHERE condition), and DB2's optimizer determines the most efficient access path to retrieve that data, including index usage, join methods, and scan algorithms.
sql SELECT EMP_ID, EMP_NAME FROM EMP_TABLE WHERE DEPT_ID = 'SALES';- CICS Resource Definitions (RDO): CICS Resource Definition Online (RDO) is used to declaratively define CICS resources like programs, transactions, files, and terminals. You specify the attributes of the resource (e.g., program name, language, residency), and CICS manages its lifecycle and availability within the region.
- COBOL
SELECTandFDStatements: In COBOL, theFILE-CONTROLandDATA DIVISIONsections are largely declarative. YouSELECTa file and assign it to an external name, and define its record structure in anFD(File Description) entry. The COBOL compiler and z/OS I/O routines handle the actual file opening, reading, and writing mechanisms. - IMS DBDs and PSBs: In IMS, Database Descriptors (DBDs) and Program Specification Blocks (PSBs) are declarative. DBDs define the physical structure of an IMS database, and PSBs define a program's logical view of the database (segments it can access, type of access). IMS then handles the complex data access and integrity.
- JCL (Job Control Language): JCL is a prime example of a declarative language. You declare *what* program to run, *what* datasets to use, and *what* resources are needed (e.g.,
- **Relationship to Other Concepts
Related Vendors
ASE
3 products