# OpenEuphoria Manual

## Euphoria v4.1

routine or constant name search

| Up |  |  | TOC | Index
<< | < | Up: 1 Euphoria Programming Language v4.1 | 1.2 Introduction > | 2 Installing Euphoria >>

## 1.1 Quick Overview

Welcome to the Euphoria programming language!

Euphoria is a programming language with the following advantages over conventional languages:

Euphoric
  A remarkably simple, flexible, powerful language definition that is easy to learn and use.
Dynamic
  Variables grow or shrink without the programmer having to worry about allocating and freeing chunks of memory. Objects of any size can be assigned to an element of a Euphoria sequence (array).
Fast
  A high-performance, state-of-the-art interpreter that's significantly faster than conventional interpreters such as Perl and Python.
Compiles
  An optimizing Euphoria To C Translator, that can boost your speed even further, often by a factor of 2x to 5x versus the already-fast interpreter.
Safe
  Extensive run-time checking for: out-of-bounds subscripts, uninitialized variables, bad parameter values for library routines, illegal value assigned to a variable and many more. There are no mysterious machine exceptions--you will always get a full English description of any problem that occurs with your program at run-time, along with a call-stack trace-back and a dump of all of your variable values. Programs can be debugged quickly, easily and more thoroughly.
High level
  Features of the underlying hardware are completely hidden. Programs are not aware of word-lengths, underlying bit-level representation of values, byte-order etc.
Debugger
  A full-screen source debugger and an execution profiler are included.
Editor
  A full-screen, multi-file editor is also included. On a color monitor, the editor displays Euphoria programs in multiple colors, to highlight comments, reserved words, built-in functions, strings, and level of nesting of brackets. It optionally performs auto-completion of statements, saving you typing effort and reducing syntax errors. This editor is written in Euphoria, and the source code is provided to you without restrictions. You are free to modify it, add features, and redistribute it as you wish.
Multi-platform
  Euphoria programs run under Windows, Linux, OS/X, FreeBSD, NetBSD, OpenBSD and can be easily ported to any platform supporting GCC.
Stand-alone
  You can make a single, stand-alone executable file from your program.
Generic
  Euphoria routines are naturally generic. The example program below shows a single routine that will sort any type of data--integers, floating-point numbers, strings etc. Euphoria is not an "object-oriented" language, yet it achieves many of the benefits of these languages in a much simpler way.
Free
  Euphoria is completely free and open source.

    include std/console.e
    sequence original_list

    function merge_sort(sequence x)
    -- put x into ascending order using a recursive merge sort
        integer n, mid
        sequence merged, a, b

        n = length(x)
        if n = 0 or n = 1 then
            return x  -- trivial case
        end if

        mid = floor(n/2)
        a = merge_sort(x[1..mid])       -- sort first half of x
        b = merge_sort(x[mid+1..n])     -- sort second half of x

        -- merge the two sorted halves into one
        merged = {}
        while length(a) > 0 and length(b) > 0 do
            if compare(a[1], b[1]) < 0 then
                merged = append(merged, a[1])
                a = a[2..length(a)]
            else
                merged = append(merged, b[1])
                b = b[2..length(b)]
            end if
        end while
        return merged & a & b  -- merged data plus leftovers
    end function

    procedure print_sorted_list()
    -- generate sorted_list from original_list
        sequence sorted_list

        original_list = {19, 10, 23, 41, 84, 55, 98, 67, 76, 32}
        sorted_list = merge_sort(original_list)
        for i = 1 to length(sorted_list) do
        	display("Number [] was at position [:2], now at [:2]",
        	        {sorted_list[i], find(sorted_list[i], original_list), i}
        	    )
        end for
    end procedure

    print_sorted_list()     -- this command starts the program

Euphoria has come a long way since v1.0 was released in July 1993 by Rapid Deployment Software (RDS). There are now enthusiastic users around the world.

| Up |  |  | TOC | Index
<< | < | Up: 1 Euphoria Programming Language v4.1 | 1.2 Introduction > | 2 Installing Euphoria >>