User Tools

Site Tools


eiffel:hello:start

Getting Started

There is much to do in the first week of EECS3311. Get started right away. Familiarize yourself with Eiffel, the Eiffel method, and Eiffelstudio:

  • Execute a “Hello World” program using the command line compiler. Instructions below.
  • Quick introduction to Eiffel Syntax here
  • Learn how to use the EiffelStudio IDE here (using class CALENDAR). This also introduces you to some design principles.
  • Run the unit testing framework ESpec, instructions here
  • See the sequence of Videos introducing EiffelStudio, ESpec and using the debugger here.

Ensure that you understand and can do the following:

  • Basic Eiffel Syntax and Method
  • Compile and execute from the command line
  • Start a new project in the EiffelStudio IDE
  • Change the settings to Void Safety mode
  • Browse clusters, classes and features (contract view, flat view etc.)
  • Use the unit testing framework ESPec in the IDE
  • Expert use of the IDE debugger
  • Add clusters and classes with the IDE
  • Use the IDE to generate documentation

Your first Eiffel program (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”.

In Java you need

  • the hello_world.java code
  • 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

  • the hello_world.e file with the Eiffel code as well as
  • an *.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).
  • Note3: On Linux (Prism or VM), ensure that you have at least 200MB (of your 1GB allotment) for EIFGENs (eiffel generated C code). The command 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).

Using command line (''ec18.11'')

To compile your program from the command line, use

ec18.11 hello_world.e

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

[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 18.11 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

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

ec18.11 -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.

  • Note: If you are using the command line under Windows, then the compiler is ec (not ec18.11). Use the Eiffel 18.11 command prompt (available from the Start menu). Alternatively,ensure that: C:\Program Files\Eiffel Software\EiffelStudio 18.11 GPL\studio\spec\windows\bin is on your PATH variable.

Using IDE (estudio18.11)

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

 > estudio18.11 &

(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:

 estudio18.11 foo.ecf &.

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

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 .
eiffel/hello/start.txt · Last modified: 2018/12/28 20:49 by jackie