Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: azazad on August 18, 2012, 12:44:09 am

Title: Nspire Java
Post by: azazad on August 18, 2012, 12:44:09 am
I have seen the other topics on Java for Nspire, and they all seem to be dead. So I will create a new one to keep the idea alive  :)

I hope the following will encourage greater interest in the idea of Java for the Nspire, and possibly lead to this idea becoming a reality. I have had some experience using Java ME for Lego robotics, and I am somewhat surprised that something similar is not available for the Nspire yet. The Nspire is the first TI calculator that can support a JVM with reasonable resources to spare, so why not?


Can the Nspire handle it?

A JVM (Java Virtual Machine) implementation called Lejos has been available for the Lego Mindstorms NXT robotic brick for years already: http://lejos.sourceforge.net/ (http://lejos.sourceforge.net/). I will use the Lego NXT as a basis for comparison with the Nspire.

The NXT's specs compared to the original Nspire non-CAS:
NXTNspire
Processor:ARM7 @ 48MHzARM9 eq. @ ~150MHz
RAM:64kB16MB
Flash ROM:256kB20MB

The Lejos project chose to implement Java ME instead of SE for obvious reasons. Java ME is probably the most we can hope for.

Minimum system requirements for Java ME:
RAM:8MB
ROM:5MB
(from http://www.oracle.com/technetwork/java/embedded/resources/me-embeddocs/index.html (http://www.oracle.com/technetwork/java/embedded/resources/me-embeddocs/index.html))

Note that these specs are for Linux. The Nspire's simpler OS should leave even more room to spare. Can the Nspire handle Java ME? I think so.


Is it practical on a time/effort basis?

Sure. The Lejos team did it for a much more limited platform, and did it well. Their implementation has garbage collection, threading, exception handling, synchronization, and many of the other features expected out of Java. Much of the core Lejos JVM and classloader can be reused for the Nspire. The LCD and input classes can be customized for the Nspire's hardware. (Color support on the CX)


Why Java? Isn't Lua enough?

Java's performance will definitely be better, possibly much better:

Even without Jazelle or JIT, Java should be fast enough for most purposes.

Lua is more of a scripting language, while Java is more of an application language. Lua is easier for beginners to pick up, while Java is a more efficient language for experienced programmers. Plus, more people should be familiar with Java, since it is more likely to be taught in CS courses and has a more C-like syntax.


There will be no shortage of Java programs that can be ported to the Nspire (excluding you-know-what ;) ). Thousands of MIDlets, or mobile phone apps, can be easily ported. With a suitable compatibility layer, we should even be able to run some applets. Java for the Nspire would unlock massive potential.
Title: Re: Nspire Java
Post by: AngelFish on August 18, 2012, 01:06:53 am
First off, I'm not trying to discourage you. Please don't take it that way :)

A JVM is a VERY difficult task. Even porting one is insanely complicated unless you're extremely comfortable with your language of choice.

Secondly, the Nspire does indeed support Jazelle, last I heard. Jazelle is not a complete hardware JVM though. It is a partial hardware implementation of some of the easier opcodes. It also supports vector tables for the opcodes it's missing, IIRC. The issue is that it's badly documented from what others have mentioned. You may want to check into it, but I wouldn't get my hopes up.

Also, the JVM is itself one of the most complicated pieces of software you will ever have the chance to modify. Understanding the architecture is no mean feat by itself.

TL;DR: Read the Sun spec. I don't care if it's not relevant. Read it. Read "Inside the Java Virtual Machine" as well. Also, spend a few weeks reading through all the ARM documentation on the Nspire's processor (can't remember the precise model number). Also, good luck and take your time. It will be like drinking from a firehose for the first few weeks.

:)

EDIT:

http://ourl.ca/15081/283054
Title: Re: Nspire Java
Post by: Hayleia on August 18, 2012, 05:04:20 am
Why Java? Isn't Lua enough?

Java's performance will definitely be better, possibly much better:
  • Lua is dynamically typed, while Java is statically typed
  • Lua programs must be parsed into tokens/bytecode before execution, Java programs are precompiled into bytecode ready for execution
  • Nspire Lua interpreter was written by TI (automatic performance hit! :D)
