The Falcon Programming Language in a Nutshell
A Falcon script can define classes and instantiate objects from them, create singleton objects (with or without base classes) and apply transversal attributes to the instances. The provides keyword checks for properties being exposed by the instances:
// A class
class Something( initval1, initval2 )
// Simple initialization can be done directly
prop1 = initval1
prop2 = nil
// init takes the parameters of the class
// and performs more complex initialization
init
self.prop2 = initval
> "Initializer of class Something"
end
function showMe()
> "Something says: ", self.prop1, "; ", self.prop2
end
end
// A singleton instance.
object Alone
function whoAmI()
> "I am alone"
end
end
// an instance
instance = Something( "one", "two" )
instance.showMe()
//"Alone" is already an instance
if Alone provides whoAmI
Alone.whoAmI()
end
Falcon has a Basic Object Model (BOM), which is available in all the items. Objects and classes can override some methods. For example, passing an item to the > print operator causes its toString BOM method to be called, and that can be overridden as follows:
object different
function toString()
return "is different..."
end
end
> "the object... ", different
Falcon supports multiple inheritance, but it disambiguates it by forcing inheritance initialization and priority, depending on the order of the inheritance declarations.
Classes also support static members that can be shared between objects of the same class and methods with static blocks that can work as class-wide initializers. Methods can be retrieved and also called directly from classes when they don't need to access the self object, providing the semantic of C++/Java/C# static methods.
It is possible to merge normal procedures with methods by assigning procedures to properties:
function call_me()
if self and self provides my_name
> self.my_name
else
> "Sorry, you didn't call me right."
end
end
object test
prop1 = nil
my_name = "I am a test!"
function hello()
> "Hello world from ", self.my_name
end
end
// normal calls
call_me()
// using the procedure as a method
test.prop1 = call_me
test.prop1()
// or a method as a procedure
proc = test.hello
test.my_name = "a renamed thing"
// see: proc will dynamically use the right "self"
proc()
Attributes are binary properties that can be either present or not present for a specific instance or object, regardless of its class.
Attributes have a great expressive power, and in Falcon, they indicate what an object is, what it has and what it belongs to, depending on the context. For example, we can define a ready attribute that indicates the objects ready for elaboration:
// declaring an attribute "ready"
attributes: ready
class Data( name )
name = name
function process()
> "Processing ", self.name, "..."
end
end
// create 10 processors
processors = []
for i in [0:10]
processors += Data(i)
if i > 5: give ready to processors[i]
end
// work with the ready ones
for d in ready
d.process()
end
RTL provides several functions to manipulate attributes.
The has and hasnt operators check for the presence of an attribute. For example:
attributes: ready class SomeClass //... other class data ... // born ready! has ready end item = SomeClass() if item has ready > "Item was born ready!" end
The base construct of Falcon functional programming is the callable sequence, also known as Sigma. At the moment, the only sequence supported is the array, but other types of sequences (such as lists) should be supported soon.
Basically, a Sigma is a delayed call that can work like this:
function test( a, b, c ) > "Parameters:" > a > b > c end // direct test( "one", "two", "three" ) // indirect cached = [ test, "four", "five", "six" ] cached()
The call respects the procedural paradigm (variable parameters), and the array is still a normal vector that can be accessed and modified through the standard language operators and RTL functions.
This delayed call is still not a full “functional context evaluation”. The proper functional evaluation process is called Sigma reduction. It recursively resolves Sigmas from inner to outer and left to right when they are at the same level, substituting them with their return value.
Special functions known by the VM as Etas start and control functional evaluation; the simplest Eta function is eval(), which initializes and performs a basic Sigma reduction.
For example, the expression “(a+b) * (c+d)” can be written in a Lisp-like sequence:
function add( a, b ): return a+b function mul( a, b ): return a*b > "(2+3)*(4+5)= ", eval(.[mul .[add 2 3] .[add 4 5]])
The .[] notation is shorthand for array declarations whose elements are separated by white space instead of an explicit “,”.
Falcon RTL comes with a rich set of Etas, such as iff (functional if), cascade (which joins more standard calls in a single sequence), floop and times (different styles of functional loops), map, filter, reduce and many others.
Functional sequences can be parameterized through closure and references. For example, the above example can be made parametric in this way:
// add and mul as before... function evaluator( a, b, c, d ) return .[eval .[mul .[add a b] .[add c d]]] end tor = evaluator( 2,3,4,5 ) > "(2+3)*(4+5)= ", tor()
Traditional functional operators, such as map, filter and reduce, are supported, but the out-of-band item system expands their functionality.
Out-of-band items are items marked with a special flag through the oob() function. Although they are normal items in every other aspect, this special mark indicates that they hold unexpected, special or somehow extraordinary value traveling through functional sequences. Although this is not a direct support for monadic calculus, monads can be implemented at the script (or binary module) level through this mechanism.
Falcon also supports Lambda expressions and nested functions.
We currently are working on some extensions to make Sigmas even more configurable—for example, parameter naming (similar to Lisp field naming) and access from the outside to the unbound variables used in the sequence.
Falcon functional programming merges with OOP, as Sigmas can be set as object properties, and object methods can be used as Kappas (Sigma-callable header symbols):
object SomeObj
a_property = 10
function myProp( value )
return self.a_property * value
end
end
> "5*10=", eval( .[SomeObj.myProp 5] )
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Home, My Backup Data Center
- Readers' Choice Awards
- What's the tweeting protocol?
- New Products
- RSS Feeds
- Dart: a New Web Programming Experience
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




8 hours 2 min ago
10 hours 34 min ago
11 hours 52 min ago
12 hours 27 min ago
12 hours 49 min ago
17 hours 37 min ago
18 hours 24 min ago
19 hours 58 min ago
21 hours 35 min ago
23 hours 33 min ago