Introduction to MANOOL
MANOOL is a homoiconic, dynamic, and multi-paradigm general-purpose computer programming language with a functional core. The author's implementation of MANOOL is made for native-code run-time environments, is written in idiomatic C++11 (with GCC-specific extensions), and currently runs under several Unix-like operating systems (OSes) on a number of CPU instruction-set architectures (ISAs). The implementation is a free and open-source (FOSS) software development tool published under the version 3 of the GNU General Public License (GPLv3).
Purpose
MANOOL is characterized as a general-purpose language because it is not specific to a particular problem domain, and it is instead broadly applicable across several problem domains. However, it is meant to compare and compete directly with such programming languages as Python, PHP, Ruby, Perl, and Tcl (i.e., so-called scripting languages), or even Scheme and Common Lisp, which somehow dooms its purpose.
In overall, MANOOL is a practical language: it is conceived as a tool useful in the professional field of programming rather than as a proof of concept for any new programming techniques or mechanisms, although incidentally its syntax and semantics do have a combination of unusual features.
Motivation
The project MANOOL emerged out of mere programming language enthusiasm and frustration with existing languages but is based on ideas and experience its author acquired throughout more than 25 years. Its design and implementation is the result of about 3.5 years of almost full-time work.
Examples
The following “Hello, world!” program provides a basic idea of what programs in MANOOL may look like:
{{extern "manool.org.18/std/0.6/all"} in WriteLine[Out; "Hello, world!"]}
And the following MANOOL expression evaluates to a (recursive) MANOOL procedure (a function in more conventional terminology) used to calculate the factorial of an integral argument:
{ let rec
{ Fact =
{ proc { N } as
: if N == 0 then 1 else
N * Fact[N - 1]
}
}
in
Fact
}
It is worth to observe that while source code in MANOOL may look at first sight unfamiliar or even awkward, there are really good reasons behind it since the syntax of MANOOL is a result of many design trade-offs. However, as in the case of Smalltalk, the syntax of MANOOL is actually so simple that it could be “described on a postcard”.
Goals
MANOOL has explicitly stated design goals (ordered according to priority), which are
- implementation simplicity (which is the sole most important consideration in the design);
- expressive power (in practical sense), usability, and general utility (value for consumers); attention to syntax and semantics details;
- correctness, security, and overall quality of implementation; run-time reliability;
- run-time performance and scalability; and
- consistency, completeness, orthogonality of features and language elegance; conceptual economy and purity.
The project MANOOL strives to satisfy all of the above goals (in that order) and do it better than existing alternatives would do!
Note that quality of diagnostics and coding defect prevention have been deliberately left, however, among low-priority goals.
Results
Implementation simplicity
The MANOOL translator fits in less than 10K lines of code (KLOC) in C++11 plus less than 500 LOC in MANOOL, which covers the core language as well as the standard library.
Expressive power
MANOOL is directly suitable for accurately expressing algorithms (up to asymptotic computational complexity) as complex as those that one might find in computer-science (CS) papers where mostly some form of high-level pseudocode is encountered.
Run-time performance
According to simple synthetic benchmarks, the MANOOL implementation executes programs notably faster than some competitors and slightly faster or on a par with other competitors.
Run-time reliability
When needed, MANOOL programs can be instructed to recover even from dynamic memory (heap and stack) exhaustion.
Other features
- Very compact (or even minimalist) core language (up to a point where a meta-circular specification might be appropriate)
- Convenient standard library (but completely optional to use)
- Computational primitives based on Church's λ-calculus (in the spirit of Landin's ISWIM prototype language/ML-like languages)
- Name bindings with static (lexical) scope
- Explicit variable capture and classification of name bindings into compile- and run-time
- Mainly eager (strict) evaluation strategy (from the perspective of λ-calculus) with possible side effects
- Compile-time evaluation
- Metaprogramming:
- Lisp-like syntactic macros with optional macro hygiene
- (optionally) self-modifying code
- Block-structured and expression-oriented (from the perspective of procedural imperative programming)
- Dynamic (latent) but strong data typing discipline
- Ad-hoc polymorphism:
- run-time function/operator overload resolution (via dynamic single-dispatch)
- Observably (modulo timings) non-referential (by-value) data model encouraging (but not requiring) to use (observably) immutable objects using automatic reference counting (ARC) and transparent copy-on-write (COW) implementation techniques
- Move semantics and syntactic sugar that emulates in-place partial updates
- Very high-level composite abstract data types (ADTs):
- set-theoretic operations, comprehensions, and logic quantifications inspired by the math notation and SETL
- values of any types (as long as the former are totally ordered) can be used as set elements and map keys
- iterators with elements of lazy evaluation strategy
- Modular programming:
- namespaces
- name binding visibility control
- multiple source files (plus support for Ada-like private program units)
- User-defined abstract data types:
- data encapsulation (with visibility control)
- Exception handling (with stack unwinding)
- Decimal floating-point arithmetic (out-of-the-box)
- Multithreading-aware implementation, free from global interpreter lock (GIL)
- Simple plug-in application programming interface (API)
Influences
The following programming languages have driven major inspiration for MANOOL (in alphabetical order):
- Ada, APL
- C++, Clojure, CLU, Common Lisp
- Forth
- Haskell
- ISWIM
- Kernel (http://klisp.org)
- Modula-2
- Oberon
- Pascal, Perl, Python
- Scheme, Self, SETL2, Smalltalk, Standard ML
- Tcl
And the following programming languages are noteworthy anti-influences:
- C#, Java, JavaScript, PHP