There is already C and assembly support on Nspires through Ndless, and those programs are precompiled and not written by TI. But I am sure you already know it since you are probably not going to write your JVM in Lua nor in Basic but probably in C or ASM ;)

Anyway, that seems to me a good idea. SDL was ported to the Nspire series and now I hear people saying "you can use nSDL for your program". Maybe your project will bring some "you can use nJVM for your program", who knows ? That would bring some activity out there for sure since not everybody knows C and some people prefer Java :D
Title: Re: Nspire Java
Post by: lkj on August 18, 2012, 09:10:59 am
Can the Nspire handle it?

A JVM (Java Virtual Machine) implementation called Lejos has been available for the Lego Mindstorms NXT robotic brick for years already: http://lejos.sourceforge.net/ (http://lejos.sourceforge.net/). I will use the Lego NXT as a basis for comparison with the Nspire.

The NXT's specs compared to the original Nspire non-CAS:
NXTNspire
Processor:ARM7 @ 48MHzARM9 eq. @ ~150MHz
RAM:64kB16MB
Flash ROM:256kB20MB

The Lejos project chose to implement Java ME instead of SE for obvious reasons. Java ME is probably the most we can hope for.

Minimum system requirements for Java ME:
RAM:8MB
ROM:5MB
(from http://www.oracle.com/technetwork/java/embedded/resources/me-embeddocs/index.html (http://www.oracle.com/technetwork/java/embedded/resources/me-embeddocs/index.html))

Note that these specs are for Linux. The Nspire's simpler OS should leave even more room to spare. Can the Nspire handle Java ME? I think so.

The OS is from TI, you know. I've heard it uses almost the whole RAM on non-CX Nspires. But compared with the NXT you still have much memory.

I hope this project succeeds and creates more interest in the Nspire :)
Title: Re: Nspire Java
Post by: Lionel Debroux on August 18, 2012, 09:55:51 am
Quote
and I am somewhat surprised that something similar is not available for the Nspire yet.
It's not surprising at all: the fact is that hardly anybody cares about the Nspire ;)

But your idea could bring more activity, so it should be pursued :)
Title: Re: Nspire Java
Post by: DWLooney on August 18, 2012, 12:26:46 pm
Wow, what a huge undertaking.

It'd be cool, though, if we could port minecraft to the nspire through it. O.O I don't care how slow it runs.

NO HURRY THOUGH, that is the prime numerator with these kind of projects.

Good luck, I would really like to see this come to fruition!
Title: Re: Nspire Java
Post by: epic7 on August 18, 2012, 04:51:45 pm
YES! YES! DO IT! :D
In learning java next month, and that would be awesome if I could use it in the nspire too!
Title: Re: Nspire Java
Post by: Jim Bauwens on August 18, 2012, 05:16:06 pm
Just a correction, the Nspire Lua interpreter is not written by TI. It's the standard lua, just without io and system libs, and some extra libs by them. And libs have nothing to do with the interpreter ;)

Hope you succeed porting it :)
Title: Re: Nspire Java
Post by: Lionel Debroux on August 19, 2012, 02:15:10 am
Quote
It's the standard lua, just without io and system libs, and some extra libs by them
IOW, it's significantly two-way incompatible with Lua on pretty much other platform.

