[Bluej-discuss] language stuff
Stephen Bloch
sbloch at adelphi.edu
Tue Oct 16 15:27:52 BST 2007
Aryeh writes:
>... anything but infix requires an amazing amount of
>conceptual conversion between problem and code space.
Huh? What real-world problem (other than parsing infix algebraic
expressions) is inherently infix? Infix notation was invented only a
few hundred years ago; it's not exactly hardwired into our brains.
>That plus having to count parens basically rules out any lisp
>variant in my mind.
>...
>the reason for using a mix of symbols vs. just one for grouping is
>breaks the counting up... something is very wrong if you have an
>expression that has more then 4 leading or closing parens in algol like
>langs because a[i] is not the same as a(i)... under your arg we should
>teach fully parened math only (because the only advantage of pre/postfix
>over infix for human readers {compilers have different reasons} is it is
>essencially fully parened without the need for parens)
Suit yourself. I'd rather keep typing right-parens until everything
matches than figure out the correct sequence of parentheses,
brackets, curly-braces, and semicolons to close a complex (yet
reasonable) expression like
myButton.addActionListener (
new ActionListener () {
public void actionPerformed(ActionEvent e) {
if (showingValues) {
myLabel.setText (Integer.toString(myButton.values()[i]));}}});
In the interest of fair comparison, here's a Scheme equivalent:
(add-action-handler my-button
(lambda (e)
(when showing-values
(set-text my-label
(number->string (vector-ref (values my-button) i))))))
>... there is also a fantastic language call APL or worse
>one where all the reserved words are white space
Slight correction. In APL, most of the predefined functions (I don't
know whether they're reserved words) are spelled using non-standard
characters, but not whitespace.
>... this goes all the way back to the mid
>60's with the divide between Bell Labs and MIT on various aspects of
>Multics (MIT wanted theoretical purity [LISP] and Bell Labs wanted
>something praciticle [C/C++/Java])
I was about to point out that Multics was in fact written mostly in
PL/1, as C, C++, and Java hadn't been invented yet. But you're
making an analogy, so never mind.
The dispute isn't "theoretical purity vs. something practical"; I
think we're all in favor of something practical. The question is
"what approach is most practical and effective for teaching beginning
programming?" In a freshman programming class (or a non-majors'
programming class), my main goal is not to get the students a
programming job next month; it's to teach them habits of good
programming.
In such a class, one of the real, practical hurdles is the time
students spend memorizing syntax rules. If I can lower that hurdle
(e.g. by using a language with far simpler and more consistent
syntax, or an IDE that shields them from some of the syntax rules), I
have in a very practical way bought myself class time to teach more
practical principles of programming: refactoring, design for re-use,
polymorphism, data structures, etc.
For my own programming, I occasionally use C, C++, or Java, but in
many cases I choose Scheme for its power, flexibility, and brevity.
These are practical decisions, motivated by the desire to produce a
working program as quickly as possible.
>There is conceptual ambiguity in pre/post fix because it is so
>unfamiliar to non-CS people....
>I was refering to arhithmatic (2 2 + 3 * would just baffle most
>beginners but 2+2*3 [assuming traditional human precendance] can be read
>instantly by anyone who is ready for college])
For the people on this list, 2+2*3 is familiar, comfortable, an old
friend. For many of my students, it's mysterious, scary, an old
enemy. I have had students disagree with one another in class over
its correct value, since some of them never really grasped order of
operations in high school. For those students, using a different
syntax allows them to start over with a clean slate. I have seen
light bulbs go on over the heads of students who had never understood
before what this "order of operations" stuff meant.
That said, when I teach CS0 for non-majors, I don't introduce
arithmetic at all until a month into the course, after they've
learned to write functions in a disciplined way on graphical objects.
By that time they're used to the prefix notation, and using the same
syntax rule for arithmetic is no big deal.
--
Stephen Bloch
sbloch at adelphi.edu
More information about the bluej-discuss
mailing list