Electric Communities: E Programming Language

Hello World

This first tutorial provides annotated code for the familiar Hello World application. This introductory application introduces you to basic E concepts:

Hello World

To run this tutorial, enter the following code and study the walkthrough that accompanies it. This example is also available in the online example suite as HelloE.e.


HelloE.e Introductory hello world application to demonstrate E basics. Copyright Electric Communities */

public class HelloE { public static void main(String args[]) { HelloWorld first = new HelloWorld(); first <- hello(); } }

eclass HelloWorld { emethod hello() { System.out.println("Hello World"); } }

The Walkthrough

E-objects function by sending messages to one another, and operate optimistically. Messages can have parameters, just like a regular Java method call. When Object A communicates with Object B, Object A sends a message through the Channel to Object B. Object B would have the proper E-code to handle that message.

When run, the code executes in the following order:

  1. main instantiates the E-object first, an instance of the E-class HelloWorld.
  2. main sends the message hello to first.
  3. first executes the HelloWorld E-method hello to handle the message.
  4. hello prints out, ``Hello World''.

Compiling and Running

To compile source code for the E runtime, use the ecomp compiler:

  ecomp filename

The ecomp command compiles E and Java source files directly into Java bytecodes. You can then run your compiled program with the E Java interpreter (the javaec command):

  javaec filename

For more information on these commands, see the E Tools and Utilities section in the E Programmer's Guide.

Copyright (c) 1996 Electric Communities. All rights reserved worldwide.
Most recent update: 5/29/96