Wednesday, February 6, 2013

Euphoria

I am a software engineer and I enjoy using a variety of languages for my work and my play. Some of my favorites are the old-time imperative languages like Fortran or Pascal or even BASIC (extended versions). I also enjoy some functional languages, like IO, and "almost" OO languages like Ada and C++. I say almost because they don't REALLY fit the bill as true OO languages, but have OO features.

I also enjoy byte interpreted languages like Python, Groovy, and a few others... but perhaps my favorite language that embraces the imperative with the interpreted is Euphoria. There are two flavors of Euphoria available: original and opensource-continued. The original version of Euphoria is simplicity itself, lacking many advanced features. It ended at version 3.1 when the creator of the (commercial) language open sourced it. The open version of the language at 4.x now, has added some more modern features to the language but they are also doing their best to maintain a level of simplicity by maintaining the core of the language which consists of two basic data types, the atom and the sequence.

An atom is basically a numeric value. A sequence is a group of atoms or other sequences.

Some Atoms:

1
3.14
'A' (or the numeric value 65... it becomes a letter when you output it using something like puts())

Some Sequences:

{1}
{1, 2, {'3', '4'}, 5}
{'A', 'B', 'C'} which is the same as "ABC", a string is a sequence.

In addition to the two data types two other variable containers are defined: integer and object.

An integer is an atom that is limited in its nature to an unsigned numeric value. An object can be whatever you assign to it. For example:

object my_var

my_var = 1
my_var = "this is acceptable too"
my_var = {2.1, 'V', "something else"}

With these simple data types you can create just about anything you can think of.

Another fine feature of Euphoria is that it has in-built vector processing for sequences. Some more examples:

{1, 2, 3} + {4, 5, 6} => {5, 7, 9}
{1, 2, 3} + 1 => {2, 3, 4}

You can add/subtract/etc. two sequences with the same number of items, or a sequence with an atom.

It is a fun and fast language. The original version was estimated to execute 6 times faster than the equivalent java code. It is not the most popular language but there is a small following and a variety of packages have been and continue to be created by the fans of Euphoria.

Check out:

The original website (v3.1) http://www.rapideuphoria.com/
The open source version (4.0.5) http://openeuphoria.org/index.wc

Enjoy.

No comments: