Euphoria (programming language) 9647 221860615 2008-06-26T12:20:08Z BOTarate 5870361 robot Adding: [[es:EUPHORIA]] {{Infobox Software| name = <big>Euphoria</big> |caption = Euphoria |developer = Robert Craig |latest_release_version = 3.1.1 |latest_release_date = <small>[[August 22]], [[2007]]</small> |operating_system = [[Cross-platform]] [[DOS|DOS32]], [[Microsoft Windows|WIN32]], [[Linux]], [[FreeBSD]] |genre = [[Interpreted language]] |license = [http://www.rapideuphoria.com/License.txt License for latest release] |website = [http://www.rapideuphoria.com/ www.rapideuphoria.com] }} '''Euphoria''' is an [[interpreted programming language]] created by Robert Craig of Rapid Deployment Software. ==Introduction== {{Citations missing|section|date=November 2007}} Developed as a personal project to invent a programming language from scratch, Euphoria's first incarnation was created by Robert Craig on an Atari Mega-ST. It's named Euphoria as an acronym for "End-User Programming with Hierarchical Objects for Robust Interpreted Applications", although there is some suspicion that this is in fact a [[backronym]]. The first public incarnation of the language was for the 32-bit [[DOS]] platform and was released in July 1993. The original Atari version, to date, has not been released. As of the release of version 3.0.0 ([[October 17]], [[2006]]), it is [[Open Source Software | open source]]. Euphoria was developed with the following design goals: * Easier to learn and use than [[BASIC programming language|BASIC]] and with more-consistent high-level constructs * To use flat-form 32-bit memory to avoid complicated memory management and size/addressing limits * Debugging support and run-time error-handling * Subscript and [[Type system | type checking]] * Loose and strict variable typing * [[Object-oriented programming]] via objects as types, user-defined or otherwise * Interpreted, with automatic memory management and [[Garbage collection (computer science) | garbage collection]] With the release of version 2.5 the Euphoria interpreter was split into two sections: the front-end parser and the back-end interpreter. The front-end, open source, is now written in Euphoria instead of C. The front-end is also used with the Euphoria-to-C translator and the Binder. ==Features== * Heterogeneous collection types (sequences) * [[DOS]] graphics library * Debugger * Database system * Low-level memory handling * [[Windows API]] support * [[Common Gateway Interface | CGI programming]] ==Execution modes== * [[Interpreter (computing) | Interpreter]] * [[C (programming language) | C]] translator (E2C) for standalone executables or [[Library (computer science)#Dynamic linking|dynamic linking]] * [[Bytecode]] compiler and interpreter (Shrouder) * The Binder binds the Euphoria source code to the interpreter to create an executable. ==Use== Euphoria was 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. Also, Euphoria has been proven to be a useful [[Common Gateway Interface|CGI]] programming language: the [http://www.rapideuphoria.com/asearch.txt File Archive Search] is written in Euphoria, for example. ==Data types== Euphoria has two basic data types: ;atom : These are numbers, implemented as either 31-bit [[integer]] or 64-bit [[IEEE floating-point standard|IEEE floating-point]], depending on the current value. Euphoria dynamically changes the implementation to the most efficient one for the data item's current value. ;sequence : A [[Array|vector]] which can have zero or more elements, where each element can be either an '''atom''' or another '''sequence'''. The number of elements in a sequence is not fixed; the coder can add or remove elements as required during run-time. Memory allocation and deallocation is automatically handled by reference counting. Individual elements are referenced using an index value enclosed in square brackets. The first element in a sequence has an index of one [1]. Elements inside embedded sequences are referenced by additional bracked index values, thus X[3][2] refers to the second element contained in the sequence that is the third element of X. Additionally, Euphoria has two ''specialized'' data types: ;integer : A special form of '''atom''', restricted to 31-bit [[integer]] values in the range -1073741824 to 1073741823. '''Integer''' data types are more efficient than the '''atom''' data types, but cannot contain the same range of values. Characters are stored as integers, eg coding [[ASCII]]-'A' is exactly the same as coding 65. ;object : A generic datatype that can contain any of the above, and can be changed during run-time. This means that if you have an object called X that is assigned the value 3.172, then later on you can assign it the value "ABC". Note that in fact, each element of a '''sequence''' is actually an '''object'''. There is no character [[string (computer science)|string]] data type, as these are represented by a '''sequence''' of '''integer''' values. However, because literal strings are so commonly used in programming, Euphoria interprets double-quote enclosed characters as a sequence of integers. Thus <code>"ABC"</code> is seen as if the coder had written: <code>{'A', 'B', 'C'}</code> which is the same as: <code>{65,66,67}</code> ==Hello World== puts(1,"Hello World!\n") ==Examples== '''Note:''' Code comments start with a double dash "--" and go through the end of line. There are no multi-line comments. As brief examples, the following code global function delete_item( object old, sequence group ) integer pos -- Code begins -- pos = find( old, group ) if pos > 0 then group = group[1 .. pos-1] & group[pos+1 .. length( group )] end if return group end function looks for an old item in a group of items. If found, it removes it by concatenating all the elements prior to it with all the elements after it. The result is then returned. Note that elements in sequences are 1-based indexed. This means that the first element has an index of 1. Simplicity is apparent in that the code clearly delineates its 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 item 'old' 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. global function replace_item( object old, object new, sequence group ) integer pos -- Code begins -- pos = find( old, group ) if pos > 0 then group[pos] = new end if return group end function 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 allocate or deallocate memory explicitly, and no chance of a leak. The line <code>group = group[1 .. pos-1] & group[pos+1 .. length( group )]</code> shows some of the '''sequence''' handling facilities. A '''sequence''' can contain a collection of any types, and this can be sliced (to take a subset of the data in a '''sequence''') and concatenated in expressions, with no need for special functions. Version 2.5 introduces the new '$' symbol, which is used for "length(sequence)." So, the above example could be written in 2.5 as follows: <code>group = group[1 .. pos-1] & group[pos+1 .. $]</code> ==Parameter passing== Another feature is that all arguments to routines are always passed by value; there is no pass-by-reference facility. However, parameters are allowed to be modified ''locally'' (i.e. within the callee), which is implemented very efficiently as sequences have automatic [[copy-on-write]] semantics. In other words, when you pass a sequence to a routine, initially only a reference to it is passed, but at the point the routine modifies this sequence parameter, the sequence is copied and the routine updates only a copy of the original. ==Comparable Languages== * [[D programming language]] * [[Lua Programming Language]] * [[Python (programming language)|Python programming language]] * [[REBOL|Rebol - data exchange and programming language]] * [[Boxx]] ==External links== Free downloads of Euphoria for the various platforms, packages, Windows IDE, Windows API libraries, a GTK+ wrapper for Linux, graphics libraries (DOS, OpenGL, etc). * [http://www.rapideuphoria.com Euphoria website] * [http://www.juliepetrusa.com/Euphoria.htm Euphoria Article] * [http://www.rapideuphoria.com/contrib.htm User Contributions] * [http://www.rapideuphoria.com/othersit.htm User Web Sites] * [http://www.listfilter.com/EUforum EUforum Message Board] * [http://www.usingeuphoria.com/ Programming with Euphoria - includes using Euphoria for CGI] * [http://wxeuphoria.sourceforge.net/ wxEuphoria] * [http://www.axyp43.dsl.pipex.com/abgte.html A Beginners Guide To Euphoria] ===Commercial use of Euphoria=== * [http://www.nexusradio.com/ Nexus Radio] * [http://www.FormsOnADisk.com/ Forms On-A-Disk] [[Category:Object-oriented programming languages]] {{Link FA|pt}} [[cs:Euphoria (programovací jazyk)]] [[de:Euphoria (Programmiersprache)]] [[es:EUPHORIA]] [[gl:Euphoria]] [[nl:Euphoria]] [[pl:Euphoria]] [[pt:Euphoria (linguagem de programação)]]