Alacrity

From Esolang
Jump to navigation Jump to search

Alacrity is an interpreted scripting language developed as a middle layer API for Lost Astronaut Studio's Game Creation Framework. Alacrity is an object-based language which has a primary programmatic feature of instantiation. All objects are instantiated by defining their characteristics. The underlying language, C++, is used to define the programmatic interface for each object based on a simple structured string data specification called HData.


The meaning of the word alacrity, interpreted at the time of the naming of this language, was "with quickness and finesse". The overall philosophy of the language is to allow powerful control of multimedia systems without lots of low-level involvement, so that applications could be developed and modified faster without sacrificing the finesse of complex underlying functionality.

In 'Alacrity', there are seven majors rules of syntax:

  • Object names that refer to a series of preprogrammed types
  • Instantiative values which consist of either keywords, for example visible that presumably activates a parent feature's visibility, or "nestable" key/value pairs, for example homogeneously as {key value} or heterogeneously {key value keyword key value...}, where values can also be nested and have formatting specific to the use case, such as parent {numlist {1 2}} or document {text {Some string}}
  • Nesters characters which group a list of keywords or key/value pairs, or a value only, specifically: {} [] and () can be used interchangeably, or ″″ or ′′
  • Fillers characters which are treated as the space between instantiative values, these being: comma (,), equals (=), space ( ), newline character, linefeeds are removed from the language entirely through a filter
  • Assignments to create a handle to refer to an object later ^variable typename {value(s)}
  • Bound functions Calls to actual C/C++ API functions that are bound to the Alacrity language. The form takes one or more parameters in the format of a list of values, or a list key value pairs, depending on the function's description. Some examples include text.load("filename.txt",varname) which would set a variable called varname equal to the contents of the file filename.txt, or nothing if the file did not exist or crayon.mix {^a ^b 0.5 c} which would set a crayon c equal to the result of mixing values a and b by a factor of 0.5, if a or b was not a crayon it would be "smartly converted" depending on the input variable's type
  • Expressions which result in a conditional when combined with operators, or are evaluated based on type. Expressions are used only by the when clause, and may include bound functions


Alacrity's reference guide does provide the concept of "root.branch.variant" in the form of variable naming conventions, though it is not expected that it will be followed by every programmer or in every use case.

Alacrity has many type definitions, but the basic types of the language are:

  • String for storing lists of characters
  • Number for storing lists of numeric values
  • Crayon for storing RGBA color values (also understands 6- and 3-character CSS hexadecimal RGB values)
  • Cartesian 2D coordinates and their related geometric forms (lines, rectangles, and line angles)
  • Tween that provide pre-loaded waveform data for animated easing
  • Image that can be constructed or loaded as PNG or JPG
  • Film collections of images
  • Model 3D models
  • Scene A list of Models
  • Window A window which may include UI elements or logical contingencies based on state-machines
  • Presentation A scriptable time-based media experience that consists of a collection of Slides each containing Visual Aids with ending contingencies (like "loop" or "go to next")

Objects of a particular type are converted "smartly" or "as one would expect or hope" in Alacrity, and types can be forced to transmogrify into other types. For example, there is a specific and transparent rule defining the action taken when the programmer is setting a floating point decimal equal to a crayon yields a particular result, but that conversion would be different and distinct when occurring in reverse.

Alacrity's HData structured string data specification allows a recursive tree of interrelated objects to be described by the language and later instantiated during run-time as compiled C++ counterparts. HData can be thought of as a Russian Dolls approach to object instantiation hierarchies, where each nestable "doll" may have different sets of specific features and an expected format.

Example HData fragment:

race {
 annual
 name "Indy 500"
 car {
  name "Ford Prius"
  driver {
   name "Bob the Walrus"
  }
  raceTeam {
   colors {blue green yellow}
  }
  topSpeed 75
  brakeSpeed 0.12
 }
 car {
  name "The NesQuickening"
  driver {
   name "Mario Andretti"
   age 56
  }
  raceTeam {
   colors {blue green yellow}
  }
  topSpeed 175
  brakeSpeed 0.12
 }
 car {
  name "Big Bessie"
  type truck // The default value for "type" is "car", change to "truck"
  driver {
   name "Austin Bearing"
   age 25
  }
  raceTeam {
   colors {#F31 white green}
  }
  topSpeed 185
  brakeSpeed 0.06
 }
}

Alacrity only provides an interface to C++ which implements the functionality between the hardware and OS levels, and the user interface level, of a given interpreted application. Alacrity's main interpreter is currently implemented experimentally only for Windows and OpenGL, with some utility classes for managing sets of HData with MySQL in PHP.

External resources