cnCalc计算器论坛

 找回密码
 注册
搜索
查看: 7840|回复: 1

[Nspire] Python & TI-Nspire, together thanks to "Micro Python"

[复制链接]
发表于 2014-9-14 22:47:12 | 显示全部楼层 |阅读模式
TL;DR : Initial TI-Nspire port of Micro Python now available !



History
Since OS 3.0.1.1753 in April 2011, in addition to the usual platform-specific BASIC language, the Nspire series has provided an implementation of an established programming language originally made for other platforms and well-suited to embedded platforms due to its relatively limited footprint and reasonable execution efficiency (for an interpreted language), namely Lua.
Even if the Nspire’s Lua implementation is crippled by the removal of standard io and os packages (making it unable to e.g. read and write files on the FS), it immediately became a popular development option for the Nspire: the Nspire’s Lua can draw single pixels to the screen and read from the keyboard, unlike the BASIC (which is much slower too) :)
Fast forward three years. Lua keeps being lightweight, it remains a popular development option for several classes of programs (e.g. the AI and suchlike higher-level functionality of game engines), and there’s LuaJIT for making programs run faster.
However, in the general developer population, it’s easy to find language popularity contests (e.g.  http://blog.codeeval.com/codeevalblog/2014 , http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html , http://spectrum.ieee.org/static/ ... ogramming-languages ) which concur that Lua is (much) less popular than multiple other well-known scripting-type languages, especially Javascript, Perl, PHP, Python, Ruby (in alphabetical order).


Motivations
Based on the above, it makes lots of sense to (try and) port other established scripting languages among Javascript, Perl, PHP, Python, Ruby to calculators - just because we can, and also because the subset of calculator users who will become professional software developers one day might want to learn popular languages first :)
Before even starting the process, we know that fitting the execution environments (written in C or C++) for these languages, on even the most powerful calculators (TI Nspire, HP Prime), is a challenge due to:
  • the raw CPU power, amount of RAM and amount of persistent storage of calculators being generally highly sub-par by modern market standards;
  • the TI Nspire being a hostile platform for developing native code programs, even if this improved recently with the expanded Ndless SDK featuring C++ support and newlib (Vogtinator, lkj et al.), already used for porting giac/xcas to the Nspire (cf. KhiCAS). The HP Prime is an open platform, it has a faster CPU and more Flash (althrough less RAM) than the Nspire CX, but its software is undocumented at the time of this writing, and the platform is not really popular among users.


Therefore, we (TI-Planet staff) sparked the port of some Python flavor to the Nspire. Python is clearly the most popular choice among the 5 ones listed above, and it has become the most popular language for learning purposes, according to a recent survey: http://www.pcworld.com/article/2 ... rning-language.html .


Porting process
Pretty much all of the work was done by the well-known Fabian “Vogtinator” Vogt,  famous for multiple pieces of work that we mentioned in the past, such as:
* contributions to the Nspire port of Linux and the automated build system ( http://tiplanet.org/nspire-linux-builds );
* contributions to the base library and toolchain of Ndless, which made it possible to port the powerful Giac/Xcas engine to the Nspire, mentioned above;
* Nspire WAV file player;
* Crafti, a native code Minecraft-like program, showcasing the nGL 3D engine that he programmed as well.

  • porting full-blown CPython + libs: it was not done, as it would be (much ?) more work and pose interesting portability challenges. It’s probably better trying something simpler first :)
  • porting python-on-a-chip, known as “p14p” (which Lionel Debroux had already partially ported to the TI-68k/AMS platform) : the port is done and it was pretty quick. However, it could only execute bytecode generated by a specific version of CPython and not python source; it was quite limited in available functions and data-types; fairly few code changes have been performed over the past three years.
  • porting MicroPython (a successful Kickstarter project): that, too, was a quick success. Micro Python supports a newer version of Python than p14p does, it’s more featureful than p14p is, and it’s still under active development.
    Performance on the Fibonacci test was decent, though lower than Nspire Lua. In order to improve speed, Fabian set to write a native ARM code emitter, which he contributed to upstream micropython; it was quickly integrated :)
    Some tests on developement versions show that Micro Python is then faster than Lua when using the "JIT".




While the code size (several hundreds of KBs on the Nspire) and RAM consumption of Micro Python are laughably tiny by modern standards, they’re above the specs of most calculator models on the marketplace... Only the Nspire family, the Prime can easily run Micro Python; maybe the Casio fx-CP400, which has lower specs (especially the amount of RAM), is even more expensive, and is a closed platform on which nobody has yet executed arbitrary native code, could do it too. However, definitely not the TI-Z80 series, almost certainly not the TI-68k series (even when executing from Flash, complex programs would probably be troublesome), and AFAICT not Casio fx-98*, Prizm or HP-49G+/50G for the same reason: too little (available) RAM.


Source & Downloads : http://tiplanet.org/forum/viewto ... mp;p=169279#p169279
(News article by Lionel Debroux, Adriweb and Critor)




发表于 2014-12-17 22:15:21 | 显示全部楼层
抢沙发
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cnCalc计算器论坛

GMT+8, 2024-12-23 08:03 , Processed in 0.078573 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表