• entries
628
1454
• views
1011768

# Speculation and such

997 views

Just fooling around.

//// Define an Epoch task that does some work//task Worker :{ // // This specifies a "message signature" which can be // used by and instance of this task to receive data // and commands from other code. // Work : integer a, integer b { // Do some computation integer result = a + b // Reply to the sender of the message with another // message, carrying the fact that we're done, and // the result of our computation. sender ~> Completed(result) }}//// Define another task, which is responsible// for generating work. It also must contain// the message response signature for taking// the results back from the worker.//task Requester :{ // // This message tells the requester to make up some work // Request : Worker ref worker { // Generate some data integer a = random() integer b = random() // Work on it! // This syntax directs the Work message to reply to this // task when it is done. The responses will be delivered // via Completed messages. worker ~> Work(a, b) ~> self } // // This message is received when the worker // is done doing its thing. It prints stuff // so work has some visible effect. // Completed : integer result { print(cast(string, result) ; " came from task!") }}//// Now we write a standard entrypoint procedure.// We're going to create a worker pool, and then// fire work at each worker a whole bunch.//entrypoint :{ // First our pool of workers... // This syntax allocates an object (task) which is garbage collected as necessary new Worker w1 new Worker w2 new Worker w3 new Worker w4 // Now a wrapper to handle requests... new Requester r // And now we get busy! integer workcount = 0 while((workcount++) < 1000) { r ~> Request(w1) // Asynchronously pass Request message with no reply expected r ~> Request(w2) r ~> Request(w3) r ~> Request(w4) }}
Voila - 4 core random number summation engine!

Hmm interesting. Eagerly anticipating more. Will parallel capabilities be part of the core language?

Yes. Epoch has no object model; instead, everything is composed of tasks, communicating via message passing.

That got my interest, big time.

Epoch seems to be a garbage collection language, but are there plans for threading and memory management extensions?

Yes. Epoch has no object model; instead, everything is composed of tasks, communicating via message passing.

Are you saying that Epoch is not an OO language?  Are you saying that it will always lean toward logic coding?

Please pardon the provocative questions.   ;)

Clinton

Yes. Epoch has no object model; instead, everything is composed of tasks, communicating via message passing.

"// This syntax allocates an object (task)..."

A little confused by this. Do you mean there are a fixed set of objects/tasks that are a part of the language that can be created?

-Josh

Reading between the lines, 'has no object model' != 'has no objects'.

Objects are tasks, and they communicate via message passing.

Yeah, but that doesn't necessarily mean that he doesn't have it in the works or that it is not supported.  Communicating via message passing can have another explanation for it.

Epoch is not an "OO language" in the sense of Java, no. It closely parallels the original idea of object orientation (message passing) but isn't really something you would think of as OO in the colloquial sense.

Concurrency is supported entirely via tasks, similar to Go, which leads to natural parallelization support. Explicit threading is unnecessary.

There may be some built-in tasks in the standard library but mostly they'd be things end-programmers create.

That is exactly what I needed to know.

How are you going to license this language when it is ready?  I am interested in using it someday.

Clinton

The implementation is and has always been free open source under the New BSD license. Use of the toolchain to write software is completely free and without licensing restrictions.

Thanks

## Create an account

Register a new account