Argile Programming Language (experimental)

current version: 2.1.0

1. About

1.1. Introduction

1.1.1. Disclaimer

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.

1.1.2. Basics of Argile programming language

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)

1.2. Features

1.2.1. Main features

  • Variable syntax
  • Polymorphism-oriented
  • Call guessing
  • Keyword-less
  • UTF-8 based
  • Access to low level programming
  • Parametered types
  • Object-oriented classes available
  • Implicit type casters can be defined
  • Definitions can be made after they are used
  • Subfunctions and anonymous functions
  • Both indentation-style and braces-style can be used

1.2.2. Drawbacks

  • 1.2.2.1. Slow compilation times (non-linear)

    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).

  • 1.2.2.2. Reusing C libraries requires some wrapping code

    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
    
    (: ... :)
    

1.3. Why the name "Argile" ?

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).

2. News

3. Downloads

4. Installation

4.1. Requirements

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.

4.2. Extracting the sources

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;

4.3. User local home directory installation

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

4.4. System-wide installation

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)

4.5. Files installed (non-exhaustive list)

('/usr' should be replaced by the value you gave to the --prefix option of the configure script, if you did, or '/usr/local')

4.6. Testing the installation

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;
}

4.7. Uninstallation

In the source directory where you compiled argile, type:

make uninstall

and it will uninstall what it has installed (if you installed system-wide, you will need root privileges again)

5. Documentation

5.1. Argile language reference

Language reference can be found here.

5.2. Installed documentation

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:

5.3. Embedded documentation

5.4. Examples

5.4.1. Hello world

use std
print "hello, world!"
printf "Hello world\n"
echo Hello World "!"

5.4.2. Hello world without std.arg

print "Hello, world!"
bind :print [<anything> ... 1,]: to std/print
bind :anything: to std/anything

5.4.3. Overloading and definitions order

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
:)

5.4.4. Arithmetics

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

5.4.5. Functions and Macros

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;
}

5.4.6. Classes

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 :)

5.4.7. Some source code from Argile runtime library

6. Screenshots

7. Contact

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

8. Copyright

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.