Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => Topic started by: qazz42 on September 06, 2010, 03:12:20 pm

Title: C# for the nspire
Post by: qazz42 on September 06, 2010, 03:12:20 pm
(I hope I am in the right forum)

Well, I was wondering if this was possible, I really like C# and it would be awsome for it to be ported to the nspire

Though I don't know the possibility of this happening because C# is not compiled, it is interpreted..


Discuss


(my 333'rd post)
Title: Re: C# for the nspire
Post by: _player1537 on September 06, 2010, 03:25:04 pm
Woah... Wut?

I didn't think C# was interpreted, I could have sworn it was compiled...  You might be thinking of java which is interpreted on the fly (as it is being run).  Python is also interpretted.

Regardless, I think C# would be ok for the Nspire.  I'd personally stick with C.
Title: Re: C# for the nspire
Post by: qazz42 on September 06, 2010, 03:26:59 pm
Player.. uhh.. It is interpreted..


Title: Re: C# for the nspire
Post by: Lionel Debroux on September 06, 2010, 03:31:30 pm
Yeah, C# is interpreted, though the .NET VM and Mono, just like the JVM, have some form of JIT-ing.
For completeness: both C# and Java can be compiled [Ahead Of Time], but then you lose portability, and some capabilities.

[EDIT: making the second sentence more precise]
Title: Re: C# for the nspire
Post by: qazz42 on September 06, 2010, 03:39:12 pm
thanks Lionel

Now back to the topic!

Can C# be ported to the nspire once we get the proper libraries, this will make programming on the nspire alot easier for us .NET framework users (Like SirCmpwn)
Title: Re: C# for the nspire
Post by: Goplat on September 06, 2010, 03:52:29 pm
The .NET framework takes 850 MB of disk space. You couldn't fit it on 26 Nspires.
Title: Re: C# for the nspire
Post by: qazz42 on September 06, 2010, 03:59:05 pm
Crap. perhaps we can make our own C# interpriter?
Title: Re: C# for the nspire
Post by: DJ Omnimaga on September 06, 2010, 03:59:12 pm
Someone would most likely have to write a dumbed-down version of it, assuming it's interpreted, meaning a lot of stuff would be missing.

Maybe someone could write a similar language but compiled, though. At the same time, it would be nice to have Axe Parser for Nspires
Title: Re: C# for the nspire
Post by: qazz42 on September 06, 2010, 04:14:32 pm
I agree DJ, I think that could work, it could do without things like Web applications and such
Title: Re: C# for the nspire
Post by: Jonius7 on September 06, 2010, 07:34:29 pm
C#, well how about C++
Title: Re: C# for the nspire
Post by: bwang on September 06, 2010, 08:45:13 pm
Let's go for C++ support first. The Nspire is slow enough without the overhead of an interpreter.
It's probably possible though, since Java runs on slow, ARM platforms.
Title: Re: C# for the nspire
Post by: DJ Omnimaga on September 06, 2010, 10:17:55 pm
i am sure it could be possible. I am certain it can't be any worse than TI-BASIC interpreter source code
Title: Re: C# for the nspire
Post by: fb39ca4 on September 07, 2010, 12:26:40 pm
For c++, isn't it just a matter of using g++ rather than gcc?
Title: Re: C# for the nspire
Post by: bwang on September 07, 2010, 12:57:00 pm
We don't have a standard library, and it is doubtful that the OS contains a C++ standard library.
Title: Re: C# for the nspire
Post by: fb39ca4 on September 07, 2010, 02:53:49 pm
Isn't c++ backwrds compatible with C code?
Title: Re: C# for the nspire
Post by: qazz42 on September 07, 2010, 03:00:05 pm
I know that C++ should be first, but I still want to try and expand the idea of C# on the nspire if it is humanly possible
Title: Re: C# for the nspire
Post by: bwang on September 07, 2010, 05:02:52 pm
It is certainly possible; however, its uses probably will be limited by the overhead of the interpreter.
It is *much* harder than C++. We already have a C++ cross-compiler, but there isn't a complete C# interpreter for ARM devices yet.
Title: Re: C# for the nspire
Post by: qazz42 on September 07, 2010, 05:48:04 pm
Bwang, good point, perhaps I could work with someone to port C# to the nspire....

out of curiosity, what would it take to build your own interpreter?
Title: Re: C# for the nspire
Post by: _player1537 on September 07, 2010, 05:50:59 pm
Not much, (imo).  In TI-Basic, an interpreter is as easy as:
Code: [Select]
"sub(str1,A,1->v
For(A,1,Length(str1
If v="command
Do stuff
If v="other command
Do other stuff
End

It would be about the same thing in C, might be fun to write if I knew how to access files on the calc.  I'd be happy to help you :)  (although other people would probably be better suited to the job)
Title: Re: C# for the nspire
Post by: qazz42 on September 07, 2010, 05:53:19 pm
of cousre, I wish TI-Basic had a To.Upper method :P

and thats interesting player, if we get further on this, I would love to work with you
Title: Re: C# for the nspire
Post by: bwang on September 07, 2010, 05:55:29 pm
I've been thinking about doing this, although it would probably be easier to port one.
_player1537, you access files by using filesize() (in the utils.h in skeleton.zip attached to the first post on the Routines thread) to get the size, the fread to read it into an array, like so:
Code: [Select]
FILE* f;
int fsize;
char* buf;
f = fread("/documents/Examples/thegame.tns");
fsize = filesize(f);
buf = (char*) malloc(fsize);
fread(buf, 1, fsize, f);
close(f);
Title: Re: C# for the nspire
Post by: Lionel Debroux on September 12, 2010, 04:24:55 am
Quote
Isn't c++ backwrds compatible with C code?
C++ is partially backwards-compatible with C (in various situations, e.g. some forms of typecasts, a C++ compiler will refuse code that is valid in C), and it is interoperable with C (within a given ABI scheme, that is) through "extern C { }" blocks.
Title: Re: C# for the nspire
Post by: calc84maniac on September 12, 2010, 09:09:54 am
I've been thinking about doing this, although it would probably be easier to port one.
_player1537, you access files by using filesize() (in the utils.h in skeleton.zip attached to the first post on the Routines thread) to get the size, the fread to read it into an array, like so:
Code: [Select]
...
f = fread("/documents/Examples/thegame.tns");
...
close(f);
I'm sure these were typos, but those should be fopen and fclose. Just so nobody gets confused :)
Title: Re: C# for the nspire
Post by: SirCmpwn on September 14, 2010, 08:47:57 am
*facepalm* C# isn't interpreted...
At compile-time, it is compiled almost all the way.  Then, at run-time, it is JIT compiled (Just-In-Time) the rest of the way.  You can do the second step whenever you like and save the binary, thus making it not interpreted.
I have been planning for a while to make a .NET Framework-like thing and object oriented C# based language for the TI-83+/84+ (SE).
Title: Re: C# for the nspire
Post by: DJ Omnimaga on September 14, 2010, 12:12:27 pm
I assume that would be for KnightOS?

I wonder how easy it would be? Would it take like most of the calc memory?

Also no facepalming at people who are learning Sir. We do not want to lose members.
Title: Re: C# for the nspire
Post by: Juju on September 14, 2010, 12:30:41 pm
Microsoft made a .NET Compact Framework made to fit on most handheld devices with low disk space, such as phones running Windows CE. According to Wikipedia, it takes up 12 MB, which could fit on the nspire. There is also the .NET Micro Framework, which takes no more than 300KB of space and doesn't need an OS to run, it could even fit on a TI-84. So C# on the nspire should be possible with at least the .NET Micro Framework. Plus the fact Microsoft announced they will release the .NET Micro Framework 4.0 source code under an Apache License 2.0, it would be awesome if someone manages to run some C# on the nspire.

Sources:
http://en.wikipedia.org/wiki/.NET_Compact_Framework
http://en.wikipedia.org/wiki/.NET_Micro_Framework
Title: Re: C# for the nspire
Post by: DJ Omnimaga on September 14, 2010, 12:40:25 pm
Mhmm, if it's 12 MB and cannot be shrinked in size, it would take pretty much all of the Nspire mem or close. I think the original OS 1.1 leaves you with like 14-17 MB free x.x

Will the .NET Micro Framework thing be smaller?

EDIT: Nvm checked Wikipedia and it seems pretty small for the Nspire.
Title: Re: C# for the nspire
Post by: qazz42 on September 14, 2010, 02:43:57 pm
*facepalm* C# isn't interpreted...
At compile-time, it is compiled almost all the way.  Then, at run-time, it is JIT compiled (Just-In-Time) the rest of the way.  You can do the second step whenever you like and save the binary, thus making it not interpreted.
I have been planning for a while to make a .NET Framework-like thing and object oriented C# based language for the TI-83+/84+ (SE).


D: IT ISNT?!!?!?! I did not know that.... my C# book says it is
Title: Re: C# for the nspire
Post by: Lionel Debroux on September 14, 2010, 02:49:01 pm
SirCmpwn, I already mentioned early in this topic that there are JITs in the .NET interpreters ;)
(and I have just edited the corresponding post to make "AOT" explicit)
Title: Re: C# for the nspire
Post by: SirCmpwn on September 14, 2010, 04:46:15 pm
Lionel, okay.  I'm just pointing out that it doesn't have to be interpreted.
DJ, probably, KOS is better suited to object oriented programming.
Title: Re: C# for the nspire
Post by: Juju on September 14, 2010, 07:05:26 pm
Well, the resulting .exe's are so well integrated in Windows you can mistake them for actual binaries. .NET is interpreted because you can run the same binary on all OSes with mono, much like Java. But sometimes, some executables uses Windows .dll's so you can't run it in mono.
Title: Re: C# for the nspire
Post by: DJ Omnimaga on September 14, 2010, 10:49:45 pm
Is mono something like Wine? I remember certain programs like RPG Maker VX database editor would not work in it.
Title: Re: C# for the nspire
Post by: Juju on September 14, 2010, 11:50:11 pm
No, Wine emulates the whole Windows while Mono is only the open source version of .NET Framework.
Title: Re: C# for the nspire
Post by: DJ Omnimaga on September 15, 2010, 12:26:15 am
Ah ok thanks for the info :)
Title: Re: C# for the nspire
Post by: bwang on September 15, 2010, 12:41:03 am
Wine Is Not an Emulator.
Just had to point that out :D
Title: Re: C# for the nspire
Post by: DJ Omnimaga on September 15, 2010, 12:50:00 am
What is it, then? X.x
Title: Re: C# for the nspire
Post by: bwang on September 15, 2010, 02:33:19 am
It's a compatibility layer that tricks Windows programs into thinking they are on Windows - a re-implementation of the Windows API, essentially.
Title: Re: C# for the nspire
Post by: Netham45 on September 15, 2010, 02:50:54 am
Wine is more of a plug that converts a north american outlet into a european outlet. The european device thinks it's on a european outlet, when it's actually on a north american one.


Does that make any sense? My mind is shutting off for the day.
Title: Re: C# for the nspire
Post by: DJ Omnimaga on September 15, 2010, 02:54:05 am
Ah ok I see, thanks for the clarification :)
Title: Re: C# for the nspire
Post by: Lionel Debroux on September 15, 2010, 08:31:50 am
Quote
Mono is only the open source version of .NET Framework.
Well, technically speaking, there's no open source version of the .NET framework ;)
Mono is a reimplementation of the .NET Virtual Machine and of many classes that form the C#/VB.Net/whatever CLI-based language.

I don't know whether Mozilla contributors have fixed the causes of the fact that Windows Firefox running under Wine under Linux is faster than Linux Firefox on Linux. It's not a matter of the compiler used for compiling the respective versions, it's a testimony to the lesser optimization of Firefox on non-Windows (because 1) the Linux memory management is better than Windows' and 2) the Wine infrastructure adds a bit of weight on top of Linux, too).
Title: Re: C# for the nspire
Post by: qazz42 on September 15, 2010, 02:42:14 pm
O_O

I leave this topic for a while, and ow I dont understand what is going on... 0x5
Title: Re: C# for the nspire
Post by: Jonius7 on October 06, 2010, 03:30:32 am
i just came back to it, i think they're moving into the details of .net framework or something, qazz 42. so now it's more like .NET framework for the nspire, not just C#. btw any progress? im confused also.
Title: Re: C# for the nspire
Post by: qazz42 on October 06, 2010, 02:52:45 pm
ah, ok, I get it

anywho, Nah, this is more about if it is possible, there is no physical work done YET