Encyclopedia > Euphoria programming language

  Article Content

Euphoria programming language

Euphoria is a PC programming language created with the following design goals:
  1. Simplicity - To be easier to learn and use than BASIC, with more-consistent high-level constructs. Uses flat-form 32-bit memory to avoid complicated memory management and size/addressing limits.
  2. Power - To provide low-level capabilities needed to access the OS and BIOS for professional development, but be more structured and less terse than a low-level language, making low-level programming less dangerous.
  3. Safety - Extensive debugging support and run-time error-handling; automatic subscript checking, type-checking, and memory handling.
  4. Flexibility - User-defined type support, with variables as loosely or strictly typed as desired. Object-oriented programming can be accomplished by defining objects as types (subsets of the sequence, which is a general-purpose collection).
  5. Ease of Development - Interpreted, with automatic memory management and garbage collection.
  6. Speed - To be fast enough to rival compiled languages for usefulness, despite being an interpreted language

The name Euphoria is an acronym for 'End-User Programming with Hierarchical Objects for Robust Interpreted Applications'. It was originally released in July 1993 by Robert Craig (Rapid Deployment Software (http://www.rapideuphoria.com)) for the DOS operating system. Current versions support 32-bit DOS, Windows, and Linux. There is also a translator to convert Euphoria code into C for compilation to native machine code.

Euphoria is primarily used by hobbyists for utility and computer game programming, but has proven useful for fairly diverse purposes. The primary strength seems to be the ease of handling dynamic collections of data of various types, most useful when dealing with string processing and image processing, which can be quite difficult in many languages. It has been used in artificial intelligence experiments, the study of mathematics, for teaching programming, and to implement fonts involving thousands of characters.

As a brief example, the following code

global function replace( object old, object new, sequence group )
    old = find( old, group )
    if old then
        group = group[1..old - 1] & new & group[old + 1..length( group )]
    end if
    return( group )
end function
looks for an old item in a group of items. If found, it replaces it with a new item. The group is then returned.

Simplicity is apparent in that the code clearly delineates it's constructs with words. Instead of braces, semicolons, and question marks, you see phrases like 'if..then', 'end if', and 'end function'.

Flexibility is present; the items 'old' and 'new' could be strings, numbers, images, or whole collections of data themselves. A different function for each data type isn't needed, nor does the programmer have to check the data types. This function will work with any sequence of data of any type, and requires no external libraries.

Safety is present due to the fact that there are no pointers involved and subscripts are automatically checked. Thus the function cannot access memory out-of-bounds, and cannot go beyond the end of the sequence or before the beginning of it to corrupt the memory. There is no need to explicitly allocate or deallocate memory, and no chance of a leak.

The line group = group[1..old - 1] & new & group[old + 1..length( group )] shows some of the collection handling facilities. Collections of any type can be sliced ('slice' means to take a subset of the data in a collection) and concatenated in expressions, with no need for special functions.

Compare with:

External link

All Wikipedia text is available under the terms of the GNU Free Documentation License

  Search Encyclopedia

Search over one million articles, find something about almost anything!
  Featured Article

... Current orders for the participating nations are 232 for the United Kingdom, 180 for Germany, 121 for Italy, and 87 for Spain. An extensive overseas sales effort ...

This page was created in 67.7 ms