Rapid Euphoria 3.1.1

    The Euphoria Programming Language version 3.1.1 - A programming language that's powerful, easy to learn, free, and a lot more fun than other languages - for Windows, DOS, Linux, FreeBSD and more. Download it, and join a fun community.

You are not logged in.

#1 2019-06-24 15:49:30

Administrator / Администратор

Hello World!

with trace

-- Tutorial - Print Hello World on the Screen

-- To run this tutorial,
--        Press Enter to execute the highlighted Euphoria statement.
--        Press F1 to flip to the main output screen.
--        Press F2 to flip back to this trace screen.
--        Read the comments as you go.

-- Step 1: Just to be neat - we'll clear the screen.
-- First, press F1 then F2.
-- Then press Enter:

-- Check again with F1/F2 - was the screen cleared?

-- Step 2: Let's position the cursor at line 10, column 30
position(10, 30)
-- Is the cursor now at 10,30? Press F1/F2

-- Step 3: Display the text:
puts(1, "Welcome to Rapid Euphoria 3.1.1 Forum!") 
-- Is the text there? Press F1/F2

-- Step 4 Output 2 blank lines and we're done
puts(1, "\n\n")


#2 2019-08-15 17:46:40

Administrator / Администратор

Re: Hello World!

Is Rapid Euphoria truly simpler then BASIC?

Let's see just one aspect of it. How would you declare and initialize the same variables in QuickBASIC and in Rapid Euphoria:

Few examples in QuickBASIC 4.5 (typical to many other languages):


DIM Bytes(3)

' Define a record structure for random-file records:
TYPE StockItem
   PartNumber  AS STRING * 6
   Description AS STRING * 20
   UnitPrice   AS SINGLE
   Quantity    AS INTEGER

' Define a record structure for each element of the index:
TYPE IndexType
   RecordNumber AS INTEGER
   PartNumber   AS STRING * 6

DIM StockRecord AS StockItem, Index(1 TO 100) AS IndexType

SHARED Index() AS IndexType, NumberOfRecords

In Euphoria we will declare and initialize all of the above like this:

sequence  TabStops, Bytes, StockRecord, Index   -- declaring
integer     NumberOfRecords

-- initializing
TabStops = {}
Bytes = {}
StockRecord = {}
Index = {}
NumberOfRecords = 0

-- We don't have to declare & initialize specific size and structure 
-- in Euphoria, since variables in Euphoria are dynamic, and can hold
-- arbitrarily any value, at any given time, yet we can initialize
-- space if we need to, like this:

-- initializing with space (QuickBASIC's structure is just a sub-sequence in Euphoria)
TabStops = repeat(0, MAXLINE)
Bytes      = repeat(0, 3)
Index      = repeat(0, 100)

Conclusion: Euphoria has a far more simple and powerful way to use variables, and that's just one aspect of Euphoria's simplicity.


#3 2019-08-16 09:53:30

Administrator / Администратор

Re: Hello World!

Are Euphoria dynamic variables safe to use?

Isn't it more safe to enforce a more specific type of variable just like we do in BASIC and other languages?

The answer is that Euphoria is much safer then other programming languages, because Euphoria provides a special function called 'type'. The 'type' function can enforce, at run time, just about any limitation on a variable, in a much more precise and practical way then in other programming languages, for example:

-- a version of signed_byte() type for atoms only:

type signed_byte(integer i)
    return i >= -128 and i <= 127
end type

-- a version of signed_byte() type for atoms and sequences (any object),
-- this is a compact code style...:

type signed_byte(object x)
    return equal(x >= -128 and x <= 127, is_int(x)) 
end type

-- declare a signed byte variable:

signed_byte b

-- use a signed byte as an argument to a function:

function do_something(signed_byte b1, signed_byte b2)
   -- do something...
end function

In Euphoria there are no limits for creating any "type" of variable, which makes it far more safer then other languages.

Last edited by shian (2019-08-22 06:43:44)


#4 2019-08-17 09:40:12

Administrator / Администратор

Re: Hello World!

Is it true??? Euphoria does not have a built in "string" type yikes ???

Yea, it's true.
Euphoria 3.1.1 does not have or need a "string" type at all. It is designed to handle strings as any other sequence of 32-bit integers (which makes it suitable, by the way, for supporting UTF-8/Unicode strings out-of-the-box).

But if you cannot live, at the moment, without a "string" type, please download and install Lib2, by shian, from the "Download" page.

To use a string type, include the file "machine2.e":

include machine2.e

To use traditional string functions (such as "left", "mid", etc), include the file "string.e":

include string.e

To use UTF-8/Unicode strings, include the file "utf8.e":

include utf8.e



#5 2019-08-17 10:20:27

Administrator / Администратор

Re: Hello World!

The fact that Euphoria 3.1.1 is using a 32-bit sequences takes lots of memory, isn't it?

  • At the same time it makes Euphoria very efficient and fast language.

  • In DOS operating system, on a new hardware, 32-bit is an advantage over 16-bit: you'll never run out of memory. That's not the case with other programming languages.

  • These days, PC's with 16GB memory... Do you really care? Unless you are a system programmer - it should not bother you at all.

  • Since today's world is using mainly 32-bit Unicode strings, more then pure ASCII strings, then Euphoria's 32-bit sequences is an obvious advantage (over Python for example).

  • So the answer: 32-bit sequences (dynamic arrays/strings) is a clear advantage which makes Euphoria also the most simple programming language in the Milky way.


Board footer

Powered by FluxBB