Falcon (programming language)
Encyclopedia
Falcon is an open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

, multi-paradigm
Multi-paradigm programming language
Programming languages can be grouped by the number and types of paradigms supported.-Paradigm summaries:A concise reference for the programming paradigms listed in this article....

 programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

. Design and implementation is led by Giancarlo Niccolai, a native of Bologna, Italy and Information Technology
Information technology
Information technology is the acquisition, processing, storage and dissemination of vocal, pictorial, textual and numerical information by a microelectronics-based combination of computing and telecommunications...

 graduate from Pistoia
Pistoia
Pistoia is a city and comune in the Tuscany region of Italy, the capital of a province of the same name, located about 30 km west and north of Florence and is crossed by the Ombrone Pistoiese, a tributary of the River Arno.-History:...

.

Falcon translates computer source code
Source code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...

 to virtual machine
Virtual machine
A virtual machine is a "completely isolated guest operating system installation within a normal host operating system". Modern virtual machines are implemented with either software emulation or hardware virtualization or both together.-VM Definitions:A virtual machine is a software...

 instructions for evaluation. The virtual machine is thought both as a stand-alone interpreter and for integration in third-party embedding applications.

A core design consideration for the Falcon programming language is to provide acceptably high performing scripting plug-ins to multi threaded
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...

 data acquisition, reporting and dispersion applications. Work continues towards that end as Falcon approaches an official 1.0 reference implementation. Doxygen
Doxygen
Doxygen is a documentation generator for multiple programming languages.Doxygen is a tool for writing software reference documentation. The documentation is written within code, and is thus relatively easy to keep up to date...

 processed source code posted at falconpl.org.

As programming languages go, Falcon design leans more towards conciseness of code and expressiveness
Expressive power
In computer science, the expressive power of a language describes the ideas expressible in that language.For example, the Web Ontology Language expression language profile lacks ideas which can be expressed in OWL2 RL . OWL2 EL may therefore be said to have less expressive power than OWL2 RL...

 than general readability. The Falcon implementation does provide facilities for source level documentation
Software documentation
Software documentation or source code documentation is written text that accompanies computer software. It either explains how it operates or how to use it, and may mean different things to people in different roles....

 and this documentation may become important as the mixed paradigm potential of Falcon scripting attempts to meet the problems faced with programming in the large.

History

A small project, HASTE, developed in 2002, in an attempt to create a small fast virtual machine
Virtual machine
A virtual machine is a "completely isolated guest operating system installation within a normal host operating system". Modern virtual machines are implemented with either software emulation or hardware virtualization or both together.-VM Definitions:A virtual machine is a software...

, soon evolved into the Falcon programming language. In early 2008, the package was first shipped under open source licensing as a package in Ubuntu
Ubuntu (operating system)
Ubuntu is a computer operating system based on the Debian Linux distribution and distributed as free and open source software. It is named after the Southern African philosophy of Ubuntu...

, and included in the KDE 4 scripting framework
Kross (KDE)
Kross is the new scripting framework for KDE SC 4, the latest version of the KDE SC. Originally Kross was designed for use in Koffice but eventually became the official scripting framework in KDE SC 4...

.

Philosophy

