NXC classes
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
NXC classes
Is it reasonably likely that NXC will support classes in the not-so-distant future?
Class support could be a huge time and resource saver.
I guess the answer is probably no, because otherwise it would likely already support them.
Class support could be a huge time and resource saver.
I guess the answer is probably no, because otherwise it would likely already support them.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: NXC classes
If you're looking for an OOPL, you might want to check out Lejos. A language where OO is an afterthought will end up feeling like an ugly kludge, like Perl's OO implementation.
- Xander
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: NXC classes
In the past I have considered leJOS, but for now I want to stick with C type languages. I feel like I am fairly versed in NXC, as it's the primary language I used for learning programming concepts, and I would like to be able to learn more about classes in a familiar setting. So far I have only used classes in C++ for Arduino libraries, and I really love them.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: NXC classes
Lejos is not that scary It has a very rich collection of classes, I think you'll like it.
- Xander
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
Re: NXC classes
I think Matt would like leJOS too. The only drawback being that you have to switch to a firmware that does not support NXT-G, if you want to keep using that language for some reason.
In any case, I have no plans for trying to add support for classes to NXC.
John Hansen
In any case, I have no plans for trying to add support for classes to NXC.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: NXC classes
Thanks both of you.
I'm not concerned in the least with putting leJOS FW on one of my NXTs
Okay, that's fine.
I'll look into trying out leJOS.
I'm not concerned in the least with putting leJOS FW on one of my NXTs
Okay, that's fine.
I'll look into trying out leJOS.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: NXC classes
Well, you don't actually have to run Java. There is also nxt-OSEK which you can program in C++ http://lejos-osek.sourceforge.net/mattallen37 wrote:In the past I have considered leJOS, but for now I want to stick with C type languages. I feel like I am fairly versed in NXC, as it's the primary language I used for learning programming concepts, and I would like to be able to learn more about classes in a familiar setting. So far I have only used classes in C++ for Arduino libraries, and I really love them.
-
- Posts: 175
- Joined: 28 Dec 2011, 13:07
- Location: Gelderland, Netherlands
- Contact:
Re: NXC classes
Or Mirah, which is more like Ruby than C, I guess, but anyway, runs like a charm on Lejos.
-- Pepijn
http://studl.es Mindstorms Building Instructions
http://studl.es Mindstorms Building Instructions
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: NXC classes
I do like the C++ syntax though and I think OO would be a nice addition to NXC. I did make some deeper considerations on how to make OO work on the NBC level and I think it would feasible to have basic OO support in NXC. (I wrote a post with my thoughts on my blog back then.)mightor wrote:If you're looking for an OOPL, you might want to check out Lejos. A language where OO is an afterthought will end up feeling like an ugly kludge, like Perl's OO implementation.
One of the reason I think OO would work well with NXC is because of the underlying firmware. Many of the basic functions is implemented by the use of structs so an OO interface to those makes much sense. For example LineOut could be implemented like this:
Code: Select all
class Line{ //This class is the DrawLineType struct type
public:
char Result;
LocationType StartLoc;
LocationType EndLoc;
unsigned long Options;
Line( LocationType start, LocationType end ){
StartLoc = start;
EndLoc = end;
}
Line( int x1, int y1, int x2, int y2 ){
StartLoc.Set( x1, y1 );
EndLoc.Set( x2, y2 );
}
void draw(){
SysDrawLine( this ); //ASM here, just can't remember it from the top of my head...
}
private:
static Line temp;
static mutex tempmutex;
public:
static char draw( int x1, int y1, int x2, int y2, Options = DRAW_OPT_NORMAL ){
Acquire( tempmutex );
temp.StartLoc.Set( x1, y1 );
temp.EndLoc.Set( x2, y2 );
temp.Options = Options;
temp.draw();
return l.Result; //This would need to be done in ASM so Release is actually executed
Release( tempmutex );
}
static char draw( LocationType start, LocationType end, Options = DRAW_OPT_NORMAL ){
Acquire( tempmutex );
temp.StartLoc = start;
temp.EndLoc = end;
temp.Options = Options;
temp.draw();
return l.Result; //Same note as above
Release( tempmutex );
}
};
You could make some pretty neat API improvements imo.
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Re: NXC classes
I had a quick peek at Mirah but I am not seeing the advantages of running that on a JVM vs Java. What can I do with Mirah that Lejos won't let me? How would you use it combination with Lejos' classes or is that not an option and would one have to redevelop all of those?pepijndevos wrote:Or Mirah, which is more like Ruby than C, I guess, but anyway, runs like a charm on Lejos.
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
Who is online
Users browsing this forum: Semrush [Bot] and 2 guests