π
<-
Chat plein-écran
[^]

nSquirrel on Ti-Nspire

C, C++, ASM...

nSquirrel on Ti-Nspire

Unread postby Eiyeron » 07 Apr 2016, 00:34

nSquirrel
Squirrel on Ti-Nspire

Last release version (v1.0.1) : https://github.com/Eiyeron/squirrel/rel ... rrel_1.0.1
Project repository : https://github.com/Eiyeron/squirrel/

nSquirrel (interpreter + n2SDLib) branch : https://github.com/Eiyeron/squirrel/tree/nSquirrel

"Squirrel is a high level imperative, object-oriented programming language, designed to be a light-weight scripting language that fits in the size, memory bandwidth, and real-time requirements of applications like video games."

Although Squirrel offers a wide range of features like:
  • Open Source MIT licence
  • dynamic typing
  • delegation
  • classes & inheritance
  • higher order functions
  • lexical scoping
  • generators
  • cooperative threads (coroutines)
  • tail recursion
  • exception handling
  • automatic memory management (CPU bursts free; mixed approach ref counting/GC)
  • both compiler and virtual machine fit together in about 7k lines of C++ code and add only around 100kb-150kb the executable size
  • optional 16bits characters strings
  • powerful embedding api
  • eg. function/classes can be defined by scripts or in C
    • eg. objects can fully exist in the VM or be bound to native code
    • eg. classes created in C can be extended by scripts or vice-versa
    • and more

nSquirrel is a fork of this language destined for Ti-Nspires. The core language will be easily embeddable into Ndless projects as the project offers libraries and API to mess with it. Thus, it's included with bindings to n2DLib to allow playing with the screen and the keyboard.

nSquirrel

Instructions :
- Download the archive containing the program (sq.tns) and if wanted, the example scripts.
- Install your sq.tns on your calc's nspire folder
- Now you can launch the interpreter for an interactive session ( quit() to exit it) or launch a .nut script (only after running the exectuable once). NOte that thanks to nspireio, you have to press twice Enter to validate your input.
- The interpreter registering itself to open .nut files, to execute such scripts, you will just have to click on them.

Notes
- For further versions, I'll probably provide two versions of the binaries, ones to compile nSquirrel's interpreter (which uses Nspire-IO) and one to be included in projects.

Example script
Image

Squirrel sur Ti-Nspire

Dernière version (v.1.0.1) : https://github.com/Eiyeron/squirrel/rel ... rrel_1.0.1
Source du projet : https://github.com/Eiyeron/squirrel/

Branche avec interpréteur nSquirrel (+n2DLib) : https://github.com/Eiyeron/squirrel/tree/nSquirrel

"Squirrel est un langage de programmation impératif de haut niveau et orienté objet, conçu pour être un langage de script léger qui rentre les conditions de taille, mémoire et resosurces de temps réels dans des applications comme des jeux vidéos."

