Jump to content

May 2017 »

2829 30 31   
- - - - -

Speculation and such

4: Adsense

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!

Sep 09 2013 07:58 PM

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

Sep 09 2013 11:08 PM
Yes. Epoch has no object model; instead, everything is composed of tasks, communicating via message passing.
Sep 10 2013 05:59 AM

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.   ;)




Sep 10 2013 06:25 AM

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?



Sep 10 2013 08:20 AM

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


Objects are tasks, and they communicate via message passing.

Sep 10 2013 09:26 AM

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.

Sep 10 2013 12:18 PM
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.
Sep 10 2013 01:36 PM

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.




Sep 10 2013 02:32 PM

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.

Sep 10 2013 07:45 PM


Note: GameDev.net moderates comments.