Euphoria (programming language)

Last updated
Euphoria
OpenEuphoria logo.png
Paradigm Imperative, procedural
Designed by Jeremy Cowgar, Robert Craig (original), Matt Lewis, Derek Parnell
Developer openEuphoria Group
First appeared1993;29 years ago (1993)
Stable release
4.1.0 / March 1, 2021;16 months ago (2021-03-01)
Typing discipline static, dynamic
OS Cross-platform: Win32, Linux, macOS, FreeBSD, NetBSD, OpenBSD
License BSD
Filename extensions .e, .ex, .exw, .edb
Website openeuphoria.org
Influenced by
BASIC
Influenced
Phix

Euphoria is a programming language created by Robert Craig of Rapid Deployment Software [1] in Toronto, Ontario, Canada. Initially developed (though not publicly released) on the Atari ST, [2] the first commercial release [3] was for MS-DOS as proprietary software. In 2006, with the release of version 3, [4] Euphoria became open-source software. The openEuphoria Group continues to administer and develop the project. [5] In December 2010, the openEuphoria Group released version 4 [6] of openEuphoria along with a new identity and mascot for the project. OpenEuphoria is currently available for Windows, Linux, macOS and three flavors of *BSD.

Contents

Euphoria is a general-purpose high-level imperative-procedural interpreted language. A translator generates C source code and the GNU compiler collection (GCC) and Open Watcom compilers are supported. Alternatively, Euphoria programs may be bound [7] with the interpreter to create stand-alone executables. A number of graphical user interface (GUI) libraries are supported including Win32lib [8] and wrappers for wxWidgets, [9] GTK+ [10] and IUP. [11] Euphoria has a simple built-in database [12] and wrappers for a variety of other databases. [13]

Overview

The Euphoria language is a general purpose procedural language that focuses on simplicity, legibility, rapid development and performance via several means.

History

Developed as a personal project to invent a programming language from scratch, Euphoria was created by Robert Craig [1] on an Atari Mega-ST. [2] Many design ideas for the language came from Craig's Master's thesis in computer science at the University of Toronto. [14] Craig's thesis was heavily influenced by the work of John Backus on functional programming (FP) languages. [14]

Craig ported his original Atari implementation to the 16-bit DOS platform and Euphoria was first released, version 1.0, in July 1993 [3] under a proprietary licence. The original Atari implementation is described by Craig as "primitive" [15] and has not been publicly released. Euphoria continued to be developed and released by Craig via his company Rapid Deployment Software (RDS) and website rapideuphoria.com. [1] In October 2006 RDS released version 3 [4] of Euphoria and announced that henceforth Euphoria would be freely distributed under an open-source software licence.

RDS continued to develop Euphoria, culminating with the release of version 3.1.1 in August, 2007. [14] [16] Subsequently, RDS ceased unilateral development of Euphoria and the openEuphoria Group [5] took over ongoing development. The openEuphoria Group released version 4 in December, 2010 [17] along with a new logo and mascot for the openEuphoria project.

Version 3.1.1 remains an important milestone release, being the last version of Euphoria which supports the DOS platform. [18]

Euphoria is an acronym for End-User Programming with Hierarchical Objects for Robust Interpreted Applications although there is some suspicion that this is a backronym.[ according to whom? ]

The Euphoria interpreter was originally written in C. With the release of version 2.5 [14] in November 2004 the Euphoria interpreter was split into two parts: a front-end parser, and a back-end interpreter. The front-end is now written in Euphoria (and used with the Euphoria-to-C translator and the Binder). The main back-end and run time library are written in C.

Features

Euphoria was conceived and developed with the following design goals and features:

Execution modes

Use

Euphoria is designed to readily facilitate handling of dynamic sets of data of varying types and is particularly useful for string and image processing. Euphoria has been used in artificial intelligence experiments, the study of mathematics, for teaching programming, and to implement fonts involving thousands of characters.[ citation needed ] A large part of the Euphoria interpreter is written in Euphoria.

Data types

Euphoria has two basic data types:

Atom – A number, implemented as a 31-bit signed integer or a 64-bit IEEE floating-point. Euphoria dynamically changes between integer and floating point representation according to the current value.
Sequence – A vector (array) with zero or more elements. Each element may be an atom or another sequence. The number of elements in a sequence is not fixed (i.e., the size of the vector/array does not have to be declared). The program may add or remove elements as needed during run-time. Memory allocation-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. Each element of a sequence is an object type (see below).

Euphoria has two additional data types predefined:

