D vs Java as a first programming language

Sean Kelly sean at invisibleduck.org
Mon Sep 29 11:55:07 PDT 2008


== Quote from Chris R. Miller (lordsauronthegreat at gmail.com)'s article
> Sean Kelly wrote:
> > Nicolas Sicard wrote:
> >> I am a teacher in a field where my students don't know what a
> >> programming language is! I need a language for a first approach of
> >> programming. I would say that Pascal, or BASIC even if a bit outdated,
> >> or even D would fit, but not Java.
> >>
> >> I can imagine my first lesson with Java:
> >>
> >>     public class HelloWorld {
> >>         public static void main(String[] args) {
> >>             System.out.print("Hello world!");
> >>         }
> >>     }
> >>
> >> I would have to explain what a class is. What a method is. What a
> >> public or private visibility means. What a static method is. What the
> >> dots in "System.out.print" mean... :) Then how to compile it. Why you
> >> can't run it without a virtual machine. A virtual what?
> >
> > The typical approach to this tends to be "just put this stuff in the
> > file and ignore it--I'll explain it later.  I never understood why this
> > is considered a good teaching method :-)
> There are so many concepts and mechanics that are at work with even the
> simplest Hello World in wee simple C that it's completely irrational to
> expect a student new to programming to comprehend what's going on.  Just
> think about it...
> #include <stdio.h>
> int main(){
>      printf("Hello, world!");
>      return 0;
> }
> Right there!  More concepts than can even be explained!  You have the
> concept of an include, and how the parser literally strings all the
> files together to create a processed source code, then how the compiler
> creates a new C run time in suspended animation which will then run the
> function main(), and how printf is supplied by the include directive
> earlier.

And of course don't forget explaining how a compiler works since they'll
be compiling the app, and how an OS works since it runs on an OS...

In all fairness, I think there's a happy medium here, where the stuff that
the student sees is explained without involving related but extraneous
details.  The big issue for me with Java is that I don't see any way around
at least a simple explanation of OO, given the format of a Java "hello world"
app.  That's significantly more material than discussing a "hello world" in
C or D.  C++ would be kind of a mess as well, since IO there uses operator
overloading, etc.

> At a certain point you have to pedagogically ask the student to take
> certain things on faith until you can better explain it all.

Fair enough.  But the amount each student is willing to take on faith varies.
Some will accept pretty much anything as magic, while others want to know
how a function call works mechanically (or in some cases conceptually, if
they're math geeks) before they feel comfortable actually calling functions.


Sean



More information about the Digitalmars-d mailing list