Rather than focusing on one programming style or paradigm
Programming paradigm
A programming paradigm is a fundamental style of computer programming. Paradigms differ in the concepts and abstractions used to represent the elements of a program and the steps that compose a computation A programming paradigm is a fundamental style of computer programming. (Compare with a...

, Falcon merges several different styles into a single framework
Software framework
In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software...

. At the same time, it targets multiple application domain
Application domain
In Microsoft's Common Language Runtime , an application domain is a mechanism used to isolate executed software applications from one another so that they do not affect each other...

s (stand-alone, embedded into other applications and server-side dynamic pages), merging them into a single hood of a common architectural design
Software architecture
The software architecture of a system is the set of structures needed to reason about the system, which comprise software elements, relations among them, and properties of both...

.

At the implementation level, Falcon is driven by the concept of service, where the scripting engine
Scripting language
A scripting language, script language, or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the...

 is seen as a service for scripts, modules and in embedded applications when not used as a stand-alone tool.

"Hello World" example

Although there are various forms of basic I/O, an example Hello world program
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

 using fast print:

> "Hello World!"

Supporting Unicode
Unicode
Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems...

, below is an internationalized example of introductions:

// International class; name and street
class 国際( なまえ, Straße )
// set class name and street address
नाम = なまえ
شَارِع = Straße
// Say who am I!
function 言え
>@"I am $(self.नाम) from ",self.شَارِع
end
end
// all the people of the world!
民族 = [ 国際( "高田 Friederich", "台湾" ),
国際( "Smith Σωκράτης", "Cantù" ),
国際( "Stanisław Lec", "południow" ) ]

for garçon in 民族: garçon.言え

which, when evaluated, displays

I am 高田 Friederich from 台湾
I am Smith Σωκράτης from Cantù
I am Stanisław Lec from południow

Data types

  • Nil - The nil keyword, a non-value.
  • Integer
    Integer (computer science)
    In computer science, an integer is a datum of integral data type, a data type which represents some finite subset of the mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values....

     - an integer 64 bit value.
  • Numeric
    Floating point
    In computing, floating point describes a method of representing real numbers in a way that can support a wide range of values. Numbers are, in general, represented approximately to a fixed number of significant digits and scaled using an exponent. The base for the scaling is normally 2, 10 or 16...

     - An IEEE 64 bit floating point value.
  • Range - a triplet of lower bound, higher bound and step.
  • MemBuf - Raw memory buffer, where each location is an unsigned 1, 2, 3, or 4 bytes integer.
  • Function
    Subroutine
    In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....

     - Functions (callable entities).
  • String
    String (computer science)
    In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....

     - Mutable sequences of UNICODE characters (but they can be used as byte buffers).
  • Array - Mutable sequences of items.
  • Dictionary
    Associative array
    In computer science, an associative array is an abstract data type composed of a collection of pairs, such that each possible key appears at most once in the collection....

     - Mutable ordered set of key/value pairs; the key can be any Falcon item.
  • Object
    Object (computer science)
    In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure...

     - Instances derived from classes or stand-alone classless objects.
  • Class
    Class (computer science)
    In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior...

     - Classes, entities that can create instances.
  • Method
    Method (computer science)
    In object-oriented programming, a method is a subroutine associated with a class. Methods define the behavior to be exhibited by instances of the associated class at program run time...

     - Immutable pairs of instances and functions to be applied on them.

Paradigms

Falcon merges six major programming paradigms.
  • procedural
    Procedural programming
    Procedural programming can sometimes be used as a synonym for imperative programming , but can also refer to a programming paradigm, derived from structured programming, based upon the concept of the procedure call...

  • functional
    Functional programming
    In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...

  • object oriented
    Object-oriented programming
    Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

  • prototype OOP
    Prototype-based programming
    Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as classless, prototype-oriented or instance-based programming...

  • message oriented
    Message passing
    Message passing in computer science is a form of communication used in parallel computing, object-oriented programming, and interprocess communication. In this model, processes or objects can send and receive messages to other processes...

  • tabular programming

Procedural

Procedural programming
Procedural programming
Procedural programming can sometimes be used as a synonym for imperative programming , but can also refer to a programming paradigm, derived from structured programming, based upon the concept of the procedure call...

 is supported through classic function declarations and calls. Every function supports implicitly variable parameter calls and named/positional parameters. A set of procedural style statements (as i.e. for, while, if, switch statements) is provided.

The following is a complete procedural program.

function sayList( saying )
for elem in saying
>> elem
formiddle: >> " "
forlast: > "!"
end
end
sayList( List("Have", "a", "nice", "day") )

If the above is saved to a text file as niceday.fal, a command line of falcon niceday.fal produces
Have a nice day!
on standard output
Standard streams
In Unix and Unix-like operating systems , as well as certain programming language interfaces, the standard streams are preconnected input and output channels between a computer program and its environment when it begins execution...

.

Functional

Falcon has an evaluation engine
Evaluation strategy
In computer science, an evaluation strategy is a set of rules for evaluating expressions in a programming language. Emphasis is typically placed on functions or operators: an evaluation strategy defines when and in what order the arguments to a function are evaluated, when they are substituted...

 called Sigma-reductor, which allows programmers to write completely functional programs
Functional programming
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...

 without the need to use any procedural construct, not differently from what is seen in Lisp. The intermixed programming style allows use of different paradigms (such as OOP
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 or procedural
Procedural programming
Procedural programming can sometimes be used as a synonym for imperative programming , but can also refer to a programming paradigm, derived from structured programming, based upon the concept of the procedure call...

 approaches) in functional sequences, or to use functional evaluations during the course of otherwise procedural programs.

Functional sequences are represented by standard language arrays
Homoiconicity
In computer programming, homoiconicity is a property of some programming languages, in which the primary representation of programs is also a data structure in a primitive type of the language itself, from the Greek words homo meaning the same and icon meaning representation...

; this means that sequences can be created, inspected and changed dynamically by the program itself, either across different evaluations or during the course of a Sigma-reduction evaluation. The following example does that by changing a special variable reference, called late binding
Name binding
In programming languages, name binding is the association of objects with identifiers. An identifier bound to an object is said to reference that object. Machine languages have no built-in notion of identifiers, but name-object bindings as a service and notation for the programmer is implemented...

in a list loop.

seq = [ printl, '"', &value, '"' ]

dolist( function(p); seq.value = p; eval(seq); end,
["Have", "a", "nice", "day"] )

Standard arrays can be called as functions if their first member is itself a callable item, as in the following example.

f = [printl, "Prompt> "]
f( "Real data to print" )

One-level functional sequences (as in the above example) can be conceptually treated as cached calls, and once assigned to a variable, they are morphologically equivalent to a function symbol.

The functional paradigm includes an out of band item marker. Items can receive an oob flag marker which can be tested through language operators and functions and indicate a special meaning for values traveling in functional sequences. For example, many functional loops, as floop and times can perform loop restarts or can be interrupted by returning either a out of band 1 or 0 from any of the involved functions. The map
Map (higher-order function)
In many programming languages, map is the name of a higher-order function that applies a given function to each element of a list, returning a list of results. They are examples of both catamorphisms and anamorphisms...

function, transforming all the values in an array through a mapping function, will ignore the returned value (discarding it) if it's an out of band nil; in this way, it is possible to perform map-and-filter operations in place.

Class-based object-orientation

The Falcon programming language provides an OOP paradigm with classes
Class (computer science)
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior...

, an inheritance
Inheritance (object-oriented programming)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

 model, class-static members, property initializers and instance constructor. Multiple inheritance
Multiple inheritance
Multiple inheritance is a feature of some object-oriented computer programming languages in which a class can inherit behaviors and features from more than one superclass....

 is supported under the condition that at most one underlying ancestor class is reflecting native data. Access to base class members is supported.

Instance structure is fixed and immutable
Immutable object
In object-oriented and functional programming, an immutable object is an object whose state cannot be modified after it is created. This is in contrast to a mutable object, which can be modified after it is created...

, but due to Falcon's functional nature where functions are seen as just a special kind of data, it is possible to set instance members to plain data or functions (making them methods) dynamically. Functional sequences can be assigned to properties, in which case they become functional methods for the given OOP instance.

Falcon supports stand-alone objects, which can be either classless or derived by class ancestors, which are instantiated and readied before the Virtual Machine executes the main script. Instance Resolution order is tracked by the Falcon Linker to ensure proper initialization of stand-alone objects, which may refer one another in program modules.

Class instances can be created through functional sequences, as instancing a class is morphologically equivalent to calling its symbol, and so, evaluating a functional sequence whose first element is a class has the effect of creating an instance.

Falcon OOP model is completed by operator overloading, which allows to create classes on which the mathematical and logical operators have a special behavior.

The C++ classes that build the Falcon engine are Doxygen
Doxygen
Doxygen is a documentation generator for multiple programming languages.Doxygen is a tool for writing software reference documentation. The documentation is written within code, and is thus relatively easy to keep up to date...

 indexed at falconpl.org.

Prototype-based object-orientation

Prototype OOP
Prototype-based programming
Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as classless, prototype-oriented or instance-based programming...

 is similar to classic Class-based OOP
Class-based programming
Class-based programming, or more commonly class-orientation, refers to the style of object-oriented programming in which inheritance is achieved by defining classes of objects, as opposed to the objects themselves .The most popular and developed model of OOP is a class-based model, as opposed to an...

, but it drops the concept of classes
Class-based programming
Class-based programming, or more commonly class-orientation, refers to the style of object-oriented programming in which inheritance is achieved by defining classes of objects, as opposed to the objects themselves .The most popular and developed model of OOP is a class-based model, as opposed to an...

. Instances are all classless, and their structure can be dynamically changed. Falcon language dictionaries
Associative array
In computer science, an associative array is an abstract data type composed of a collection of pairs, such that each possible key appears at most once in the collection....

 (ordered key/value pair collections) can include functions; dictionaries can then be blessed to inform the language that they are to be treated as classless instances, and applying dot accessor causes their values to be treated as properties
Property (programming)
A property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field and a method. Properties are read and written like fields, but property reads and writes are translated to get and set method calls...

 or methods
Method (computer science)
In object-oriented programming, a method is a subroutine associated with a class. Methods define the behavior to be exhibited by instances of the associated class at program run time...

. In the following example, a dictionary becomes an object:

dict = bless([ 'state' => 0, 'incme' => function; self.state++; end ])
dict.incme
> dict.state // will print '1'

Bindings
Name binding
In programming languages, name binding is the association of objects with identifiers. An identifier bound to an object is said to reference that object. Machine languages have no built-in notion of identifiers, but name-object bindings as a service and notation for the programmer is implemented...

 in arrays works similarly.

array = [1,2,3]
array.showMe = function
for item in self
> item
end
end

array.showMe

Message-oriented

Message-oriented programming
Message passing
Message passing in computer science is a form of communication used in parallel computing, object-oriented programming, and interprocess communication. In this model, processes or objects can send and receive messages to other processes...

 allows indirect calls to one or more registered listeners when a message is broadcast. The contents of the message are arbitrary and can include any language item, including but not limited to classes from which to create instances, functional sequences or tables. Listeners can either compete to receive the message and exclude the others, or participate in building a common reply to the message in ordered steps. Messages can be broadcast and require an immediate reply or can be left in the environment to be received and processed by latecomers (termed assertions in Falcon).

Message oriented programming has a direct interface into the Virtual Machine, on which external native modules and embedding applications can interact. For example, a multithreaded application may throw into the virtual machine messages coming from different threads, for serialized processing at script level and later broadcast of processed solutions directly from within the scripts.

Tabular

Tabular programming can be seen as a special extension of OOP programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

, where a class is represented by a table, whose columns are properties and where each row is an instance. Other than keeping all the instances together, and allowing each instance to work on the surrounding rows of the parent table, modification on the table are dynamically reflected into every instance.

Tables offer a means to select behaviors between a finite set of choices, or to mix behaviors and merge them, providing fuzzy logic engines. As each row, actually a Falcon array, can contain both table-specific data and logic or private logic (via array bindings), an entity selected in a table via global selection logic can provide specialized working abilities.

Features

Along with the multiple paradigms, Falcon presents a variety of different features for programmers.

List comprehensions

Base types and classes exposing the sequence interface to the internal engine offer a "comp" method which offers all the functionality of a list comprehension construct. The comp method takes a mandatory "source" parameter, which can be another sequence, an item of range type or a generator function returning one item at a time, and a special marker at termination.

A function (or in general a callable item) can be provided as second optional parameter, and acts both as a filter and modifier.

Associative pair sequences (as i.e. dictionaries) are supported as well.

The following is a simple example using a range to create a list comprehension; the result is an array of even numbers 2..10:

even_array = [].comp( [2:11:2] )

This generates a list of random integer numbers in the range 1,9; the list terminates when the random number is 10 (that is, each item as 1/10 probability to be the last).

random_list = List.comp( function; n = random(1,10); return n 10 ? oob(0): n; end )

The next, more complete example, uses a generator to fill a set of exactly 10 unique random numbers chosen in the 1..100 range. In this occasion, the role of determining the end of the comprehension is delegated to the filter.

random_set = Set.comp(
[random, 1, 100], // generator, callable array
function( number, myself ) // filter, using the optional "myself" param
if myself.len 10
return oob(0) // return oob(0) as a generator to terminate
end
return number
end
)

The "comp" method returns the same object it operates on. So, it is possible to apply it on an already existing sequence to add more data to it.

Similarly, the "mfcomp" generic method allows to create list comprehensions using more input sets, as in the following example.

sums = [].mfcomp( {x,y=> x+y}, .[1 2 3], .[4 5 6] )

The resulting array in "sums" contains the values obtained summing each element in the first set (x) with each element of the second set (y).

Template documents

Falcon allows scripts to be part of text documents, with the preprocessor or directive. Scripts saved as ".ftd" files are treated as text documents and simply echoed until one of those processor directives is encountered. Inbound scripts are executed as in the following .ftd example:

You called this script with parameters.

FTD documents can be merged with normal Falcon scripts to form applications, where the presentation logic is in dynamic templates (the FTD files), and the application logic is stored in Falcon modules.

FTD documents can be used in driving dynamic websites. Some popular webservers (currently Apache 2
Apache HTTP Server
The Apache HTTP Server, commonly referred to as Apache , is web server software notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million website milestone...

), have modules which directly parse and execute ".fal" and ".ftd" scripts, providing an API which integrates in the webserver engine. It is also possible to use dynamic FTD pages along with CGI scripts.

Exceptions

Falcon supports error handling via the raise, try and catch statements. The raise statement can throw any Falcon item, including nil, numbers, strings, objects and so on. Library functions and external modules will usually raise instances of the Error class, or instances of a class derived from that.

The catch statement can be used to catch any type of item, a certain type (i.e. strings or integers), or instances from a certain class. Caught classes are organized on a hierarchical base, so that it is possible to provide more generic error handlers like the following example (TypeError is a library class derived from Error):

try
... code that can raise ...
catch TypeError in error
... if we mixed up types ...
catch Error in error
... another generic error ...
catch StringType in error
... an explicit raise "something" was issued ...
catch in error
... some other exception has been raised, referenced in the variable error.
end

The in clause of the catch statement is optional (this means that the error itself may be discarded).

The catch statement mimics the select statement, which can be used to switch on the type or class of a given variable.

Explicit string expansion

Falcon includes an '@' unary string expansion operator that returns a string with inline '$' variable references replaced. This operation allows for formatting during the substitution.

For example:

a = 123456.789
v = "formatted as"
s = "a = $a, $v $(a:12rg3,.2), rounded hex as $(a:C)"
printl( @ s)

Which prints:
a = 123456.789, formatted as 123,456.79, rounded hex as 0x1E241
  • a literal string, a = , the value of the variable a, and a literal comma
  • an expanded string from the variable v
  • the value of a, right-aligned in a width of 12, 12r, with a grouping of 3 using comma, 3g, and then rounded to 2 decimal places, .2
  • the value in upper-case hexadecimal (rounded up to closest integer) prefixed with '0x'.

Embeddable runtime

Falcon is designed for embedding into and extending other systems with a linkable runtime library, libfalcon.

Documentation generator

Falcon ships with an integrated documentation system
Documentation generator
A documentation generator is a programming tool that generates documentation intended for programmers or end users , or both, from a set of specially commented source code files, and in some cases, binary files....

, called faldoc, which is specifically designed to provide Falcon based libraries (be they native C++ code or module sets written in Falcon) with maintainable documentation
Software documentation
Software documentation or source code documentation is written text that accompanies computer software. It either explains how it operates or how to use it, and may mean different things to people in different roles....

.

Virtual filesystem

All I/O operations happening at engine or at virtual machine (script execution) level are delegated to a centralized Virtual Filesystem Provider
Virtual file system
A virtual file system or virtual filesystem switch is an abstraction layer on top of a more concrete file system. The purpose of a VFS is to allow client applications to access different types of concrete file systems in a uniform way...

, to which external modules or embedding application facilities are allowed to register dynamically. Subscribed Virtual Filesystems abstract I/O operations as directory read, file creation and stream opening, and can be addressed from within scripts by URI. This makes it possible to load modules or open resources from any VFS (as network resources or compressed/crypted archives), which may include special virtual locations provided by third party modules and/or by applications embedding the engine.

Concurrency support

In versions 0.8.x, the separate Threading module provides full multithreading to scripts, while starting from version 0.9.x the "Threading" module is integrated in the standard modules and threading support
Concurrency (computer science)
In computer science, concurrency is a property of systems in which several computations are executing simultaneously, and potentially interacting with each other...

 is provided directly inside the main engine. The multithreading model is agent oriented, and data across threads must be explicitly shared through several possible sharing mechanisms. Each thread runs a different virtual machine, which runs separately from any operation happening in the others (as i.e. garbage collection
Garbage collection (computer science)
In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...

). This allows for efficient parallel processing and zero contention outside the control of the script developer.

Coroutines

Falcon supports quasi-parallel coroutining. Coroutine
Coroutine
Coroutines are computer program components that generalize subroutines to allow multiple entry points for suspending and resuming execution at certain locations...

s are code executed in time slices or during idle times by the Virtual Machine. They provide a lighter parallel approach than the full threading model and allow full visibility of program global data through different coroutines. Explicit cooperation of each coroutine is required, (i.e., each coroutine must check for data availability before blocking reads).

Metacompiler

The Falcon compiler contains a meta-compiler
Metacompiler
Metacompilers are a subset of a specialized class of compiler writing toolscalled compiler-compilers.The feature that sets a metacompiler apart from a standard compiler-compileris that a metacompiler is written in its own language and translates itself....

 that supports macro expansions. A Falcon Virtual Machine in the standard compiler drives the meta-compiler. Output generated from the meta-compiler is sent to the language lexer
Lexical analysis
In computer science, lexical analysis is the process of converting a sequence of characters into a sequence of tokens. A program or function which performs lexical analysis is called a lexical analyzer, lexer or scanner...

 as if part of the original source. Using escape sequences, it is possible to dynamically write the contents of the program being compiled by printing it:

\[ printl( "printl( 'Hello world' )" ) \]

The keyword macro provides a simplified candy-grammar interface to compile-time meta-programming.

Native internationalization

Strings prefixed with an 'i' are recognized as exported (international) strings
Internationalization and localization
In computing, internationalization and localization are means of adapting computer software to different languages, regional differences and technical requirements of a target market...

. Declaring the language used in a module through the directive statement, it is possible to indicate which is the native language in which strings are written, as in the following example:

directive lang=fr_FR // uses 5 characters ISO language code
ISO 639
ISO 639 is a set of standards by the International Organization for Standardization that is concerned with representation of names for language and language groups....



> i"Bonjour à tout le monde!"

A command line tool called fallc is provided to export 'i' strings into XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

 definition files, which can be used as templates to provide translation
Translation
Translation is the communication of the meaning of a source-language text by means of an equivalent target-language text. Whereas interpreting undoubtedly antedates writing, translation began only after the appearance of written literature; there exist partial translations of the Sumerian Epic of...

s into different languages.

The translated string table is applied to the modules at load time
Loader (computing)
In computing, a loader is the part of an operating system that is responsible for loading programs. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution...

.

Feathers standard library

Supporting modular programming
Modular programming
Modular programming is a software design technique that increases the extent to which software is composed of separate, interchangeable components called modules by breaking down program functions into modules, each of which accomplishes one function and contains everything necessary to accomplish...

, Falcon ships with Feathers, the standard module suite, which integrates the built-in core module, containing the basic I/O and language-integrated base functions, classes and objects.

Feather modules currently include:
  • Compiler
    Compiler
    A compiler is a computer program that transforms source code written in a programming language into another computer language...

     - Reflexive compiler and dynamic plugin loader
    Loader (computing)
    In computing, a loader is the part of an operating system that is responsible for loading programs. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution...

     module.
  • Configuration Parser - Complete configuration file
    Configuration file
    In computing, configuration files, or config files configure the initial settings for some computer programs. They are used for user applications, server processes and operating system settings. The files are often written in ASCII and line-oriented, with lines terminated by a newline or carriage...

     parser support.
  • DBI - Allows you to connect to various open source databases like MySql
    MySQL
    MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...

    , PostgreSQL
    PostgreSQL
    PostgreSQL, often simply Postgres, is an object-relational database management system available for many platforms including Linux, FreeBSD, Solaris, MS Windows and Mac OS X. It is released under the PostgreSQL License, which is an MIT-style license, and is thus free and open source software...

     and SQLite
    SQLite
    SQLite is an ACID-compliant embedded relational database management system contained in a relatively small C programming library. The source code for SQLite is in the public domain and implements most of the SQL standard...

    .
  • JSON
    JSON
    JSON , or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects...

     - Module converting Falcon data and objects to and from JavaScript Object Notation.
  • Logging - High performance parallel logging facility.
  • MXML - Very fast and simple Minimal XML
    XML
    Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

     parser (compatible with XML 1.0).
  • Process
    Process (computing)
    In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...

     - Interface to cross platform process support (start, kill, pipes...)
  • Regular Expressions
    Regular expression
    In computing, a regular expression provides a concise and flexible means for "matching" strings of text, such as particular characters, words, or patterns of characters. Abbreviations for "regular expression" include "regex" and "regexp"...

     - PCRE 7.x compatible
    Perl Compatible Regular Expression
    Perl Compatible Regular Expressions is a regular expression C library inspired by Perl's external interface, written by Philip Hazel. PCRE's syntax is much more powerful and flexible than either of the POSIX regular expression flavors and many classic regular expression libraries...

     regular expression library interface.
  • Socket - BSD sockets
    Internet socket
    In computer networking, an Internet socket or network socket is an endpoint of a bidirectional inter-process communication flow across an Internet Protocol-based computer network, such as the Internet....

     cross platform networking support.
  • Threading (since 0.9.0) - Multithreading structures support.
  • ZLib
    Zlib
    zlib is a software library used for data compression. zlib was written by Jean-Loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compression program. Zlib is also a crucial component of many software platforms including Linux, Mac OS X,...

     - Interface for simple compression routines.

Implementation

The core VM and official modules, (including Feather modules and other community provided support modules) are all written in C++. Some very low level module and engine elements are written in C and Assembly.

Supported platforms

Falcon is distributed through installers on Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

 and Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 systems (where building and installing is a more articulated process), or through self-building source packages on various open systems as Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 or OpenSolaris
OpenSolaris
OpenSolaris was an open source computer operating system based on Solaris created by Sun Microsystems. It was also the name of the project initiated by Sun to build a developer and user community around the software...

.

On the latter systems, Falcon is usually supported and generally kept up to date on various distributions, among which:
  • Ubuntu
    Ubuntu (operating system)
    Ubuntu is a computer operating system based on the Debian Linux distribution and distributed as free and open source software. It is named after the Southern African philosophy of Ubuntu...

  • Fedora
    Fedora (operating system)
    Fedora is a RPM-based, general purpose collection of software, including an operating system based on the Linux kernel, developed by the community-supported Fedora Project and sponsored by Red Hat...

  • Gentoo
    Gentoo Linux
    Gentoo Linux is a computer operating system built on top of the Linux kernel and based on the Portage package management system. It is distributed as free and open source software. Unlike a conventional software distribution, the user compiles the source code locally according to their chosen...

  • Slackware
    Slackware
    Slackware is a free and open source Linux-based operating system. It was one of the earliest operating systems to be built on top of the Linux kernel and is the oldest currently being maintained. Slackware was created by Patrick Volkerding of Slackware Linux, Inc. in 1993...

  • Arch Linux
    Arch Linux
    Arch Linux is an independently developed, Linux-based operating system for i686 and x86-64 computers. It is composed predominantly of free and open source software, and supports community involvement....

  • Mandriva
    Mandriva
    Mandriva S.A. is a publicly traded Linux and open source software company with its headquarters in Paris, France and development center in Curitiba, Brazil. Mandriva, S.A...

  • openSUSE
    OpenSUSE
    openSUSE is a general purpose operating system built on top of the Linux kernel, developed by the community-supported openSUSE Project and sponsored by SUSE...

  • SUSE Enterprise Linux
    SUSE Linux distributions
    SUSE Linux is a computer operating system. It is built on top of the open source Linux kernel and is distributed with system and application software from other open source projects. SUSE Linux is of German origin and mainly developed in Europe. The first version appeared in early 1994, making...



Falcon is available on Solaris based OS distributions through the Blastwave
Blastwave
Blastwave.org is a privately-held corporation specialized in building and supporting open source software packages for Oracle Solaris, as well as various operating system distributions based on OpenSolaris...

 project, and through the AuroraUX distribution of the DragonFly BSD
DragonFly BSD
DragonFly BSD is a free Unix-like operating system created as a fork of FreeBSD 4.8. Matthew Dillon, an Amiga developer in the late 1980s and early 1990s and a FreeBSD developer between 1994 and 2003, began work on DragonFly BSD in June 2003 and announced it on the FreeBSD mailing lists on July...

system.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK