Shop OBEX P1 Docs P2 Docs Learn Events
JavaScript on the Propeller? — Parallax Forums

JavaScript on the Propeller?

Heater.Heater. Posts: 21,230
edited 2013-04-11 02:29 in General Discussion
Continuing my current obsession with JavaScript I'd like to introduce you to this: http://www.espruino.com/
With an impressive demo video here: http://www.espruino.com/Video

It was only the other day that I was half joking here that one day we would be programming our tiny embedded systems in JS. Only to find that someone has already done it. Thanks to KC_Rob for the heads up on that.

That guys JS operates in 128K FLASH so it's not far off fitting in a PII. With an external memory it must be possible. He says he might open source the thing at some point only I have the horrible feeling he may have written it in ARM assembler.

Comments

  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-06 06:38
    Amen, Brother!!! I think I'm starting to see the light!!! JavaScript, Node and Forth!! Together, we can rule the world!!

    Seriously, I've been reading up on Node and learning JavaScript and with the little example you posted in the other thread, the bells and lights are starting to go off in my head. Wrapping your mind around the anonymous functions and call backs and event loop takes a bit but once it starts to click, woohooo!!! There are some really neat possibilities to blend everything together with JS superglue.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-06 06:49
    Hey, I just found this implementation of JS: http://code.google.com/p/tiny-js/ or at least a fair chunk of JS in only 2000 lines of code. Sounds like JS for the Propeller is on the way!

    @mindrobots,

    Great. Yes, I have managed to program for decades without anonymous functions, inner functions, closures. So it takes a bit of getting used to. The idea that local variables can still be valid after a function has exited is just freaky.

    Never used recursion on an embedded system, I believe it was forbidden on many projects I have worked on.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-06 06:55
    @Heater
    Do you want a Dallas Systems DS80C400 Tini motherboard? I have three here and two have never been used. It is all Java, have a file system, has LAN, has a RTC, has a couple of serial ports, has 1-wire, has Canbus. It can even use I-Buttons.

    http://www.maximintegrated.com/datasheet/index.mvp/id/4983
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-06 06:56
    Javascript on the propeller is impossible. It can't be done.





    :D (somebody had to say it)
  • Heater.Heater. Posts: 21,230
    edited 2013-04-06 07:08
    doggiedoc,
    Javascript on the propeller is impossible. It can't be done.

    I agree. Crazy impossible. Wait a minute...
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-06 07:32
    Totally impossible!!

    I just ordered my Olimexino STM32 so I can have something to compare the impossible to! :lol:

    Let's see, now should I work on my taxes, work on the many, many other projects on my stack or allocate another stack frame and start playing with this silliness???

    Could we be seeing evolution in action ...... Propeller --> PropGCC --> Raspberry Pi & Propeller --> Propeller 2 & Raspberry Pi --> PropJS --> Enlightened Systems
  • Heater.Heater. Posts: 21,230
    edited 2013-04-06 08:59
    Wow, I never imagined computers would reach sentience via a network of nodes controlled by a crappy little scripting langage designed and thrown in to a WEB browser in a week back in 1995.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-06 12:05
    Totally impossible!!

    Guess what?

    The TinyJS interpreter on Google code linked to above happens to be made by the same guy at Pur3 Ltd in the UK as the Espurino system in the video. Looks like he has not added all the hardware interfacing goodies to the version on Google code.

    There is also a branch in that repository where someone has taken TinyJS and tried to make it more standards compliant. In the process it is has grown to over 8000 lines of code.

    Anyway, TinyJS compiles fine on Linux out of the box and the resulting interpreter does actually work interactively.

    I would compile it with propgcc but my machine with that on is tied up with farmville for hours (no I don't do that).

    We are very close to JS on the Propeller.

    Now, how best to make use of all the Props COGs and other goodies from JS?

  • jazzedjazzed Posts: 11,803
    edited 2013-04-06 12:11
    mindrobots wrote: »
    Seriously, I've been reading up on Node and learning JavaScript and with the little example you posted in the other thread ...

    What other thread? Did I miss another amazing Heater post?
  • Heater.Heater. Posts: 21,230
    edited 2013-04-06 12:20
  • KC_RobKC_Rob Posts: 465
    edited 2013-04-06 12:55
    doggiedoc wrote: »
    Javascript on the propeller is impossible. It can't be done. :D (somebody had to say it)
    And now it most assuredly will be done, it's practically in the books! Lol

    I can't even remember how I came across Espruino the other day, but once I did, I knew that Heater must be informed (on the off-chance that he hadn't already seen it) -- that way he'd know that he wasn't so far out in left field after all. :)

    The code examples do whet the appetite. Espruino looks promising.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-06 13:00
    Loopy,

    Thanks for the offer for the Tini board. I'm going to decline. I have too may platforms to keep up with and to be honest Java is not on my favorites list.

    Note: Java and JavaScript are very different languages. In some respects JavaScript has more advanced features than Java, like inner functions, anonymous functions, closures, prototypal inheritance... which makes it more interesting and makes up for it's interpreted nature.
  • KC_RobKC_Rob Posts: 465
    edited 2013-04-06 13:09
    Heater. wrote: »
    Note: Java and JavaScript are very different languages. I[n] some respects JavaScript has more advanced features than Java, like...
    I'll second that: not the same thing at all.
  • jazzedjazzed Posts: 11,803
    edited 2013-04-06 13:57
    Heater. wrote: »

    Well it's a start.

    I ran their hello, world example last week, but didn't have time to look for the serial interface stuff. Is "npm" like a Node Package Manager? Any chance you could start a thread for exploring Node + SerialPort and related things? I've missed how to plug the functions into html for example. Is there enough interest from others here?

    I have plenty to do, but I'd like to learn more about this even in little pieces.

    Thanks,
    --Steve
  • Heater.Heater. Posts: 21,230
    edited 2013-04-11 02:24
    m1ianidi,
    Java Script on the Propeller is not possible...

    http://forums.parallax.com/showthread.php/147256-Trying-to-build-TinyJS-for-the-Prop.

    In Propeller land the impossible is done yesterday.
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-11 02:29
    Heater. wrote: »
    In Propeller land the impossible is done yesterday.

    That's because there aren't any interruptions!!! :0)
Sign In or Register to comment.