inicio mail me! sindicaci;ón

E, episode thirteen (Conclusions)

Here I am, at the end of my E-journey.

What have I learned?

The existance of great ideas. I don’t really like E’s syntax but the ideas behind and beyond this language are great. The capability security model is stupid-proof and 100% secure. It’s a pity nobody uses it. As far as I know Palladium is a capability infrastructure but I don’t like the way and the reason why it’s implemented :-)

The E-things I dislike are it’s javashism, the slowness of the command line intepreter, the apparent no-interest of people outside the little community and so on.

What next?

Another exotic language? Another less known or widespread language? Smalltalk? Io? Common Lisp?

E, episode twelve (Capabilities)

Capabilities

E uses capability based security to supply both strong security and broad flexibility without incurring performance penalties. Capabilities might be thought of as the programming equivalent of physical keys

E makes use of the Principle of Least Authority (POLA) to ensure that it gives no more authority that the other part needs.

In the real physical world, if you had to depend on children to fetch CDs, you would not use an ID badge. Instead you would use keys. You would give the child a key to the front door, and a key to the CD cabinet. You would not give the child a key to the gun vault. All current popular operating systems that have any security at all use the ID badge system of security. NT, Linux, and Unix share this fundamental security flaw. None come anywhere close to enabling POLA. The programming languages we use are just as bad or worse. Java at least has a security model, but it too is based on the ID badge system–an ID badge system so difficult to understand that in practice no one uses anything except the default settings (sandbox-default with mostly-no-authority, or executing-app with total-authority). The “children” are the applications we run. In blissful unawareness, we give our ID badges to the programs automatically when we start them. The CD cabinet is the data a particular application should work on. The gun vault is the sensitive data to which that particular application should absolutely not have access. The children that always run to get a gun are computer viruses like the Love Bug. In computerese, ID badge readers are called “access control lists”. Keys are called “capabilities”. The basic idea of capability security is to bring the revolutionary concept of an ordinary door key to computing.

Read the rest of this entry »

E, episode eleven (The Dream)

E programs never block. They never just sit and wait around for results.

It this just a dream :) ?

E, episode ten (Promises)

A promise is the result of an eventual send to an object:

[code lang="javascript"] def carVow := makeCar <- (”Mercedes”) carVow <- moveTo(2,3) [/code]

“<-” is the eventual send operator.

Now you can start making eventual sends to the promise as if it were the object itself.

The “when-catch” clause is used to wait for the resolution of a promise:

[code lang="javascript"] def temperatureVow := carVow < - getEngineTemperature() when (temperatureVow) -> done(temperature) { println(”The temperature of the car engine is: ” + temperature) } catch error { println(”Could not get engine temperature, error:” + error) } println(”execution of the when-catch waits for resolution of the promise,”) println(”but the program moves on immediately to these printlns”) [/code]

We can read the when-catch statement as, “when the promise for a temperature becomes done, and therefore the temperature is locally available, perform the main action block… but if something goes wrong, catch the problem in variable error and perform the problem block”. The when-catch construct waits for the temperature to resolve into an actual (integer) temperature, but only the when-catch construct waits (i.e., the when catch will execute later, out of order, when the promise resolves). The program itself does not wait: rather, it proceeds on, with methodical determination, to the next statement following the when-catch. Inside the when-catch statement, we say that the promise has been resolved. A resolved promise is either fulfilled or broken. If the promise is fulfilled, the main body of the when-catch is activated. If the promise is broken, the catch clause is activated.

References can always resolve to local object (vow references) or be unguaranteed references (receiver references) that must be treated as remote objects.

E, episode nine (Distributed Computing)

There’s no much to write about E’s concurrency model after you read this enlightment (from E in a Walnut):

