The history of Aptilis

Appendix

Thibault Jamme about the beginnings of Aptilis:

I started thinking of the ideal CGI language when I first wrote CGI scripts back in 1995. Designers were involved in the creative loop from early on and they found the arcane syntax of PERL unmanageable. C, my favourite, was even worse. All languages at the time required libraries to be added on in order to cope with the web, for example to acquire HTML form variables. Another nightmare was portability were a program written under Windows would not even compile under Unix, and PERL was no different, in particular when it came to sending e-mails programmatically.
C was very bad with Strings, you'd either keep leaking memory (and that's extremely lethal to servers such as IIS who keep programs dormant) or you'd spend ages debugging your application.

Aptilis is based around a compiler that tranforms Aptilis source code in a string of operands and operators, piled-up together a la 'reverse polish' notation.

Aptilis addresses all those short comings by providing a similar feature set to Linux and Windows, and many things necessary for web deployment are built-in: HTML Form variables acquisition, Output of graphics with True Type support, XML, SSL, support for templates to separate business logic from graphic design and layout, etc. Aptilis makes beginners and non-programmers' lives easier.

Aptilis' first name was equinox after an album from Jean-Michel Jarre. However too many things were called Equinox, from ski companies to celtic sects. When it came to change the name I wanted to use the word 'habilis' after the first humans who used tools. Unfortunately, this was the name of a cleaning company in Belgium. 'hab' had to become 'apt'.


Changes from Aptilis 1 to Aptilis 2 (until build 044)

New predefined subs
-------------------

- SetArrayDimensions(Array[], dim1size, dim2size, ...)
  Up to 31 dimensions may be specified.
  returns total number of elements in array

- GetArrayDimensions - fills an array with the description of
  a multi-dimension array

- GetSubstring, but it's just another name for the already existing Mid

- GetCharAt to get the ASCII code of a character inside a string without
  resorting to a costly GetSubString

- Cat, a cheap alternative to string concatenation with '+' as in:
  c = a + b $
  can now also be:
  c = cat(a$, b$) $

- ParseDatabase will parse a database from a string as opposed to from
  a file. (Which allows you to get your databases from other sources than files)

- SortDatabase(db[], whatField, sortType) (Example in sdb.e.txt) to sort
  a database   using one of its fields.

- Stream subs: open, close, read, write, setPostion, getPosition.
  File handles (that may also be sockets in disguise) appear in Aptilis.
  What a shock!

- LoadPostFile extends the capabilities of loadFile, to load the result
  of a CGI program, using post and not get. LoadPostFile dumps either
  the local variables of the sub it's been called from, or the values of
  a key based array passed as an extra, optional parameter.

- HTTPLoad and HTTPPostLoad allow you to specify the Headers of an HTTP
  request.

- ReadEmails to read emails through a POP3 gateway.

- SendMimeMessage - allows to specify a mime type together with an encoding:
        attach = loadFile("aptilis-attached.txt") $
        mimeType = "multipart/mixed; boundary=\"-----X-TJTECH-952220281157\"" $
        sendMimeMessage(mimeType$, to$, from$, subject$, attach$, replyTo$)
        The body of the message needs to be encoded accordingly.
        Mime version is 1.0


  *** The new Aptilis Star Command! ***

- FillForm is a very powerful command that 'stuffs' an HTML form.
  It fills the value parameters of input tags and puts 'checked' and
  'selected' flags where needed in checkboxes/radioboxes and SELECTs
  respectively! This is very useful when a form needs to be filled with
  values to be edited!


  *** XML Support ***

- ParseXML will parse a piece of XML.

- GetXMLField will extract a field from a parsed XML string.

- GetXMLTagAttributes to get the attributes of a tag.


New features
------------

- Multiple dimension arrays. (Note that they cannot expand dynamically
  because   aptilis wouldn't know how - So an out of range subscript causes
  the programm to stop with an error.)

- main params

  The entry sub (by default: main) can now receive command line parameters:
  ex:  sub main(args[])

       end sub

  Note that the environment variables are available in the global array _ENV[""]
  and the number of command line parameters are availaible through:
  n = getArraySize(args[])

- Enhanced and rationalized error messages.

- Customized copyright message
  If there is a file called "aptilis-message.txt" in the directory where aptilis
  started, then this file is displayed in place of the original aptilis copyright
  message.

- Run-time error messages give out a call tree

- Select/case: case now takes negative paramaters as well

- var keyword
  This allows you to 'declare' the variables at the begining of a sub.
  Although aptilis does not require variables to be declared, if you choose
  to do so with 'var' then any undeclared variable found by the compiler
  will trigger an error. This can help find bugs such as 'nTOtal' typed
  incorrectly in places instead of 'nTotal'.

- Subs can now return arrays! Including thru the call/takeCalls mechanism!!

- HTTP 1.1 now supported! This was badly needed to retrieve web pages
  served by virtual web servers (servers that have several domains on
  the same IP number)

