F.E.L.T.

Functionally Equivalent Language Translation

FELT -- A Hackers Guide!

Welcome fellow FELT hacker-to-be. In the following sections you will see how the single syntax rule is used to make FELT very simple to code. This uniformity of syntax means you will soon be writing language neutral code provided you "follow da rules!". There aren't many rules and they are mainly to do with things that FELT has no control over, such as determining what functions are available at run-time and how you can account for this and either factor your code into multiple files or use the #F:WHEN instruction for smaller scripts that you want to keep to a single file.

A quick recap; as easy as (ONE 2 "3!")

As stated before, there is one syntax "shape" to learn and here it is as FELT code:

(FELT-INSTRUCTION ARG1 ARG2 ... ARGn)

And in English just in case you need it spell-ed out to you:

ALL FELT instructions consist of an opening parenthetical, "(", followed by the name of an instruction, followed by any parameters that the instruction either insists on having or optional ones, finally terminated by a closing parenthetical, ")". There are no exceptions to this rule.

Hello World

I guess the simplest example would be the all-time classic "Hello World" program. Here is the FELT equivalent:

(emit "Hello, World!")

Here we are using the EMIT (o>) function to render some output to "stdout" and passing it the single string "Hello, World!".

You can see the pattern; ( followed by EMIT, followed by the string and finally the closing ). Just like we said it would be. Now it gets interesting, even at this stage...unlike most programming language tutorials however, we can't run this directly because FELT code cannot be run! First we have to translate it into a "real" language. I am slowly beginning to liken FELT to the "superposition of all languages" such that a FELT program represents the "wave-collapse" function before it collapses; it can be any language provided the correct "observation" is made of it. That is, a specific back-end coder "observes" the FELT source and collapses it into PHP, or JavaScript or Node.js. Wow. Quick, inhale and exhale again just to make sure this is real!

So... let's run that example through PHP and JavaScript "observers" and see what comes out.

Hello World as PHP

echo "Hello, World!";

Hello World as Node.js

console.log("Hello, World!");

Stepping it up

We've seen how to make a single function call, now here are some examples that show some of the different instructions in action, and notice the same consistent form:

(defvar name "Emacs The Viking")  ;; assign a string to a variable
(const PI 3.14159)                ;; define a constant, I like PI ;)
(file-get-contents "config.ini")  ;; load the config file
(sprintf "%s/%s" folder file)     ;; create a file path

Of course, the above only make sense in a PHP environment as JavsScript doesn't have file-get-contents or sprintf unless you make them available at run-time. That's one thing that FELT cannot do and probably will never be able to do; translate one 'standard' library function for one language into an equivalent 'standard' library function in another language.