Multiple threads form the basis of conventional models of concurrent programming. Remarkably, human beings engage in concurrent distributed computing every day even though people are generally single threaded ([...]). How do we simple creatures pull off the feat of distributed computing without multiple threads? Why do we not see groups of people, deadlocked in frozen tableau around the coffepot, one person holding the sugar waiting for milk, the other holding milk waiting for sugar? The answer is, we use a sophisticated computational mechanism known as a nonblocking promise. Let us look at a conventional human distributed computation. Alice, the CEO of Evernet Computing, needs a new version of the budget including R&D numbers from the VP of Engineering, Bob. Alice calls Bob: “Could you get me those numbers?” Bob jots Alice’s request on his to-do list. “Sure thing, Alice, I promise I’ll get them for you after I solve this engineering problem.” Bob has handed Alice a promise for the answer. He has not handed her the answer. But neither Bob nor Alice sits on their hands, blocked, waiting for the resolution. Rather, Bob continues to work his current problem. And Alice goes to Carol, the CFO: “Carol, when Bob gets those numbers, plug ‘em into the spreadsheet and give me the new budget,okay?” Carol: “No problem.” Carol writes Alice’s request on her own to-do list, but does not put it either first or last in the list. Rather, she puts it in the conditional part of the list, to be done when the condition is met–in this case, when Bob fulfills his promise. Conceptually, Alice has handed to Carol a copy of Bob’s promise for numbers, and Carol has handed to Alice a promise for a new integrated spreadsheet. Once again, no one waits around, blocked. Carol ambles down the hall for a contract negotiation, Alice goes back to preparing for the IPO. When Bob finishes his calculations, he signals that his promise has been fulfilled; when Carol receives the signal, she uses Bob’s fulfilled promise to fulfill her own promise; when Carol fulfills her promise, Alice gets her spreadsheet. A sophisticated distributed computation has been completed so simply that no one realizes an advanced degree in computer science should have been required. In this simple example, we see why human beings never get trapped in the thread-based deadlock situations described endlessly in books on concurrent programming. People don’t deadlock because they live in a concurrent world managed with a promise-based architecture. And so it is withE.

Why we people stick with that evil and bad multithreading stuff?

E, episode eight (Interfacing to Java)

Since E sits on top of the JVM is capable of using quite everything the Java world exposes.

Package access

We can import a class from the underlying Java virtual machine with the import statement, and speak to the Java object much as we would speak to an E object

[code lang="javascript"]

create a single vector with a direct call to Java

def vector := () vector.addElement(”abc”)

create a makeVector function which can be called repeatedly to make more vectors

def makeVector := def vector2 := makeVector()

create a shorthand for the java.util package, that gives quick access to all the

classes in java.util

def := def vector3 := () [/code]

unsafe: is of the many uri getters available in E. Others are file: (already seen), the programmer-defined util:, swing: (to access javax.swing) and awt: (to access java.awt), resource: (for read-only access to resource files such as images, sounds, and static texts) and import:.

The import: uriGetter is similar to unsafe:, except it only imports those parts of the Java API that have been audited for capability security and found to convey no authority. So import: is often useful in these security-aware situations. A complete list of safe versus unsafe classes, and the small percentage of Java API methods which are suppressed for security reasons, are listed in the documentation.

Public constants

As noted earlier, E does not have an expression to directly represent public static final variables. To use such static finals from a Java class, put parentheses at the end of the variable name, making it syntactically look like a function call, prefix it with “get”, uppercase the first letter, and E will get the value for you:

[code lang="javascript"] .getYEAR() [/code]

Access to overloaded methods

E.call() function can be used to access overloaded methods in this way:

[code lang="javascript"] E.call(javaObject, “method(String, int)”, ["abc", 23]) [/code]

The first argument is the object to send the message to, the second is the full signature of the method and the third argument are the parameters to pass to the invoked method.

With E you have also the Java power in your pocket! :)

E, episode seven (Data Structures)

E has three built-in data structures: lists, maps (hashtables) and sets. Each one comes in two flavors. Immutable (Const) and Mutable (Flex).

Lists

Lists are 0-indexed. You can use “+” for concatenation or the size() method to know the number of elements in the list. Keep in mind that the E String type is a special kind of ConstList where all the elements are characters.

