WebAssembly target for Idris

298 views
Skip to first unread message

John Siegrist

unread,
Feb 17, 2017, 8:24:16 PM2/17/17
to Idris Programming Language
Hello All,
Being fairly new to Idris, I was wondering if anyone has considered compiling Idris down to the fairly new WebAssembly? The WebAssembly project has decided to target for C/C++ code as its first language so adapting Idris should be a matter of emitting the intermediate C code from the Idris compiler and running it through the WebAssembly C/C++ compiler. Does this sound like an idea worth pursuing? Having a choice like Idris as an alternative to JavaScript/NodeJS as the single full-stack seems like it would be a good outcome.
Kind regards,
John Siegrist

http://webassembly.org
https://github.com/WebAssembly/design/blob/master/CAndC++.md
https://github.com/WebAssembly/binaryen

Bardur Arantsson

unread,
Feb 18, 2017, 5:25:16 AM2/18/17
to idris...@googlegroups.com
On 2017-02-18 02:24, John Siegrist wrote:
> Hello All,
> Being fairly new to Idris, I was wondering if anyone has considered
> compiling Idris down to the fairly new WebAssembly? The WebAssembly
project
> has decided to target for C/C++ code as its first language so adapting
> Idris should be a matter of emitting the intermediate C code from the
Idris
> compiler and running it through the WebAssembly C/C++ compiler.

I don't think it's quite as simple as that. The runtime also needs to be
compatible with WebAssembly. I believe that means (among other things)
no threads -- at least for the time being.

(I have no idea whether Idris actually requires such support in the
emitted "backend" language. Given that there's a JS backend, perhaps
not? Either way, it's probably a little more complicated than it sounds
to provide a WebAssembly backend.)

> Does this sound like an idea worth pursuing? Having a choice like Idris
> as an alternative to JavaScript/NodeJS as the single full-stack seems
> like it would be a good outcome.

Certainly -- it would be amazing to have WebAssembly backends for all
the things.

Regards,

Jacob Thomas Errington

unread,
Feb 19, 2017, 10:44:24 AM2/19/17
to idris...@googlegroups.com
On 02/18/2017 05:22 AM, Bardur Arantsson wrote:
> On 2017-02-18 02:24, John Siegrist wrote:
>> Hello All,
>> Being fairly new to Idris, I was wondering if anyone has considered
>> compiling Idris down to the fairly new WebAssembly? The WebAssembly
> project
>> has decided to target for C/C++ code as its first language so adapting
>> Idris should be a matter of emitting the intermediate C code from the
> Idris
>> compiler and running it through the WebAssembly C/C++ compiler.
>
> I don't think it's quite as simple as that. The runtime also needs to be
> compatible with WebAssembly. I believe that means (among other things)
> no threads -- at least for the time being.
>
> (I have no idea whether Idris actually requires such support in the
> emitted "backend" language. Given that there's a JS backend, perhaps
> not? Either way, it's probably a little more complicated than it sounds
> to provide a WebAssembly backend.)
>

Idris recently added some concurrency primitives. These are implemented
using pthreads in the C backend. It might be possible to implement them
using a single-threaded event loop scheme like in Node though.

Jake

Reply all
Reply to author
Forward
0 new messages