Subject:
|
Re: Robolab as a tool for teaching programming
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Thu, 17 Mar 2005 01:31:27 GMT
|
Original-From:
|
Steve Baker <sjbaker1@AVOIDSPAMairmail.net>
|
Viewed:
|
3702 times
|
| |
| |
John Hansen wrote:
> > 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.
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 - but making
someone put in a constant that's one higher than the number you really wanted to
test against is teaching a really bad habit. Think about what happens when you
switch to a conventional language that supports floating point:
float x = 32.5 ;
if ( x < 33 )
printf ( "x is 32 or less" ) ; /* I don't think so! */
It's imperative to teach stuff like this correctly from day one because we DO NOT
want to see our new employees writing:
if ( x < 32.00000000000000000000000000000000000000000001 )
Programming is an exacting mental exercise - it permits no 'fuzzy' thinking
whatever. Subtle errors such at this one can cost weeks of effort to find and
fix. If you teach sloppy habits at the outset, you get really bad programmers
in later years.
I've personally written and maintained over half a million lines of C++ code over
the past 10 years - I earn a six figure salary doing it - and I run a team of a dozen
solid professional programmers doing work to exacting government standards. The
product I manage is the best of it's kind in the world and has an 80% market share
world-wide. I've been programming in a dozen different langauges since the mid-1970's.
I think I'm qualified to know what makes a good programmer.
As a rule of thumb, a well trained programmer can be 10 to 50 times more productive
than a sloppy one.
We'd never even *consider* using a 'goto', writing in machine code, using a language
that doesn't allow you to name variables or write subroutines. We'd never document
using such a lowly tool as a flow chart. Those techniques are as obsolete as
the hardware we had back in the 1970's when I was taught them.
Why on *earth* would we teach them to our children - except perhaps as a cautionary
tale, a historical curiosity or as a punishment?
---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1@airmail.net> WorkEmail: <sjbaker@link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net http://tuxaqfh.sf.net
http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----
|
|
Message is in Reply To:
| | Robolab as a tool for teaching programming
|
| (...) 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 (...) (20 years ago, 16-Mar-05, to lugnet.robotics, FTX)
|
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
|
|
|
Active threads in Robotics
|
|
|
|