Ciao is a general-purpose
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
which supports
logic
Logic is the study of correct reasoning. It includes both formal and informal logic. Formal logic is the study of deductively valid inferences or logical truths. It examines how conclusions follow from premises based on the structure o ...
,
constraint,
functional,
higher-order, and
object-oriented programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impl ...
styles. Its main
design objectives are high
expressive power,
extensibility
Extensibility is a software engineering and systems design principle that provides for future growth. Extensibility is a measure of the ability to extend a system and the level of effort required to implement the extension. Extensions can be t ...
, safety, reliability, and efficient execution.
Language characteristics
Ciao provides a full
Prolog
Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving, and computational linguistics.
Prolog has its roots in first-order logic, a formal logic. Unlike many other programming language ...
system (supporting
ISO
The International Organization for Standardization (ISO ; ; ) is an independent, non-governmental, international standard development organization composed of representatives from the national standards organizations of member countries.
Me ...
-Prolog),
declarative subsets and extensions of Prolog,
functional programming
In computer science, functional programming is a programming paradigm where programs are constructed by Function application, applying and Function composition (computer science), composing Function (computer science), functions. It is a declarat ...
(including
lazy evaluation
In programming language theory, lazy evaluation, or call-by-need, is an evaluation strategy which delays the evaluation of an Expression (computer science), expression until its value is needed (non-strict evaluation) and which avoids repeated eva ...
), higher-order (with predicate abstractions),
constraint programming
Constraint programming (CP) is a paradigm for solving combinatorial problems that draws on a wide range of techniques from artificial intelligence, computer science, and operations research. In constraint programming, users declaratively state t ...
, and
objects, as well as feature terms
(records), persistence, several control rules (
breadth-first search
Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next dept ...
, iterative deepening, ...),
concurrency (threads/engines), distributed execution (agents), and parallel execution. Libraries also support WWW programming, sockets, external interfaces (
C,
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
,
TclTk,
relational databases
A relational database (RDB) is a database based on the relational model of data, as proposed by E. F. Codd in 1970.
A Relational Database Management System (RDBMS) is a type of database management system that stores data in a structured form ...
, etc.), etc.
Ciao is built on a kernel with an extensible modular design which
allows both restricting and extending the language — it can be seen as a language building language. These restrictions and extensions can be activated separately on each program module so that several extensions can coexist in the same application for different modules.
Developing safe and reliable programs
Programming in the large in Ciao is supported via:
* A robust module/object system. This provides module-based separate/incremental compilation (which is automatic without need for makefiles).
* An integrated assertion language for declaring (optional) program properties (specifications). These include types, modes, determinacy, non-failure, cost (time, memory), etc.
* Automatic inference and static/dynamic checking of such assertions (including unit testing).
Ciao has also support for programming in the small: the compiler is
capable of producing small executables (including only those builtins
used by the program) and the interpreter supports scripting.
The ''environment'' includes a classical top-level and an evolved emacs
interface with an embeddable source-level debugger and a number of
execution visualization tools.
The Ciao preprocessor supports static debugging and verification
assertion checking and optimization via source to source program
transformation. These tasks are performed by Ciaopp, distributed
separately).
Auto-documentation
Ciao includes , an automatic documentation generator. It
processes programs adorned with (Ciao) assertions and machine-readable
comments and generates manuals in many formats including HTML, pdf,
texinfo, info, man, etc., as well as on-line help, ascii README
files, entries for indices of manuals (info, WWW, ...), and maintains
WWW distribution sites.
Portability and efficiency
The Ciao compiler (which can be run outside the top level shell)
generates several forms of architecture-independent and stand-alone
executables, which run with speed, efficiency and executable size
which are very competitive with other high-level languages in general
and in particular with commercial and academic Prolog/CLP
systems. Modules can be compiled into compact bytecode or C source
files, and linked statically, dynamically, or autoloaded.
Example
:- module(qsort, sort/2 []).
% Example: ?- qsort([5,2,3,4,1],X).
qsort(Data, Out) :-
qsort_(Data, Out, []).
qsort_([], R, R).
qsort_([X, L], R, R0) :-
partition(L, X, L1, L2),
qsort_(L2, R1, R0),
qsort_(L1, R, R1.
partition([],_,[],[]).
partition([X, L],Y,[X, L1],L2) :-
X =< Y, !,
partition(L,Y,L1,L2).
partition([X, L],Y,L1,[X, L2]) :-
partition(L,Y,L1,L2).
See also
* Comparison of Prolog implementations
*
Prolog syntax and semantics
Further reading
*
*
*
*
References
External links
*
{{DEFAULTSORT:Ciao (programming language)
Prolog programming language family
Functional languages
Functional logic programming languages
Cross-platform software
Dynamically typed programming languages
Free and open source compilers
Cross-platform free software
Object-oriented programming languages
Scripting languages
Text-oriented programming languages