Hacker News new | ask | show | jobs
by sixo 3334 days ago
'Concurrency-by-default' is similar to a notation I've been using to map out async service calls. It's just this: lines are terminated with "," or ";". A comma doesn't block and all comma-separated lines are executed in any order, while a semicolon blocks. Names are only usable when a semicolon is reached, and a semicolon unblocks flow when all preceding names are bound. Probably code is scoped into { } blocks. So a lambda is like "pyth_distance = {x, y; sqrt(x^2 + y^2)}". A series of async callbacks would be given by an inner block {x = call1(), y = call2(); pyth_distance(x,y)}, allowing you to do any manipulations you can do with normal code.

Might try making a toy language out of it eventually.

8 comments

You're close to inventing monads! I did this once too for async reasons also, and it's how I wandered into the world of Monads and functional programming. I would definitely take a look at Scala's futures and what it means to be a monad. This is probably the best way to internalize them. :)
Hm the terminators are much like shell, e.g.

    # synchronous
    sleep 1 ;
    sleep 2 ;

    # parallel
    sleep 1 &
    sleep 2 &
    wait
    wait
The results have to be files... in shell you think of the file system as your "variables", so everything is somewhat global.
Interesting concept. The article mentioned that other languages determine blocking automatically based on usage of the variables. So in your example, it could be determined that x and y must be calculated first before pyth_distance is called with x and y. Would you incorporate this kind of automatic detection into your language? Why or why not, and to what level? Would it perhaps be safer for the language to determine blocks for you?
This reminds me of writing assembly for VLIW DSP chips,where each 'instruction' is actually several that run concurrently.

https://en.m.wikipedia.org/wiki/Very_long_instruction_word

HDLs generally fit this paradigm. You might want to have a look at VHDL or Verilog.
Urbiscript is another spin on this idea, dedicated to robotics in this case. The development seems to have stalled but the ideas are really interesting.
That's really cool.

Would you build something like this from scratch or base it on another tech stack like the jvm?

That's exactly what || (concurrent statements) and ; (sequential statements) do in Esterel.
Thanks, was totally unaware of that. For the lazy and ignorant like me:

https://en.wikipedia.org/wiki/Esterel

(if you'd like to throw a link in your comment, would be happy to delete this one)

No need :) But I'll happily add this one, which is a nice short intro if you know nothing about it: http://www.embedded.com/design/prototyping-and-development/4...

I came in contact with the language during my studies (one of my profs worked on it), found it interesting, but haven't really had a chance to apply it to anything I've done professionally since. It's a very neat language though, and if I got to do anything in the embedded field.

I notice that there is now an open source compiler, which is great. The only implementation I was aware of so far was closed source.