Shop OBEX P1 Docs P2 Docs Learn Events
Erlang to Propeller — Parallax Forums

Erlang to Propeller

nisbusnisbus Posts: 46
edited 2011-04-19 09:51 in Propeller 1
Hi,

has anyone tried creating a compiler for Erlang to the propeller?

It seems Erlang would be a great fit for programming 8 cogs since Erlang is all about concurrency.

thanks,
nisbus

Comments

  • nisbusnisbus Posts: 46
    edited 2010-11-26 17:06
    ehmm, I already know Erlang.
    I was wondering if anyone had attempted to build an interpreter for Erlang to Propeller.
    It's a favorite language of mine and I think it would be a natural fit for the Propeller.

    thanks,
    nisbus
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2010-11-26 19:24
    The reference wasn't for you it for those that don't know what it is.
    nisbus wrote: »
    ehmm, I already know Erlang.
    I was wondering if anyone had attempted to build an interpreter for Erlang to Propeller.
    It's a favorite language of mine and I think it would be a natural fit for the Propeller.

    thanks,
    nisbus
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-11-27 09:45
    Erlang sounds huge. Is this something for micro's, or is Erlang more suited for running on a some sort of large, central server that talks to micros?

    from
    http://learnyousomeerlang.com/introduction
    Erlang is no silver bullet and will be particularly bad at things like image and signal processing, operating system device drivers, etc. and will shine at things like large software for server use (i.e.: queues, map-reduce), doing some lifting coupled with other languages, higher-level protocol implementation, etc. Areas in the middle will depend on you. You should not necessarily wall yourself in server software with Erlang: there have been cases of people doing unexpected and surprising things. One example is IANO, a robot created by the UNICT team, which uses Erlang for its artificial intelligence and won the silver medal at the 2009 eurobot competition. Another example is Wings 3D, an open source 3D modeler (but not a renderer) written in Erlang and thus cross-platform.

    If you have Erlang running on your windows/linux box, we could probably make something that interfaces the prop portion of the application to that.

    What sort of application did you have in mind? This sounds cool.
  • nisbusnisbus Posts: 46
    edited 2010-11-27 13:39
    Sorry Bob, I misunderstood your post and thanks for the link.

    I really don't have a specific application in mind.
    The similarities with the programming style of spin and erlang just struck me as something that would open up a whole world of possibilities in programming the propeller.

    In Spin you do coginit to 'spawn' some code on a new cog.
    In Erlang you spawn a new process (green-thread) with some code.

    Erlang is all about message passing with no mutable state which sounds perfect for programming 8 independent cogs.

    Erlang is a relatively small language (it will probably fit a single A4 page) so creating a compiler for Erlang to propeller should not be that hard (for someone that knows how to build a compiler, that is).

    The huge thing in Erlang is OTP (Open telecom platform) which is all about managing the spawned threads and has some patterns for programming Erlang systems but I don't see where that would be run on a propeller since that would require one cog to run the Erlang VM and somehow manage the rest of the cogs. Maybe there should be an OPP (Open propeller platform) for managing multiple propellers from a single VM running on a Win/*nix box.

    I just really like the Erlang syntax and would love to be able to program the propeller using it ( i.e. binary pattern matching, list comprehension etc), I have no idea if this is possible or even feasible. I was just thinking out loud :)

    ASM for me is just too hard, and Spin is such a weird language with a mix of C, Pascal and some other languages sprinkled on top. It would be nice to have a language that a lot of people know and a functional one to boot.

    My two cents,
    nisbus
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-11-28 07:16
    The thing about the prop and this forum is the amount of community interaction. Everybody have there own projects, but we find if we all work together, we benefit from each others work.

    In my case, I'm using FORTH to do low level implementation to do distributed coordinated parallel processing, this is an extension to the prop's multi-core simultaneous parallel processing. It is the logical layer on the hardware layer.

    Erlang appears to be similar, or possibly and extension on to of a logical parallel layer. This might have a common basis to some of my work.

    If you can show us the "single A4 page" example, we could probably come up with something. Interested?

    If you can provide you ideal of an idealize example, and your favorite references (wiki was little terse) we can get started. This sounds really cool!
  • nisbusnisbus Posts: 46
    edited 2010-11-29 13:16
    Well, I finally found the Erlang language specs and it's actually 20 pages ;)
    http://www.it.uu.se/research/group/hipe/cerl/doc/core_erlang-1.0.3.pdf

    I'm not sure whether it would be possible to run the Erlang VM on a cog.
    For starters I would love to see list comprehension and binary pattern matching on the propeller and I will probably start writing something for this soon.

    As for favorite references, http://www.erlang.org documentation is the place to look for anything Erlang.
    The HiPE page is also interesting http://www.it.uu.se/research/group/hipe/.

    I'll keep you posted with my progress but this will probably take some time since this is my first compiler.
  • nisbusnisbus Posts: 46
    edited 2010-11-29 14:09
    Well I found some interesting info in the erlang docs about cross-compiling the OTP:
    http://www.erlang.org/faq/implementations.html#id56464
    "Getting Erlang to run on, say, an 8 bit CPU with 32kByte of RAM is not feasible". (At least they don't say impossible :))

    It seems that this is possible although I don't know if the memory requirements are too great for the propeller to handle.

    It seems that there is a template that needs to be filled out for cross compiling it and I've attached a sample from the source as well as the readme.
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-11-29 21:10
    It seems to me most instances of Erlang are built on C. But since the prop has limited memory, it would require much care to get something usable to fit on a prop. And writing everything in assembly might be tedious.

    What about implementing key Erlang functions in FORTH, and run interactively from the command line? The you just chose the key Erlang functions, and tailor them to prop architecture. Lots of extra cogs, and lots of extra space.

    What are the key Erlang functions? Tuple, Letrec, etc? What functions do we need to have to call it a usable Erlang?
  • jazzedjazzed Posts: 11,803
    edited 2010-11-29 21:31
    And writing everything in assembly might be tedious.

    What about implementing key Erlang functions in FORTH ...
    From tedious to Reverse Polish :D Nice tradeoff.

    But seriously folks. Languages that generate byte-codes are probably the best kind to port to Propeller. Pascal, Java 1.1, Z80 (assembly instructions), and others were all pretty easy to do in PASM because they use an intermediate byte-code model. I don't know forth or how it operates, but I'm sure it works great for those who are attached to it and probably use it exclusively. It's not clear what Erlang does, but the specs I've seen posted don't really tell anything about the implementation.

    Now, one thing you could do since the language appears to be written with GNU C is try to compile it with ZOG's GNU toolchain. The problem will be getting a ./configure output that would be usable with ZOG. I have no idea if there is a cross compile option available for zylin's ZPU ... I haven't seen any configure script in the toolchain or install directories.
  • thanosthanos Posts: 1
    edited 2011-04-19 09:51
    I'm using them (propellers) as sensors in a large erlang OTP system.
    Unfortunately its in a commercial app otherwise I would be happy to share the node code. What I can tell you is we created an I2C linked-in driver and use the Erlang node as the master with the porps as slaves.
Sign In or Register to comment.