Integer – An atom, restricted to 31-bit signed integer values in the range -1073741824 to 1073741823 (-2^30 to 2^30-1). Integer data types are more efficient than the atom data types, but cannot contain the same range of values. Characters are stored as integers, e.g., coding ASCII-'A' is exactly the same as coding 65.
Object – A generic datatype which may contain any of the above (i.e., atom, sequence or integer) and which may be changed to another type during run-time.

There is no character string data type. Strings 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

"ABC"

is seen as if the coder had written:

{'A', 'B', 'C'}

which is the same as:

{65, 66, 67}

Hello, World!

puts(1, "Hello, World!\n")

Examples

Program comments start with a double hyphen -- and go through the end of line.

The following code looks for an old item in a group of items. If found, it removes it by concatenating all the elements before it with all the elements after it. Note that the first element in a sequence has the index one [1] and that $ refers to the length (i.e., total number of elements) of the sequence.

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 .. $]     end if     return group end function

The following modification to the above example replaces an old item with a new item. As the variables old and new have been defined as objects, they could be atoms or sequences. Type checking is not needed as the function will work with any sequence of data of any type and needs 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

Furthermore, no pointers are involved and subscripts are automatically checked. Thus the function cannot access memory out-of-bounds. There is no need to allocate or deallocate memory explicitly and no chance of a memory leak.

The line

group = group[1 .. pos-1] & group[pos+1 .. $]

shows some of the sequence handling facilities. A sequence may contain a set 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.

Parameter passing

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

Related Research Articles

C (programming language) General-purpose programming language

C is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, protocol stacks, though decreasingly for application software, and is common in computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.

Erlang (programming language) Programming language

Erlang is a general-purpose, concurrent, functional programming language, and a garbage-collected runtime system. The term Erlang is used interchangeably with Erlang/OTP, or Open Telecom Platform (OTP), which consists of the Erlang runtime system, several ready-to-use components (OTP) mainly written in Erlang, and a set of design principles for Erlang programs.

In computer science, an integer is a datum of integral data type, a data type that represents some range of mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values. Integers are commonly represented in a computer as a group of binary digits (bits). The size of the grouping varies so the set of integer sizes available varies between different types of computers. Computer hardware nearly always provides a way to represent a processor register or memory address as an integer.

Java virtual machine Virtual machine

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation. Having a specification ensures interoperability of Java programs across different implementations so that program authors using the Java Development Kit (JDK) need not worry about idiosyncrasies of the underlying hardware platform.

Lisp (programming language) Programming language family

Lisp is a family of programming languages with a long history and a distinctive, fully parenthesized prefix notation. Originally specified in 1958, Lisp is the second-oldest high-level programming language still in common use. Only Fortran is older, by one year. Lisp has changed since its early days, and many dialects have existed over its history. Today, the best-known general-purpose Lisp dialects are Racket, Common Lisp, Scheme, and Clojure.

Pascal (programming language) Programming language

Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named in honour of the French mathematician, philosopher and physicist Blaise Pascal.

Python (programming language) General-purpose programming language

Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.

PHP Scripting language created in 1994

PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994. The PHP reference implementation is now produced by The PHP Group. PHP originally stood for Personal Home Page, but it now stands for the recursive initialism PHP: Hypertext Preprocessor.

OCaml is a general-purpose, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy, Ascánder Suárez, and others.

Interpreter (computing) Program that executes source code without a separate compilation step

In computer science, an interpreter is a computer program that directly executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. An interpreter generally uses one of the following strategies for program execution:

  1. Parse the source code and perform its behavior directly;
  2. Translate source code into some efficient intermediate representation or object code and immediately execute that;
  3. Explicitly execute stored precompiled bytecode made by a compiler and matched with the interpreter Virtual Machine.

Abstract Syntax Notation One (ASN.1) is a standard interface description language for defining data structures that can be serialized and deserialized in a cross-platform way. It is broadly used in telecommunications and computer networking, and especially in cryptography.

Data type Attribute of data

In computer science and computer programming, a data type or simply type is an attribute of data which tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support basic data types of integer numbers, floating-point numbers, characters and Booleans. A data type constrains the possible values that an expression, such as a variable or a function, might take. This data type defines the operations that can be done on the data, the meaning of the data, and the way values of that type can be stored.

Delphi (software) General-purpose programming language and a software product

Delphi is a general-purpose programming language and a software product that uses the Delphi dialect of the Object Pascal programming language and provides an integrated development environment (IDE) for rapid application development of desktop, mobile, web, and console software, currently developed and maintained by Embarcadero Technologies.