(Autrement dit : C'est un langage de programmation destiné à être embarqué comme le lua)

Même si Squirrel offre un large panel de fonctionnalités :
  • Licence MIT Open Source
  • typage dynamique
  • délégation
  • classes et héritage
  • fonctions de haut niveau
  • encapsulation lexicale
  • générateurs
  • threads coopératifs (coroutines)
  • simplification automatique de récursion terminale
  • gestion des exceptions
  • Gestion automatique de la mémoire (sans pic d'utilisation du CPU; approche mixte de collection de déchets et de comptage de références)
  • Le compilateur et la VM tiennent sur environ 7000 lignes de C++ et n'ajoutent qu'à peu près 100-150kb de données sur l'exécutable.
  • en option, chaînes de caractères 16-bits
  • puissante API embarquée
  • exemples avec des classes et fonctions définissables par script ou en C
    • Ex : les objets peuvent n'exister que dans la VM ou être lié à du code natif
    • Les classes définies en C peuvent être étendues par des scripts et vice versa
    • Et plus!

nSquirrel est un dérivé de ce langage destiné aux calculatrices Ti-Nspire. Le cœur du programme sera facilement intégrable dans des projets Ndless car le projet offre des librairies et une API pour intéragir avec. Ainsi, le programme est inclus à la librarie n2DLib pour permettre de jouer avec l'écran et le clavier.

nSquirrel

Instructions d'installation :

  • Téléchargez l'archive contenant l'interpréteur (sq.tns) et si voulus, les scripts d'exemple
  • Installez sq.tns dans le dossier "ndless" de votre calculatrice
  • À présent, vous pouvez soit lancer l'interpréteur (quit() pour quitter) ou vous pouvez lancer un fichier .nut.tns (après avoir au moins lancé une fois l'interpréteur). Notez qu'à cause d'nspire-io, vous avez à appuyer deux fois sur Enter pour valider.
  • L'interpréteur s'enregistre automatiquement pour ouvrir les fichiers .nut à leur exécution.

Notes
Pour les versions futures, je fournirai 2 versions des fichiers binaires : l'une pour compiler l'interpréteur nSquirrel (qui utilise Nspire-IO) et l'autre pour être incluse dans des projets

Exemple de script :
Image
Attachments
nSquirrel 1.0.0.zip
(2.07 MiB) Downloaded 36 times
Last edited by Eiyeron on 09 Apr 2016, 00:16, edited 1 time in total.
User avatar
Eiyeron
Niveau 10: GR (Guide de Référence)
Niveau 10: GR (Guide de Référence)
Level up: 17.7%
 
Posts: 20
Joined: 30 May 2012, 16:56
Gender: Not specified
Calculator(s):

Re: nSquirrel : Squirrel Programming on Ti-Nspire

Unread postby Adriweb » 07 Apr 2016, 07:52

This is definitely very cool - Yet another third-party language on the Nspire platform :D
The demo is pretty nice, too.

Regarding n2DLib, I think that one will have to be recompiled/adapted to work with the latest Nspire CX revisions (rev. W ("CR 4")) with their new LCDs, and maybe nSquirrel as well

(And thanks for crossposting!)
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 53.8%
 
Posts: 12877
Images: 1085
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
Class: (ingénieur)
Twitter: adriweb
GitHub: adriweb

Re: nSquirrel : Squirrel Programming on Ti-Nspire

Unread postby Eiyeron » 07 Apr 2016, 10:07

Concerning the newer revision, indeed, that must be something to be added, but on n2DLib's side. I should add another issue ticket to Matref's repository. As soon as this will be fixed or loadPNG, I'll update nSq to accept these changes.

I also am a bit busy right now but the french translation will come later. You're welcome for the crosspost, thanks Streetwalrus to have suggested me to post it here. What should be next? Should I post to the archive or should I keep it here for now?
User avatar
Eiyeron
Niveau 10: GR (Guide de Référence)
Niveau 10: GR (Guide de Référence)
Level up: 17.7%
 
Posts: 20
Joined: 30 May 2012, 16:56
Gender: Not specified
Calculator(s):

Re: nSquirrel : Squirrel Programming on Ti-Nspire

Unread postby Ti64CLi++ » 07 Apr 2016, 12:34

Very good Eiyeron. :bj:
For a member of Planète Casio and a Casio adept, very good. ;)
Image
User avatar
Ti64CLi++Modo
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 78.7%
 
Posts: 3184
Images: 61
Joined: 04 Jul 2014, 14:40
Location: Clermont-Ferrand 63
Gender: Male
Calculator(s):
Class: Maths Sup
GitHub: Ti64CLi

Re: nSquirrel : Squirrel Programming on Ti-Nspire

Unread postby Eiyeron » 07 Apr 2016, 14:32

