8 ms·
You know what I've always wanted to see (and it's quite possible one exists; I have never actively searched for one)? A completely asynchronous programming lang
by AnkhMorporkian 11y ago
You know what I've always wanted to see (and it's quite possible one exists; I have never actively searched for one)? A completely asynchronous programming language. Every single operation is carried out asynchronously; everything from addition to while loops.
Synchronization would be a nightmare, but I think it would be a fun exercise to see what you could do in that framework.
- nine_k 11y agoIs lazy evaluation asynchronous enough for you? It's more predictable than random asynchronous I/O, though, so synchronization is easier.
- Natanael_L 11y agoThere are some doing that by default, but I can't remember the names. Every operation can be done in parallel unless you declare a necessary order for some subset(s) of operations.
- luhn 11y agoHow would that work? My understanding of async is that it's a way of interacting with IO. So how would the examples you give (additional, while loops) behave asynchronously, since they don't involve IO? (Except for maybe memory IO..?)
- chrisseaton 11y agoAddition still takes time though doesn't it? The idea is I could start an addition operation, and then be notified in some way when it's done. I think the idea most similar to what the grandparent wants is instruction-level dataflow, where programs are DAGs, and instructions are only run when their inputs are ready, rather than when a program counter reaches them. Physical dataflow machines were built that did this in hardware.
- luhn 11y agoA program as a DAG.... Whoa. That's an interesting concept to try to wrap your mind around.
- harlowja 11y agoJust fyi, a library openstack (and myself and others) has created (in python) basically lets u program your workflow (really dataflow) as a DAG, and then the library will run it reliably (and in parallel and so-on). I'm more than willing to answer questions about how it does that if people are interested... http://docs.openstack.org/developer/taskflow/ http://docs.openstack.org/developer/taskflow/ https://pypi.python.org/pypi/taskflow https://pypi.python.org/pypi/taskflow And yes u can do things like built equation solvers to: http://docs.openstack.org/developer/taskflow/examples.html#linear-equation-solver-in-parallel http://docs.openstack.org/developer/taskflow/examples.html#l... And other neat things: http://docs.openstack.org/developer/taskflow/#examples http://docs.openstack.org/developer/taskflow/#examples
- glittershark 11y agoThat's exactly how Haskell's IO monad works (albeit a little simplified)
- tomn 11y ago> programs are DAGs, and instructions are only run when their inputs are ready, rather than when a program counter reaches them. At a low level, that's exactly what modern CPUs do. https://en.wikipedia.org/wiki/Out-of-order_execution https://en.wikipedia.org/wiki/Out-of-order_execution
- chrisseaton 11y agoRight, but only on a single core and only over a small sliding window. Real data flow machines made it explicit rather than a fragile optimisation and scaled it up.
- tomn 11y ago
- xyzzy123 11y agoSuch a language would translate really nicely to hardware. Funnily enough, verilog / VHDL are the closest I can think of... You don't get what you would normally think of as "while loops" though, which makes sense if you think about it.
- krupan 11y agoCheck out MyHDL and Cocotb: http://www.myhdl.org/ http://www.myhdl.org/ http://potential.ventures/cocotb/ http://potential.ventures/cocotb/
- jflatow 11y agoThis is called Continuation Passing Style: https://en.wikipedia.org/wiki/Continuation-passing_style https://en.wikipedia.org/wiki/Continuation-passing_style
- ketralnis 11y agoErlang is sort of this. All I/O is done by passing messages to Port objects which send the results/errors back as messages. Your process doesn't block until you tell it to and you don't block on a single operation exactly: you block on waiting for a message in your process's mailbox. The nice thing about this approach is that you can emulate blocking or non-blocking I/O within the same function or even against the same file descriptor. And processes are so cheap that if your callees do block in unexpected ways you can just move that one call into its own process that just sends you a message when it's done.
- silverpikezero 11y agoHoare's CSP is exactly this. It's not a programming language per se, but I know of several DSL's that were built using CSP syntax. https://en.wikipedia.org/wiki/Communicating_sequential_processes https://en.wikipedia.org/wiki/Communicating_sequential_proce...
- Scramblejams 11y agoThis was attempted with Midori, see here: http://joeduffyblog.com/2015/11/19/asynchronous-everything/ http://joeduffyblog.com/2015/11/19/asynchronous-everything/
- glittershark 11y agoHaskell does this.