Argile is an experimental, C-based, compiled programming language, that produces C code. It is not intended for beginners, but for experienced programmers with a good knowledge of C language. Also, it is not intended for big productions uses, since its compilation time may not scale linearly.
In classical programming languages, all definitions (variables, functions, ...) are identified with an identifier, which is a single string of limited characters, like these:
main gtk_window_set_title SDL_SetVideoMode glPushMatrix define-abbrev-table
In Argile, however, definitions are identified mainly by their syntax. An argile syntax literal may look like this:
: <Person p> drives <Car c> (at <real speed = 50.0> { km/h | mph }) :
(<> are for parameters, () for options, {} for enumerations ...); this could then be called explicitly by:
(Bob) drives (some car) ; (Bob) drives (Bob's car) at 60.0 mph
or implicitly by:
Dave drives some car at 150.0 km/h
(that is supposing the definitions
:Person:
,
:Car:
,
:Bob:
,
:Bob's car:
,
:some car:
and
:Dave:
exist with expected types)
The version 1.0.0 of ARC is about 16900 lines of argile code, and compiles itself on an AMD Athlon™ 64 Processor 3000+ in about 1 minute and 44 seconds ! (an average of 162 lines per second) but that is including GCC compilation time which is around 30 seconds.
On an Asus EeePC (Intel® Celeron® M 900MHz processor), it compiles itself in about 4 minutes and 51 seconds (average: 58 lines per second).
This is probably the slowest to compile known programming language; indeed, compilation time doesn't necessarily grow linearly with the number of definitions. The execution speed however should be the same as with C.
With recent optimizations, the version 2.0.0 of ARC, having 17121 lines of code, compiles itself on the same Asus EeePC in 4 minutes and 12 seconds (average: 68 lines per second). On an Intel® Core™ i3 2350M CPU @ 2.30GHz, it compiles in about 44 seconds (23 seconds with 3 concurrent compilation jobs).
For example, the argile wrapper for the SDL library looks like this:
use std, array #include <"SDL/SDL.h"> #extern :SDL_Init <nat flags>: -> int #extern :SDL_InitSubSystem <nat flags>: -> int #extern :SDL_Quit: #extern :SDL_QuitSubSystem <nat flags>: #extern :SDL_WasInit <nat flags>: -> nat #extern SDL_INIT_TIMER -> nat #extern SDL_INIT_AUDIO -> nat #extern SDL_INIT_VIDEO -> nat (: ... :)
Argile means clay, which is often plastic and can take any shape. Since the main feature of Argile programming language is to be polymorphic, Clay would have been a well-suited name. However, this word is too common, and a Clay programming language already exists (according to web search engines).
release of version 2.1.0 (ChangeLog)
release of version 2.0.2 (ChangeLog)
Argile language reference available in documentation
release of version 2.0.1 (ChangeLog)
This is only a minor fix
release of version 2.0.0 (ChangeLog)
This is a major version change; it does not support shared object module anymore since it wasn't actually useful, plus it didn't work properly on MinGW platform. It has been tested successfully on :
release of version 1.2.0 (ChangeLog)
release of version 1.1.1 (ChangeLog)
release of version 1.1.0 (ChangeLog)
added links for mailing list, Savannah project page and CVS in contact and downloads sections
release of version 1.0.0
To compile argile compiler, you will need: GCC, GNU make, GNU bash.
To modify and/or recompile the argile compiler, you will also need: automake, autoconf, libtool, GNU bison, flex.
Start by extracting the source tree from the archive; in a terminal, type:
tar -xzvf /path/to/argile-2.1.0.tar.gz && cd ./argile-2.1.0
Then, either make a system-wide installation, or a user local home installation as follows;
First, compile by typing the following commands in a console or terminal:
./configure --prefix=$HOME && make
Optionally, you can recompile the compiler with itself (very slow) by typing:
make backup && make re
Then, install with the command:
make install
First, compile by typing the following commands in a console or terminal:
./configure && make
Then, as administrator (super user or root), install with the command:
make install
(note: on MinGW or Cygwin, there is no need to be administrator)
('/usr' should be replaced by the value you gave to the --prefix option of the configure script, if you did, or '/usr/local')
/usr/bin/arc
/usr/bin/arc-make.sh
/usr/lib/libargrt*
/usr/include/argile/argrt/*
/usr/share/doc/argile/*
/usr/share/argile/argile.el
Typing the following command in a console or terminal:
arc --version
should print something like:
arc (Argile Compiler) version 2.1.0 Copyright (C) 2009,2010,2011,2014 the Argile authors (see the AUTHORS file distributed along with this software). This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
And typing:
arc --line='use std; print "Hello, world!"'
should print something like:
#include "/usr/include/argile/argrt/std.h" int main(int argc, char **argv) { printf("%s\n", "Hello, world!"); return 0; }
This documentation is installed in PREFIX/share/doc/argile, where PREFIX is either /usr, your HOME directory, or any other value you gave to the --prefix= option of the configure script:
Help on command line options:
arc --help
gives:
Usage: arc [options...] [--] [file] Options help: -a --max-match-rec <max> : Limit syntax match depth; 0 = no limit (may take ages) (default is 500) -A --add-dir <dir> : Add directory to file path list -b --bind-doc <name> : Finds documentation of binding (e.g std/print) -B --double-source-lines : Generate line numbers of both argile and C sources -c --max-comp-rec <max> : Limit compilation depth; 0 = no limit (may take ages) (default is 1000) -C --concat : Concatenate main codes in main function -d --dump : Dump precompiled code on stdout -D --debug-comp : Dump compilation process -e --env-help : Show the environment variables help -g --max-gen-rec <max> : Limit gencode depth; 0 = no limit (may crash) (default is 500) -G --get-defs <syntax> : Get definitions matching syntax -h --help : Show this help -H --header <file> : Generate C Header in file -i --indent : Code dumping is indentation-based -I --include-dir <dir> : Add directory to system include path list -l --line <string> : Parse string instead of file or stdin -L --source-lines : Generate source line numbers for C preprocessor -m --module <file> : Generate modularized argile header in file -M --no-main : Generate NO main function -n --no-color : Don't use colors (for errors and dumping) -N --no-auto-use : Disable auto use file list -o --output <file> : Generate C code in file instead of stdout -O --operators <file> : Set extra operators file (see --extract-operators) (each line is 1 or 2 hexadecimal numbers: start end) -p --deps <file> : Generate Makefile dependencies in file -P --proto-syntax : Generate syntax comment for functions prototypes -r --max-rejects <max> : Limit reject history; 0 = no limit (default is 5) -R --show-progress : Show progress percentage during compilation -S --stats : Print compilation statistics when dumping -t --col-per-tab <cols> : Set number of columns per tabulation (default = 8) -T --daltonism : Print symbols corresponding to colors (dumping) -u --utf8 : Use UTF-8 for column counting and $ARGILE_OPERATORS -U --use <file> : Use file (preload) -v --verbose : Print additional informations -V --version : Show version information and exit -x --hexa-string : Use hexadecimal sequences for non-ascii strings -X --extract-operators : Get default extra operators file content
Help on environment variables:
arc --env-help
gives:
Environment variables help: ARGILE_AUTO_USE : list of files separated by ':' (see --use) ARGILE_COLOR : 0 or 1 (opposite of --no-color) ARGILE_COLPERTAB : integer (see --col-per-tab) ARGILE_DALTONISM : 0 or 1 (see --daltonism) ARGILE_FILE_PATH : list of pathes separated by ':' (see --add-dir) ARGILE_HEXASTR : 0 or 1 (see --hexa-string) ARGILE_INDENT_STYLE : 0 or 1 (see --indent) ARGILE_LINENUMS : 0, 1 or 2 (see --source-lines and --double-source-lines) ARGILE_MAXCOMP : integer (see --max-comp-rec) ARGILE_MAXGEN : integer (see --max-gen-rec) ARGILE_MAXMATCH : integer (see --max-match-rec) ARGILE_MAXREJECTS : integer (see --max-rejects) ARGILE_OPERATORS_FILE: (see --operators and --extract-operators) ARGILE_OPERATORS : string of additional operator characters (or ranges) (ex: "!#-'*-/<-@[-`|~" : '-' sign delimits a range; so "<-@" means from '<' character to '@') ARGILE_UTF8 : 0 or 1 (see --utf8) HOME : when no ARGILE_FILE_PATH is set, $HOME/include/argile/ $HOME/include/argile/argrt/ , /usr/include/argile/ , /usr/include/argile/argrt/ and `./' are also added to the file path.
Documentation on bindings:
arc --bind-doc "std/*"
arc --bind-doc std/print
gives:
========================== std/print : ========================== Print its arguments without spaces between them using printf() and supports formatting for the basic types (int, nat, real, word, text, syntax); for other types, it prints a pointer address (%p format). It can also print spaces between arguments, if the bind option `spaced' is specified. If the bind option `error' is set, it will print on standard error rather than the default standard output. Only the first syntax parameter is considered, but it can be in a list. Syntax requirements :<any>: :[<any>...]: ==========================
use std print "hello, world!" printf "Hello world\n" echo Hello World "!"
print "Hello, world!" bind :print [<anything> ... 1,]: to std/print bind :anything: to std/anything
use std; print x let x = 0 print x let x = 1 let x = 2 print x let x = 3 (: this will print: 0 0 2 :)
use std (: arith. operators macros priority results from their order in std.arg ; also, they use unions, so int/nat must be explicited :) let int x = 1 + 3 * 4 / 2 (: 1 + ((3 * 4) / 2) :) print x (: prints 7 :) let int y = (x * 2 + 3) (: = (x) * (2 + 3) !!!! (x) is detected after (2+3) since it is shorter, and constant literals are immediately detected as such; so when doing arithmetics on non-constant, adding some parenthesis is good practice. :) let int y = (x * 2) + 3
use std .:first function:. -> nat { let nat N = 13 sub function sub function if N == 13 return 1 .:sub function:. a macro N =:a macro <nat &x>:= {x *= 2} (: takes a reference to a natural :) N } print first function (: will print 52 :)
(actually, argile macros are some kind of inline functions)
When compiled, this generates the following C code:
#include "/usr/include/argile/argrt/std.h" unsigned int first_function(); static void sub_function(unsigned int * N); unsigned int first_function() { unsigned int N = 13; sub_function(&N); sub_function(&N); if ((N == 13)) { return 1; } //; return N; } static void sub_function(unsigned int * N) { *N *= 2; } int main(int argc, char **argv) { printf("%u\n", first_function()); return 0; }
use std class Foobar int i nat n text t Foobar f (: In class code, calls are not compiled normally, the class binding of the std module wants them to match this syntax :<type> <word> (/<nat>): (the natural integer can be used to specify a bit size) :) (: some kind of method :) .: <Foobar me>.increment :. {me.i++ ; me.n++ ; me.t++} let Foobar@ F (: @ is for raw value, rather than pointer :) F.t = "some foobar text" prints (F.i) (F.t) (F.f) F.increment prints (F.i) (F.t) (F.f) class Dummy_Inherits_Foobar <- Foobar real r let D = new Dummy_Inherits_Foobar D.increment prints D.r D.i del D class Kornholyo {any TP} class :Manual Multi Inheritance: { Foobar@ foobar_parent Kornholyo@ kornholyo_parent } autocast Manual Multi Inheritance -> Foobar; autocast Manual Multi Inheritance -> Kornholyo { Manual Multi Inheritance.kornholyo_parent (: it's not the first field :) } let Manual Multi Inheritance@ M M.increment (: auto cast to Foobar :) M.TP = nil (: auto cast to Kornholyo :)
E-mail to < argile-questions at nongnu dot org > (a public mailing list) for any question related to programming in Argile, or compiling or installing the Argile compiler. You can also consult its archives here.
E-mail to < argile AT gmail DOT com >
Project page of Argile compiler on GNU Savannah: here
Argile compiler is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 3 or (at your option) any later version. (see COPYING for details).
Copyright © 2009,2010,2011,2014 The Argile authors (see details here).
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included here.