The Falcon Programming Language in a Nutshell

Falcon is based on an open coding approach that seamlessly merges procedural, object-oriented, functional and message-oriented programming.

In late 2003, I had the problem of making business-critical
decisions and performing maintenance actions in real time, analyzing data
that was passing through the servers I was charged with controlling.
Data throughput was on the order of thousands of messages per second,
each of which was made of complex structures and possibly nested
maps, whose size was measured in kilobytes.

The applications in charge of those controls were already almost complete,
and they were heavily multithreaded by design. The only thing missing
was the logic-processing engine. That would have been the perfect job
for a scripting language, but the memory, CPU, threading,
responsiveness and safety constraints seemed to be a hard match.

After testing the available solutions, I decided to try to solve the
problem by writing a scripting language from the ground up, taking into
consideration those design constraints. After the decision was made to
move forward, useful items commonly found missing from other scripting
languages were added to the design specification. So, Falcon
mainly was designed from the beginning to meet the following requirements:

Rapidly exchange (or use directly) complex data with C++.

Play nice with applications (especially with MT applications) and
provide them with ways to control the script execution dynamically.

Provide several programming paradigms under the shroud of simple,
common grammar.

As soon as I was able to script the applications that drove the
initial development and meet these ambitious targets in terms of
overall performance, I realized that Falcon may be something
useful and interesting for others also, so I went open source.

The project is now reaching its final beta release phase, and Falcon
has become both a standalone scripting language and a scripting
engine that can drive even the most demanding applications.

The Falcon programming language now is included with many high-profile
distributions, including Fedora, Ubuntu, Slackware, Gentoo and others.
If your distribution doesn't include it yet, you can download it from
www.falconpl.org, along with user and developer documentation.

Falcon currently is ported for Linux (32- and 64-bit), Win32 and Solaris
(Intel). Older versions work on Mac OS X and FreeBSD. We are porting the
newer version shortly, and a SPARC port also should be ready
soon.

The Language

Falcon is an untyped language with EOL-separated statements and code
structured into statement/end blocks. It supports integer math (64-bit)
natively, including bit-field operators, floating-point math,
string arrays, several types of dictionaries, lists and MemBuffers
(shared memory areas), among other base types and system classes.

You can run this script by saving it in a test file and feeding it
into Falcon via stdin, or by launching it like this:

$ falcon <scriptname.fal> [parameters]

We place great emphasis on the multiparadigm model. Falcon is based
on an open coding approach that seamlessly merges procedural,
object-oriented, functional and message-oriented programming. We're also
adding tabular programming, sort of a multilayer OOP, but we don't
have the space to discuss that here. Each paradigm we support is
generally a bit “personalized” to allow for more comfortable programming
and easier mingling with other paradigms.

Falcon Procedural Programming

Falcon procedural programming is based on function declaration and
variable parameters calls. For example:

function checkParameters( first, second, third )
> "------ checkParameters -------"
// ">" at line start is a short for printl
if first
> "First parameter: ", first
end
// ... and single line statements
// can be shortened with ":"
if second: > "Second parameter: ", second
if third: > "Third parameter: ", third
> "------------------------------"
end
// Main script:
checkParameters( "a" )
checkParameters( "b", 10 )
checkParameters( "c", 5.2, 0xFF )

You can use RTL functions to retrieve the actual parameters passed to
functions (or methods). Values also can be passed by reference (or
alias), and functions can have static blocks and variables:

Notice the string expansion operator in the above code. Falcon
provides string expansion via naming variables and expressions and
applying an explicit @ unary operator. String expansions can contain
format specifiers, like @ "$(varname:r5)", which
right-justifies in five
spaces, but a Format class also is provided to cache and use
repeated formats.

Both user-defined collections and language sequences provide iterators
that can be used to access the list traditionally. Functional
operators such as map, filter and reduce also are provided.

Trending Topics

Webinar: 8 Signs You’re Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th

Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.