To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 23712
23711  |  23713
Subject: 
Robolab as a tool for teaching programming
Newsgroups: 
lugnet.robotics
Date: 
Wed, 16 Mar 2005 16:01:04 GMT
Viewed: 
3725 times
  
In lugnet.robotics, Steve Hassenplug wrote:
   On Tue, March 15, 2005 12:01 pm, John Hansen said:
   And I don’t feel angry or even particularly annoyed that FLL doesn’t allow using a real programming language in its competitions. Just discouraged and frustrated, mostly.

So, this is the same argument we’ve been hearing for the last couple weeks, right? NQC is the only “Real” programming language that can be used on the RCX (with standard firmware). If we can’t use NQC, I won’t participate.

I apologize for the “doesn’t allow using a real programming language” statement. It was clearly false and I realized it immediately after I posted. I didn’t want to issue an immediate correction because I hoped that people would ignore it as an example of hyperbole and focus on my arguments instead. Unfortunately that didn’t happen. Oh, well. Of course LASM and MindScript are both real programming languages. Robolab and RIS are real code generators for those two real programming languages. Please forgive my incorrect statement.

  
   code using lots of little pictures. But don’t even try to argue that it teaches children good programming skills because it doesn’t.

NQC doesn’t teach any better programming skills than Robolab. You can create exactly the same “spaghetti code where you ‘jump’ whenever you wish” as with Robolab. The coaches need to teach good programming.

Sorry, I wasn’t clear, I guess. I didn’t state anywhere that NQC teaches good programming skills. Others here seem to have suggested that Robolab teaches kids good programming skills (flowcharting being one of them). I was rebutting what I believe is a demonstrably false assertion. I demonstrated that it was false. Robolab is a LASM code generator. LASM doesn’t have higher-level language constructs such as block statements, while loops, etc... As a result Robolab teaches kids to use jumps and labels (since that is how you construct loops using LASM). Unfortunately, it doesn’t allow you to name your labels in a meaningful way (as far as I can determine) and it doesn’t let you draw a process flow directional arrow connecting the jump icon with the label icon (which a real flowcharting tool would let you do). It uses lots of different icons to represent the “chk” LASM opcode, hard-coding most of the parameters (forcing kids to use greater-than and less-than-or-equal comparisons, as far as I can tell). Because of these (and many other) reasons Robolab teaches kids programming patterns that they will need to unlearn.