- Compile only flag.
  From the command line, adding an exclamation mark at the end of the aptilis
  file will signify to aptilis to check the program for errors, but not to run it.
  (You can't have aptilis program file names ending with an '!' now).

- More comment types:
  #
  '
  as well as the old //
  and... // can now be at the end of a line
  /*
     multiline comments
     now supported!
  */
  The rem comment has been removed as it was far too confusing.


- Removed features

  + From build 35, the 'entry' feature has been removed. That used to allow
  you to selecet an alternative to the 'main' sub when calling a program
  from the web. Indeed a hacker could have called any sub with the parameters
  of his / her choice.


Structural changes (No effect on coding, unless clearly stated otherwise)
------------------

- New 'for' implementation.
  The for loop run-time code has completly been re-implemented.
  It should be a bit faster and fixes a bug with aptilis 1.xxx which
  could not use a key indexed variable to loop.

- Completly new sub calling mechanism.
  This is to make the code re-entrant, in view to multithreading.
  The implementation of takeCalls is also affected.

- Call (RSI) uses the new sub calling mechanism.
  Performance should not be affected, but the new implementation
  makes the code more efficient, more legible and more maintainable.
  It also paves the way for future developments.

- LoadDatabase has been re-written. Build 27. Parsing is now halted on
  any error.


Improvements
------------

- Plenty of memory leaks fixed on exit caused by errors.
  (Thank you very, very much Code Guard!!!)
  (Code guard is a utility that came with my Borland C++ and it's just
   out of this world!)

- 'For' speed should be better.

- Significant code re-writes. (optimization, reliability, maintenance.)

- Variable context masking done at compile time (to save a few clocks at
  run-time) (Don't worry about it - it's fairly technical.)

- Operation in numeric context sped up. (inlining, internal.)

- Operations in string context have been optimized for cases where outcome
  is false.

- Less redundancy with the (internal) socket functions.

- Less redundancy between Database file functions and pure file functions (internal).

- Replace is SO much faster and efficient.


Known issues
------------

- a line looking like: (with boolean operators)
  r8 = a < b and 1 < 3
  will produce a syntax error. This is due to a quirk in the compiler
  which for the moment identifies assignments on a separate pass.

  Workaround: (It won't slow down your code)
  r8 = (a < b and 1 < 3)

- Unix version: GetFileLastModification returns the same value as GetFileDate

- Comments at the end of lines don't work all the time // and they should.


Issues solved
-------------

- Substractions in string context may cause crash instead of generating an error.
  Fixed as of 039.

- Separate used to return an empty array when the target was longer than
  the substrate. It now returns the whole substrate when the target
  is empty or longer than the substrate.

- Fixed missing header problems on loadFile loading URLs - this may cause
  some of your code to work differently, you may now need to explicitly remove
  headers from documents loaded from the Web, using the http protocol.
  ex: f = loadFile("http://www.cnn.com/") $

- Memory optimization at the end of database parsing.


Build History
-------------

  030 Fixed empty fields in databases that were ignored and shifted the rest
      leftward.
  031 Fixed 2 gasping huge memory over-allocation problems in parseDatabase.
  032 Added 'ReadLine' Command.
  033 Fixed 'Textarea' bug in fillForm.
  034 Used generic write functions for saveDatabase (Can now use ftp:// too.)
  035 Compiled with Freetype 1.5 (5 Nov 2002)
  036 Added file name in error message when script hasn't been found and fixed
      loading script problem on Unix. (13 Nov 2002)
  037 Added XML <TAG/> syntax. (26 Nov 2002)
  038 Fixed Freak XML parsing bug where parsed xml string thought it was bigger than
      it actually was.
      Re-factored http fetcher code - to higher standards, better performance and enhanced
      legibility.
      Added full versioning info in http headers when using built-in http fetcher.
      Fixed rare memory leak on wrong call to LoadPostFile.
      (12 Feb 2003)
  039 Fixed ClearArray bug that was WAY off the mark... An incorrect value was used
      to set the array's size.
      Fixed crash when reporting an inapproriate operator in a String context operation.
      (13 Feb 2003)
  040 Fixed rare replace bug that caused the end of the substrate not to be copied
      when the substrate was too short.
      Support for Transfer-Encoding: chunked in HTTP replies now supported. (02 Apr 2003)
  041 Support for SSL added. Fixed a bug on chunked HTTP with big documents.
      (29 Apr 2003)
  042 Fixed XML GetTagAttributes that was broken on tags near the end of the data
      block. (15 Jul 2003)
  043 Call to SSL_CTX_free, not much effect on leakage on shutdown. (2 Aug 2003)
      Note that the SSL leakage on shutdown should not be a problem.
      Also fixed problem where assigning an empty array to an array didn't clear up the
      destination array.
  044 Fixed XML parsing bug where the last field of an XML block may have been
      irretrievable.
      Also added XML comments support as well as the skipping of the Directives.
      (8 Sep 2003)
  045a Very first phase of MySQL interface integration. Adds predefined sub MySQLScramble.
      This may or may not stay inside Aptilis, or may stay but may not be documented.
  045b Max: First Open Source build with new license information.
      Libs used: OpenSSL 0.9.7c; FreeType 1.3.1.
  045c Two new subs: GetLocalVariablesList and GetGlobalVariablesList.
  045d Max: Fixed Bug in ReadEmails and added two optional parameters ´don't delete´ and ´headers only´.
  046 Fixed stream 'write' bug.
  047*1 GetTemplate implemented, WARNING contains debugging code that outputs junk - so not to be
        considered release material. Big parts of the parser have been completely re-written.
  047*2 Added support for <nick@server.com> "Nicks Realname" in sendmail, so that the
        sender's real name should appear in the recipient's message.