But yeah, porting some Java framework + library ought to be possible on the Nspire, and unlock some potential (at least once in a while, when native code development is available to users).
Title: Re: Nspire Java
Post by: Adriweb on August 19, 2012, 03:51:29 am
Quote
It's the standard lua, just without io and system libs, and some extra libs by them
IOW, it's significantly two-way incompatible with Lua on pretty much other platform.
As much as a whole lot of platform-specific programming languages... I don't see why this is so important. Actually, it's "easy" to port what's required to make it work on normal Lua, as Jim's done (and even further, since it runs with JS too). So, when this part is done, it should be really good. (more talking about Cemetech's LuaZM for example, here)

But yeah, porting some Java framework + library ought to be possible on the Nspire, and unlock some potential (at least once in a while, when native code development is available to users).
Indeed, it would be a great new way opening to a lot of things
Title: Re: Nspire Java
Post by: Jim Bauwens on August 19, 2012, 03:47:02 pm
IOW, it's significantly two-way incompatible with Lua on pretty much other platform.
While true, it not really significant because basically every Lua platform is different .. just take a look at Love2D, Corona, implementations of Lua in games ..
None of those are compatible with each other, none. Also, the TI-Nspire API is pretty close to the one of Love2D (both event based, similar working structure) so porting stuff between those two platforms isn't that hard.

Anyway, I'm going too much of topic here. Sorry for that ^^
Title: Re: Nspire Java
Post by: _Nicco_ on October 21, 2012, 08:19:35 pm
Does anyone know what happened to this idea?  I'm not a great programmer yet but I'm willing to learn and try to help out.  It seems that all of these Java for Nspire projects die out quickly.  I'm sure that many people including me would like to have java on the Nspire (I'm learning java in my computer science class).  What can I do to help make it happen?
Title: Re: Nspire Java
Post by: jwalker on October 21, 2012, 08:39:44 pm
They die out fast because poeple just dont have enough time to work on it.
I do have to admit that having java would be nice...
also, nice necro :)
Title: Re: Nspire Java
Post by: _Nicco_ on October 21, 2012, 08:44:59 pm
Sorry it was the most recent thread on Java for the Nspire.
Title: Re: Nspire Java
Post by: TIfanx1999 on October 21, 2012, 08:59:19 pm
Qwerty's post actually gives a pretty good explanation.

I'd also add:
Although java would be nice, there are other good options available (C, ARM ASM, Lua). This being the case, java is not seen as a necessity.

Any implementation of Java would require ndless, and TI is constantly updating their OSes. Each update seems to block ndless. This is somewhat discouraging to prospective programmers. The mentality is "Why invest your time if it will all be for nothing?" C and ARM assembly (which also require ndless) already struggle with popularity, I fear Java would be the same.

Time. Such an undertaking is a big commitment, for a few individuals it would be a large undertaking. I think if this were to be pursed, a decently sized team would be a must.

Also, the necro is fine, as it is relevant to the topic. No need to start another thread. :)



Title: Re: Nspire Java
Post by: jwalker on October 21, 2012, 09:43:22 pm
very true, anyway the topic isnt that old.
Title: Re: Nspire Java
Post by: _Nicco_ on October 22, 2012, 12:00:30 am
I wanted to do something like this to:
1. Get better at Java coding since I'm taking an AP course on Computer Science and Java is the language that were using.
2. Force me to learn C or Assembly because I think that I need to learn either if not both of those languages as well.
3. Help out everyone else that wants to use Java on the Nspire.

I think that doing something like this will help me become a better programmer in general which is why i want to do it.  Also I think if I start it and get it going maybe people will end up joining the project and helping out.  The problem is that I am busy with school so it will take a while but I'm still willing to learn and try.
Title: Re: Nspire Java
Post by: Scipi on October 22, 2012, 12:24:37 am
If there was a team that would devote itself to this project, I'd donate some of my time towards helping, it'd just need to be active so work isn't gone to waste. Perhaps we could see what was done so far for khavi and merge the two efforts? Personally, if there are C implementations of the JVM out there, it'd be more of an effort of changing code to support Nspire-C as well as the hardware. Not a complete rewrite of every concept, so, at least on the outside, it doesn't look to be that monumental of an effort to port it. Then again, I didn't get that far into my own attempt due to difficulties figuring out the development environment for Nspire.
Title: Re: Nspire Java
Post by: ExtendeD on October 22, 2012, 07:58:34 am
If you're using a Linux OS, with the latest Ndless SDK, the installation is just a matter of unzipping the archive, opening NdlessEditor, and using the menus to build and transfer the program to the emulator.
HOMER-16, you should give it a try to forget your bad experience with the setup :)