[code lang="javascript"] def list := ["a", 2, true]

this is true: list[0] == “a”

this is true: list[2] == true

def newList := list + ["last"]

this is true: newList[3] == “last”

for each in newList { println(”Element: ” + each) } for i => each in newList { println(”Element number ” + i + ” is ” + each) }

def listSize := newList.size()

get subrange starting at 0, running up to element 2, but not including element 2

def subrange := list(0,2)

this is true: subrange == ["a",2]

[/code]

Lists can be made editable (FlexList) with diverge() method. From then they obtain methods such as push/pop and element replacement. To go back to a ConstList use snapshot() method

[code lang="javascript"] def newList := [] def editable := newList.diverge() editable.push(100) if (editable.pop() == 100) { println(”Yeah, push and pop make a list work like a stack”) } editable[0] := “b”

def frozen := editable.snapshot() [/code] Read the rest of this entry »

E, episode six (I/O)

There’s nothing much to say about E’s input output. Since E sits on top of Java it uses the underline classes (mostly java.io.File) to do I/O. Insted of Java, E has a more human interface to the underline file system.

[code lang="javascript"]

file objects for hardwired files:

def file1 := def file2 := [/code]

In the above examples “<file :>” instruction allow to connect (and open) to a file in the file system

[code lang="javascript"]

using a variable for a file name, note the space after the colon:

def filePath := “c:\home\rhymes\data.txt” def file3 :=

using a single character to specify a Windows drive

def file4 := def file5 := [/code]

You can replace “file” with the drive letter if you are on Windows. Note that forward slashes are platform-independent way to separate directories in E.

File objects can also represent directories:

[code lang="javascript"] def dir := def file6 := dir["data.txt"] [/code]

As said in a previous post you can use the “for” loop to iterate over text files and directories easily. E is also platform indipendent about end-line markers (the only operating system not using “\n” is Windows). It translates them automatically for you.

Java IO is not as straightfoward as E’s right :) ?

E, episode five (Functions and Objects)

Functions

This is a basic recursive function:

[code lang="javascript"] def factorial(n) { if (n == 0) { return 1 } else { return n * factorial(n-1) } } [/code]

What I noticed (and found wierd) is that

[code lang="javascript"] if (blah blah) {} else {} [/code]

is a syntax error :| Remember to put the else clause on the same line of the closing bracket of the if clause.

I asked (and received) an explanation in the e-lang mailing list here

You can nest the definitions of functions and objects inside other functions and objects, giving you functionality comparable to that of inner classes in Java. Nested functions and objects play a crucial role in E

E has the notion of “guard”, a mechanism to do type checking (at runtime). Here an example:

[code lang="javascript"]

guarding a variable

def title :String := “abc”

guarding a parameter, and a return value. Note the guard on the

return value is part of the def line for the function.

def reciprocal(x :float64) :float64 { return 1 / x } [/code]

The “title” constant is explicitly forced to be a String. In the “reciprocal” function the parameter and the return value must be a 64-bit float.

Objects

Here is a singleton object:

[code lang="javascript"] def origin { to getX() {return 0} to getY() {return 0} }

def myY := origin.getY() [/code]

Python programmers beware, methods are not functions. Methods are just the public hooks to the object that receive messages; functions are standalone objects

Read the rest of this entry »

E, episode four (Basics)

E ships with a command line interpreter, named rune useful to test scripts and examples. The configuration file also has the capability to save trace log where you want useful to examine errors separately to not clog the terminal window everytime.

Basics

E has variables (declared with var statement) and constants (declared with def). The assignment is done with “:=” operator, no “=” sign, comparison is done with “==”. So “=” it’s illegal. Remember that.

Statements are ended with new line (no useless “;” or something else).

Basic data types are int, float, string, char, boolean.

Variable sostitution can be done with back-tics “`” in this way:

[code lang="javascript"] def x := 3 def printString := Value of x is: $x [/code]

Strings are somewhat like Java’s. Read the rest of this entry »

Next entries »