LASM, at least, allows for defining meaningful label names and constants (using #define) so that programs can look like this:
#define x 35
#define y 34
#define SOUND_CLICK 0
#define SOUND_DOWN 2
#define OUT_ABC 7
#define OUT_A 1
#define OUT_C 4
#define Forward 2
#define srcVar 0
#define srcConst 2
#define srcRand 4
#define main 8
#define LessThan 1
#define GreaterThan 0

;main
 task main
 pwr OUT_ABC, srcConst, 5
 dir Forward, OUT_ABC
 setv x, srcRand, 20
 setv y, srcRand, 30
 chk srcVar, x, LessThan, srcVar, y, x_is_not_less_than_y
 pwr OUT_A, srcConst, 3
 jmp end_if_x_less_than_y
x_is_not_less_than_y:
 pwr OUT_C, srcConst, 3
end_if_x_less_than_y:
 plays SOUND_DOWN
 wait srcConst, 200
infinite_loop:
 plays SOUND_CLICK
 wait srcConst, 200
 chk srcConst, 10, GreaterThan, srcVar, x, keep_looping
 jmp stop_looping
keep_looping:
 setv x, srcRand, 20
 jmp infinite_loop
stop_looping:
 endt
In Robolab you would have colored arrows pointing up over here and arrows with the same color pointing down somewhere else, with nothing but their color to suggest that they are related. Or you’d have a little tiny box containing a number attached to the up arrow box and that same number attached to the down arrow box. And instead of SOUND_CLICK you’d have a little tiny box containing the number 1 attached to an icon that looks like it might cause the RCX to play a sound. Hopefully none of the kids would ever look at the generated LASM code and notice that some of their tiny little numbers have been changed from being 1-based to being 0-based while others were left unmodified. The Robolab program would be a picture that would be hard to figure out without a lot of Robolab experience. Perhaps someone will be willing to draw it for us and post a link to it.

In NQC it looks like this:
#pragma noinit

task main()
{
  SetPower(OUT_A+OUT_B+OUT_C, 5);
  SetDirection(OUT_A+OUT_B+OUT_C, OUT_FWD);
  int x = Random(20);
  int y = Random(30);
  if (x < y)
    SetPower(OUT_A, 3);
  else
    SetPower(OUT_C, 3);
  PlaySound(SOUND_CLICK);
  Wait(200);
  while (true)
  {
    PlaySound(SOUND_DOWN);
    Wait(200);
    if (x < 10) break;
    x = Random(20);
  }
}
NQC does not force kids to learn bad programming patterns. Yes, it supports goto but it does not require its use. Instead it provides numerous modern higher-level programming constructs that help new programmers develop good programming habits and skills.

Because Robolab is a LASM code generator and because of the way it was designed I assert that it does teach bad programming practices (bad flowcharting, magic numbers throughout code, off-by-one errors, spaghetti code due to jumps/lands with meaningless labels, meaningless identifiers, etc...) I could be wrong about Robolab since my experience with it is limited to examining online documentation and examples. Maybe it doesn’t force kids to use programming techniques that teach them bad practices. Maybe there are facilities in Robolab that allow for less-than and greater-than-or-equal-to comparisons. Maybe there is a way in Robolab to define meaningful variable, constant, and label names. Maybe there is a way to use one common choice icon and define its parameters rather than forcing kids to use a different icon for each possible type of choice they want to specify. If I am wrong I hope someone will show me the error of my ways.

   Or, they could use Mindscript, which doesn’t allow the use of Goto’s.

MindScript is a great language. I’m glad FLL relented and allowed its use directly. Unfortunately very few people worldwide, let alone FLL teams, are familiar with it. At least that is the strong impression I am left with. There is only one tool that I know of which provides extensive support for programming in MindScript. And you can’t use that tool in FLL competitions. RIS is a MindScript code generator but it doesn’t give kids the opportunity to experience the language directly.

   Given the restrictions Robolab imposes, it’s not hard to develop an example that is more difficult to code in Robolab. But, it’s still very possible.

I would do it using a flag, like this psudocode:
set redflag = 0
if (RotationAmount < 50 && loopCount >= 4) set redflag = 1
if AmbientTemp < 32 set redflag = 1
if Message() == 13 set redflag = 1

In your pseudocode you evaluate all three parts of the logical OR which is not done in NQC or most other modern programming languages. To account for that you would need to additionally check the value of redflag prior to the check of AmbientTemp or Message(). I believe that a logical AND in Robolab would require two “if” icons back to back.

   Of course the logic error in the original example is that the comparison (AmbientTemp < 32) would more likely be (AmbientTemp <= 32), but that’s the problem with a contrived example.

I’m sorry but I disagree completely. Why would you say that the comparison would be <= 32 rather than < 32? My example was not contrived. I can think of innumerable examples where programming logic is best expressed as a check to ensure a value is below a certain threshold. Yes, you can rewrite those comparisons to be a check to ensure that a value is below or equal to the original threshold minus 1, but that is where you start introducing off-by-one errors. If the critical threshold is a certain value (0 or 32 or 100 or 360 or whatever) the best way to write the code is to use the threshold value directly rather than (due to restrictions imposed by your tool for generating LASM or MindScript code) rewriting it as a different sort of comparison against a slightly different number. If other programmers here disagree I am certainly willing to take correction.

John Hansen



Message has 2 Replies:
  Re: Robolab as a tool for teaching programming
 
On Wed, March 16, 2005 11:01 am, John Hansen said: (...) My only reason for commenting was that this has been used as an argument before. You've done a nice job of conveying the fact that you're willing to consider that other languages may be (...) (20 years ago, 16-Mar-05, to lugnet.robotics)
  Re: Robolab as a tool for teaching programming
 
(...) What you teach by not having a <= operator is that you should write: if ( x < 33 ) printf ( "x is 32 or less" ) ; ...rather than if ( x <= 32 ) printf ( "x is 32 or less" ) ; You can "get away with it" in a language that only supports integers (...) (20 years ago, 17-Mar-05, to lugnet.robotics)

Message is in Reply To:
  Re: FLL not allowing NQC; Mindscript is allowed
 
On Tue, March 15, 2005 12:01 pm, John Hansen said: (...) So, this is the same argument we've been hearing for the last couple weeks, right? NQC is the only "Real" programming language that can be used on the RCX (with standard firmware). If we can't (...) (20 years ago, 15-Mar-05, to lugnet.robotics)

114 Messages in This Thread:
(Inline display suppressed due to large size. Click Dots below to view.)
Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR