Join us on Discord!
You can help CodeWalrus stay online by donating here.

Duktape - A JavaScript interpreter for the Nspire [ti-nspire]

Started by Legimet, February 04, 2015, 03:01:18 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Legimet

Hi everyone, I just joined CodeWalrus  :D

This is a port of Duktape, a lightweight JavaScript (ECMAScript) interpreter, to the TI-Nspire.
It can run in interactive mode (NspireIO) or run a .js(.tns) file from the documents screen. To exit from interactive mode type ".exit".
More functions will be added later.

Download: http://ti-pla.net/a153555
Source code: https://github.com/Legimet/duktape-nspire

Dream of Omnimaga

Hiya and welcome to the forums. :walrii: I saw this on Omni yesterday but I didn't return yet so that was why I didn't reply immediately. It seems very promising. How far into completion is it? Would, for example, simple Javascript-based games (point and click) be useable? Also how is the speed?

New languages are always welcome on the TI-Nspire. With the limitations of TI-BASIC and some people not always liking Lua, sometimes people might have felt there aren't enough alternatives that can suit them. Good job!  :thumbsup:
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Legimet

Quote from: DJ Omnimaga on February 04, 2015, 04:14:44 AM
New languages are always welcome on the TI-Nspire. With the limitations of TI-BASIC and some people not always liking Lua, sometimes people might have felt there aren't enough alternatives that can suit them. Good job!  :thumbsup:

Thanks. I think I'll do a benchmark similar to the one for Micropython (recursively calculate Fibonacci numbers). Duktape doesn't have a JIT but I don't think it should be bad. Games and other stuff should be possible once I add some "Duktape/C" functions for graphics, input, touchpad, etc. Duktape/C functions are native functions that can be called from JS code.

Also Vogtinator said that PyWrite should be easy to use for JS. The syntax highlighting is modular, and duktape.tns can be called in the same way as micropython.tns. Although the name might not fit :P

Dream of Omnimaga

Do you mean a benchmark to compare the speed of each Nspire language? As for games I was mostly thinking about classic javascript material, as in stuff that would work in Internet Explorer 6 and anything above. I assume that you wouldn't support JQuery and other more modern stuff lol :P

Also nice to see that we can use C in the language. Glad to hear about PyWrite as well. I guess the name should not be a serious issue as long as that feature is clearly documented. Some people might prefer being able to run everything from just 1 software/launcher, like on the 84+ with Doors CS.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Adriweb

Note: we (TI-Planet) intend to write a full-fledged news article about it soon, which will be like the MicroPython one (if not directly based on it).
A draft will probably be available on some google docs somewhere, I guess I can invite you on it, Legimet, if you want to participate in its writing :)  *

So, benchmarks and all :)

Also, yeah, jQuery-like bindings so that we can do stuff like : $("calculator").eval("x+x") and $("geometry").newGraph().plot("y1(x)","sin(x)") etc. :P



* PS : like the python one, it will be sent to TI as well - the more we get them to acknowledge good things like those, that can seriously be useful for STEM and learning in general, the better it will be (more chances of getting more support from them in the future, maybe for official support of such things...
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Snektron

But javascript != html, right? So why would you need jQuery?  ???
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Duke "Tape" Eiyeron

I think he meant bindings which allows to make fluent expressions : f1().f2().f3()...
  • Calculators owned: A lot.

Snektron

ooh, as in like, other apps? So if you'd want to do something with the Grapher $("Grapher")? I think i get it now :)
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Dream of Omnimaga

#8
Also I know that some apps attempted to port HTML to calcs before, so maybe in the future Duktape could be expanded to support minimal HTML or something similar? :P

Anyway, in response to @Adriweb (welcome to CodeWalrus, by the way :) ) I am hoping that this, combined with MicroPython, can help convincing TI that Ndless can be very handy for educational purposes as well. But with their Nspire mentality in the last years, maybe they'll just tell us to port MicroPython and Duktape to the TI-83 Premium CE and TI-84 Plus CE and that they have no plan to open the Nspire to native language programs? <_<
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Snektron

While youre at it convincing TI, try to get them to not rename their calculators every minute :P
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Duke "Tape" Eiyeron

Oh, I know how I would have named this project : Duke Tape. Much better. Quite. (-_(//)):
  • Calculators owned: A lot.

Dream of Omnimaga

  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Legimet

I just uploaded a version compiled with -O3 (it's a little larger, but faster)

Dream of Omnimaga

By the way, are there code examples that works both on calc and on a computer?
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Legimet

Well, there's always
print('Hello world!');

But seriously, an article which will be posted on TI-Planet with code examples. I have to add some modules first (filesystem, graphics, etc.)

Powered by EzPortal