BASIC-PLUS is an extended dialect of the BASIC programming language that was developed by Digital Equipment Corporation (DEC) for use on its RSTS/E time-sharing operating system for the PDP-11 series of 16-bit minicomputers in the early 1970s through the 1980s.

C Sharp (programming language) Multi-paradigm (object-oriented) programming language

C# is a general-purpose, multi-paradigm programming language. C# encompasses static typing, strong typing, lexically scoped, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines.

S-algol is a computer programming language derivative of ALGOL 60 developed at the University of St Andrews in 1979 by Ron Morrison and Tony Davie. The language is a modification of ALGOL to contain orthogonal data types that Morrison created for his PhD thesis. Morrison would go on to become professor at the university and head of the department of computer science. The S-algol language was used for teaching at the university at an undergraduate level until 1999. It was also the language taught for several years in the 1980s at a local school in St. Andrews, Madras College. The computer science text Recursive Descent Compiling describes a recursive descent compiler for S-algol, implemented in S-algol.

OpenLisp

OpenLisp is a programming language in the Lisp family developed by Christian Jullien from Eligis. It conforms to the international standard for ISLISP published jointly by the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC), ISO/IEC 13816:1997(E), revised to ISO/IEC 13816:2007(E).

Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community. First released in 2014, Swift was developed as a replacement for Apple's earlier programming language Objective-C, as Objective-C had been largely unchanged since the early 1980s and lacked modern language features. Swift works with Apple's Cocoa and Cocoa Touch frameworks, and a key aspect of Swift's design was the ability to interoperate with the huge body of existing Objective-C code developed for Apple products over the previous decades. It was built with the open source LLVM compiler framework and has been included in Xcode since version 6, released in 2014. On Apple platforms, it uses the Objective-C runtime library, which allows C, Objective-C, C++ and Swift code to run within one program.

This glossary of computer science is a list of definitions of terms and concepts used in computer science, its sub-disciplines, and related fields, including terms relevant to software, data science, and computer programming.

BASIC interpreter Interpreter that enables users to enter and run programs in the BASIC language

A BASIC interpreter is an interpreter that enables users to enter and run programs in the BASIC language and was, for the first part of the microcomputer era, the default application that computers would launch. Users were expected to use the BASIC interpreter to type in programs or to load programs from storage.

References

  1. 1 2 3 "RapidEuphoria homepage". Archived from the original on 2012-07-11. Retrieved 2010-12-30.
  2. 1 2 "RapidEuphoria forum, 2002-09-10 by Robert Craig". Archived from the original on 2011-07-16. Retrieved 2010-12-30.
  3. 1 2 "RapidEuphoria forum, 2006-10-18 16:44 by Robert Craig". Archived from the original on 2011-07-16. Retrieved 2010-12-30.
  4. 1 2 "RapidEuphoria forum, 2006-10-18 1:19 by Robert Craig". Archived from the original on 2011-07-16. Retrieved 2010-12-30.
  5. 1 2 "openEuphoria group homepage" . Retrieved 2010-12-30.
  6. "openEuphoria download page" . Retrieved 2010-12-30.
  7. 1 2 3 "openEuhporia manual, Binding and Shrouding" . Retrieved 2011-01-07.
  8. "Euphoria Win32Lib project at Sourceforge" . Retrieved 2010-12-30.
  9. "Euphoria wxEuphoria project at Sourceforge" . Retrieved 2010-12-30.
  10. "Euphoria GTK+ project at Sourceforge" . Retrieved 2010-12-30.
  11. "Euphoria IUP Project by Jeremy Cowgar" . Retrieved 2010-12-30.
  12. "openEuphoria manual, Database" . Retrieved 2010-12-30.
  13. "openEuphoria wiki, Database Interfaces" . Retrieved 2011-01-02.
  14. 1 2 3 4 "RapidEuphoria website, release notes". Archived from the original on 2012-07-14. Retrieved 2010-12-30.
  15. "RapidEuphoria forum, 2 Mar 1998 13:04 by Robert Craig". Archived from the original on 2011-07-16. Retrieved 2010-12-30.
  16. "RapidEuphoria news". Archived from the original on 2010-12-16. Retrieved 2010-12-30.
  17. "openEuphoria release notes". Archived from the original on 2011-07-27. Retrieved 2010-12-30.
  18. "openEuhporia manual, Platform Specific Issues" . Retrieved 2010-12-30.
  19. "openEuphoria roadmap" . Retrieved 2010-12-30.

Free downloads of Euphoria for the various platforms, packages, Windows IDE, Windows API libraries, a cross-platform GTK3 wrapper for Linux and Windows, graphics libraries (DOS, OpenGL, etc.).