I find this a bit reducing me, summing me as "a Casio-ist". I mean, it's already been years that I registered to Omnimaga because I was programming also on Ti (like Snak'11, HBE, a stupid experiment with my own (a bit of Street's too) game engine in the works.

I don't hold any ressentment or grudges, don't worry though. :p I switched for the Nspire only because of the better support of C/C++ and the better power and memory.
User avatar
Eiyeron
Niveau 10: GR (Guide de Référence)
Niveau 10: GR (Guide de Référence)
Level up: 17.7%
 
Posts: 20
Joined: 30 May 2012, 16:56
Gender: Not specified
Calculator(s):

Re: nSquirrel : Squirrel Programming on Ti-Nspire

Unread postby Ti64CLi++ » 07 Apr 2016, 15:38

Excuse me, but I just know you on Planète-Casio. Sorry :?
Image
User avatar
Ti64CLi++Modo
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 78.7%
 
Posts: 3184
Images: 61
Joined: 04 Jul 2014, 14:40
Location: Clermont-Ferrand 63
Gender: Male
Calculator(s):
Class: Maths Sup
GitHub: Ti64CLi

Re: nSquirrel : Squirrel Programming on Ti-Nspire

Unread postby Eiyeron » 07 Apr 2016, 20:38

Again, no problem. That aside, I wonder how much people will be interested in this thing. I should provide some better examples, shouldn't I?
User avatar
Eiyeron
Niveau 10: GR (Guide de Référence)
Niveau 10: GR (Guide de Référence)
Level up: 17.7%
 
Posts: 20
Joined: 30 May 2012, 16:56
Gender: Not specified
Calculator(s):

Re: nSquirrel : Squirrel Programming on Ti-Nspire

Unread postby Adriweb » 07 Apr 2016, 20:43

I didn't know the language, at first, but looking at the example scripts, it's pretty damn impressive \o/
Looks like a Lua on steroids (especially with the bindings to Nspire-specific stuff) :)
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 53.8%
 
Posts: 12877
Images: 1085
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
Class: (ingénieur)
Twitter: adriweb
GitHub: adriweb

Re: nSquirrel : Squirrel Programming on Ti-Nspire

Unread postby Lionel Debroux » 07 Apr 2016, 20:45

Good to see another "standard", alternative language on the Nspire, showcasing once more what one can do with access to native code :)

Another "standard" language for which an embeddable implementation exists is TCL, with libjim, which provides welcome extensions to old-style TCL (which is not usually considered high quality / maintainability, and is not high performance either, but is portable).

More / better examples are seldom a bad thing.

This is newsworthy, but we're a bit busy today...
Membre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
User avatar
Lionel DebrouxSuper Modo
Niveau 14: CI (Calculateur de l'Infini)
Niveau 14: CI (Calculateur de l'Infini)
Level up: 6.6%
 
Posts: 6498
Joined: 23 Dec 2009, 00:00
Location: France
Gender: Male
Calculator(s):
Class: -
GitHub: debrouxl

Re: nSquirrel : Squirrel Programming on Ti-Nspire

Unread postby Eiyeron » 08 Apr 2016, 01:27

An example with lots of comments will come a little later, with a bugfix about some things that I overlooked (like a wrong argument usage on drawSpritePart and wrong key names setting).

Lionel Debroux wrote:Good to see another "standard", alternative language on the Nspire, showcasing once more what one can do with access to native code :)


Yeah, that's what I wanted to show with this calc, that it's something that we usually overlook its true power and that it deserves some better solutions to allow people program on it.

Lionel Debroux wrote:Another "standard" language for which an embeddable implementation exists is TCL, with libjim, which provides welcome extensions to old-style TCL (which is not usually considered high quality / maintainability, and is not high performance either, but is portable).

There are actually quite a number of embeddable script languages. I chose this one because it had a good C-like syntax (a bit quirky on some things but I still like it) and that it would offer similar performances to Lua (if not a small slower on some things but more stable performance-wise and being a small faster on some bits).
Attachments
screen.png
screen.png (1.46 KiB) Viewed 1537 times
User avatar
Eiyeron
Niveau 10: GR (Guide de Référence)
Niveau 10: GR (Guide de Référence)
Level up: 17.7%
 
Posts: 20
Joined: 30 May 2012, 16:56
Gender: Not specified
Calculator(s):

Next

Return to Native: Ndless, Linux, ...

Who is online

Users browsing this forum: No registered users and 3 guests

-
Search
-
Featured topics
L'OS 5.5 de la TI-83 Premium CE / 84 Plus CE supprime l'assembleur - la plupart des jeux et certains programme ne fonctionneront plus
Omega, le fork étendant les capacités de ta NumWorks, même en mode examen !
Découvre les nouvelles fonctionnalités en Python de l'OS 5.5 pour la 83PCE/84+C-T Python Edition
Comparaisons des meilleurs prix pour acheter sa calculatrice !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...

Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety 
-
Stats.
366 utilisateurs:
>348 invités
>14 membres
>4 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)