Alternatively, join us on Discord.

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 1 Guest 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

DJ 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:

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

DJ 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.

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...
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Snektron

But javascript != html, right? So why would you need jQuery?  ???
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()...

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 :)
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


DJ Omnimaga

February 05, 2015, 06:15:05 pm #8 Last Edit: February 05, 2015, 06:17:11 pm by DJ Omnimaga
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? <_<

Snektron

While youre at it convincing TI, try to get them to not rename their calculators every minute :P
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. (-_(//)):

DJ Omnimaga


Legimet

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

DJ Omnimaga

By the way, are there code examples that works both on calc and on a computer?

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