Skip Navigation
York U: Redefine the PossibleHOME | Current Students | Faculty & Staff | Research | International
Search »FacultiesLibrariesCampus MapsYork U OrganizationDirectorySite Index
Future Students, Alumni & Visitors
Getting Started

Eiffel The Language -- Basics

Use Eiffel in Prism or Install on your laptop

We will use the following tools, both installed on our Linux Prism servers:

  • EiffelStudio IDE version 15.12.
  • ESpec unit testing tool (a testing library), part of the EiffelStudio Distribution.

How to start using the above tools is explained further below. You can run EiffelStudio IDE (Integrated Development Environment) or the Eiffel command line compiler (ec) in one of three ways:

  • It is available on the Prism Linux workstations (and on the red compute server). The IDE is invoked from the command line as “estudio15.12”.
  • You may download the SEL Virtual Machine (SEL-VM details) and run it under VirtualBox on your laptop. The VM is the same Linux operating system and environment as the Prism workstation. Login at the site and install the latest build.
  • You may also install EiffelStudio 15.12 on your Windows, Linux or MacOs laptop (download) (Eiffel Documentation).

The Windows version of EiffelStudio is nice to use. But note that all Labs, Assignments, Projects and Labtests must be submitted and executable on the Prism (Linux) version. Although all versions on the different operating systems are similar there may be some slight differences.

Hello World

Whenever you want to get started with a new language (in our case Eiffel) or an Integrated Development Environment (in our case, EiffelStudio), one always tries to run the simplest possible program - one that prints out “Hello World”.

Linux (Prism or VM)

On your Prism account, ensure that you have at least 200MB (of your 1GB allotment) for EIFGENs (eiffel generated C code). The command

cd
du -h

will help you see what your memory usage is. You can use the eclean command to remove all the EIFGEN directories (see below).

Command line (''ec15.12'')

In Java you need (a) the hello_world.java code and (b) the variable CLASSPATH must be set correctly so that the Java runtime will find your classes and the basic pacakges to compile your program.

In Eiffel you also need (a) the hello_world.e file with the Eiffel code as well as (b) a *.ecf file that tells the Eiffel compiler (called ec) where to find your files as well as all the libraries (such as the base library) that your code will be using. Here are the contents of hello_world.e:

class HELLO_WORLD create
	make
feature
	make 
		do
			print("Hi World!")
		end
end
  • Note1: ensure that the file name is “hello_world.e” and the class name in the file is HELLO_WORLD. Eiffel is case insensitive. However, the convention is to write class names in CAPITAL letters.
  • Note2: On Windows, you might want to put “io.read_line” after the print statement. Semi-colons are not needed between lines (to indicate sequencing).

You run the compiler (“ec”) from the command line on the hello_world.e file as follows:

ec15.12 hello_world.e

On Prism (Linux), we have renamed the command line compiler (“ec”) to '“ec15.12”, as we are using EiffelStudio version 15.01.

[On your own install in Linux/Windows/MacOs, you may be prompted to precompile. Answer Yes.]

On Windows/MacOs, the command line will just be “ec”. On Windows, use the EiffelStudio 15.01 Command Prompt (available from the Start menu).

When you invoke ec on a single source file such as hello_world.e, the compiler will generate the ecf file for you (hello_world.ecf). ECF files specify which libraries will be used. The Base library is always included.

To execute the program:

cd EIFGENs/hello_world/W_code
 ./hello_world

and it should print out the message.

In general, you will need other libraries (in addition to the Base library) and thus you will invoke the compiler on the ECF file.

You can obtain a finalized executable that can be deployed by any user (without the need for the EiffelStudio environment) by:

ec15.12 -c_compile -finalize -config hello_world.ecf

The Eiffel program is translated to C, and the C program is compiled to executable machine code (that does not need a virtual machine to run it). To execute the program:

cd EIFGENs/hello_world/F_code
 ./hello_world

The above executable should print out “Hi world”. This executable is all you need to run the program on any other Linux machine of the same architecture.

eclean script (Prism/VM))

The compiler creates a large number of C and other files that you should get rid off to conserve disk space.

We recommend that you reserve 200MB of free space on your disk for generating the intermediate C files.

If you invoke the Linux command eclean on your directory, the EIFGENs (Eiffel generated files) will be deleted leaving only *.e and *.ecf files.

> eclean .

IDE (estudio15.12)

You can invoke the EiffelStudio IDE on the above project as follows:

> estudio15.12 &

(On your own install, it is just estudio).

When you start a new project on the IDE, you can use the Wizard to generate an ECF file automatically. If you already have a project with ECF file foo.ecf, then you can start from the command line as follows: estudio15.12 foo.ecf &.

(The ampersand at the end causes the EStudio process to run in the background, leaving the terminal free for further commands.)

EiffelStudio Documentation.

Windows

If you are using the command line under windows, then the compiler is ec (not ec15.12). Use the Eiffel 15.12 command prompt (available from the Start menu). Alternatively,ensure that:

C:\Program Files\Eiffel Software\EiffelStudio 15.12 GPL\studio\spec\windows\bin

is on your PATH variable.

ESpec unit testing library

We will be using the ESPEC unit testing framework (a library developed at York University and now part of the EiffelStudio distribution).

On the Prism/Linux workstations and the VM, the ESpec Library is present by default (when creating a new project). If it is your own install, then you need to add the library.

Add ESpec library

  • Open your project with EiffelStudio
  • Open “project settings window” from Eiffel Studio (Project → Project Settings …)
  • Expand the groups section by clicking on the arrow next to it
  • Select the ESpec library as shown below

(To add other libraries, or to add the ESPEC library that comes with your version of eiffelStudio, see here)

The ECF file will thus have the following line in it:

<library name="espec" 
location="$ISE_LIBRARY\contrib\library\testing\framework
\espec\library\espec-safe.ecf"/>

Change the code in class HELLO_WORLD to the following, in order to test if the ESpec library is working. In the tool bar, select the HELLO_WORLD class and change the class the code below:

class HELLO_WORLD inherit
	ES_TEST
create
	make
 
feature {NONE} -- Initialization
 
	make
			-- Run tests
		do
			add_boolean_case (agent t0)
			--show_errors
			show_browser
			run_espec
		end
feature -- tests
	t0: BOOLEAN
		do
			comment("t0: succeed?")
			Result := false
		end
 
end
To run the tests:
  • Compile the system (by pressing Ctrl-F7) and wait for the C compilation to complete. After adding a lot of code, it is safer to freeze the system (Shift-Ctrl-F7).
  • Press the little down arrow next to the run button, and invoke “run workbench system”, that will bring a browser window with the results of your tests. The keyboard shortcut is Ctrl-Alt-F5).

The test will succeed if you have Result := true (and you will get a green bar).

For more on how to use the testing framework see

EiffelStudio Tutorial

Eiffel the Language

Mac and Ubuntu

These are rough notes that may be out of date.

MacOs: MacOs Install

To install in Linux/Ubuntu

sudo apt-get purge eiffelstudio
sudo apt-get update
sudo apt-get install eiffelstudio
Suppressing runtime catcall warnings
  • In Execution → Exception Handling, check “disable catcall console warnings” and “disable catcall debugger warnings”.
Last modified:
2016/01/25 14:04