Slashdot Mirror


Java as a CS Introductory Language?

A couple of questions concerning Java have ended up in the bin over the past few weeks, and rather than handle them separately, I've decided to lump them together as they deal with Java's use as a learning language, as opposed it's traditional use as an application language, and in many cases, which looks to be replacing C/C++ in this role. Personally, I feel that teaching Java in college is fine, however I'm a little concerned in it's replacing C/C++ in that role. This, of course, begs the question is C/C++ any better. How about this: if you were going to structure a curriculum to teach Object Oriented concepts, would you teach it using Java, C/C++, or something else?

First, tulare queries: "I'm currently a student at a small university whose CS students are required to attend two terms of Java programming courses before moving on to other OOP languages. My personal feeling is that Java is clunky, ugly, and runs much too slow on most platforms. The official CS department position is that Java is pure OOP (as opposed to C, for example), and furthermore, Java is extremely widely used at this time. Now, I may be stirring things up a little here, but just because everyone does something one way does not neccessarily mean that something is being done the best way. What I'm asking is to hear reasoned opinions on the following statements:

  1. Java is a fine development language, and it will help me as a programmer to learn it.
  2. I'm right. Java is a fad, not worth much more than the Windows OS in terms of quality, and my CS faculty is doing me a disservice by cramming it down my throat.
  3. There's a little truth in both the above statements."
And we have this one from Banjonardo: "The AP Computers course, the strongest computers-oriented course in a high school, is changing its core curriculum. The language taught, which has progressed from Pascal to (currently) C++ is changing once more. Next year will be the last for C++. The new language will become Java. My question is, realistically, which is the best language for an AP Comp class to learn? I will use my school as an example: Our 386s were given away to students on Friday, to make way for the brand spanking new 900Mhzs provided by the "Digital High School" program. What language would be the most appropriate to send our students forth with?"

While on IRC, I was discussing this issue a bit with other editors and Chris DiBona happened to have some thoughts on the matter, his words follow:

When Cliff mentioned that a Java in education story was going to be posted, I asked to weigh in on the topic. I will not talk about the suitablity of using a non-free language, as I'm certain that will be discussed in the comments and is not a trivial issue.

I don't think that Java, or any Object Oriented language, would be suitable for an AP Computer science class. I don't think it serves the needs of students looking to fully understand the internal workings of a computer, which is in my mind what an AP computer science course should be directed towards.

C is a language that has been designed to be very close to the hardware, and its ideosyncracies and power reflect that. Through this relationship, C reflects the realities of the hardware your programs run on. Memory management, low level process and I/O control are all things that a computer scientist should understand at a very low level, to better aid in future programming and debugging no matter which language is chosen or inflicted upon said scientist.

In contrast, Java has been designed to take such concerns away from the programmer. Memory management? Low level IO? These are not the droids you were looking for.. (at least not without an RMI written in another language) That's okay too, that isn't what people want from Java and it isn't what it was designed to do.

And that is exactly my problem with it being applied in a computer science course designed to teach CS fundamentals. In short, since I believe that AP CS courses should focus on the low level architecture of computing, Java is an inappropriate language for that course.

When is Java appropriate? In your college sophomore comparative languages course, or, alternatively, in an OO course or two, but it shouldn't be used as the keystone language for any CS program. Please don't take this as me saying that Java is neither useful or important in it's own (non-free) way, as it clearly is. However, in my opinion, It should be considered an adjunct subject to a serious program in Computer Science.

5 of 913 comments (clear)

  1. Not your father's Java... by Dr.Evil · · Score: 5

    Every time there is a discussion on Java, the same complaints come up:

    • Java is slow.
    • Java doesn't allow me direct memory access, pointer manipulation, templated classes, overloaded operators (insert favorite C++ feature here).
    • The syntax is not rich enough.

    Guess what, folks - most of that hasn't been true for the past couple of years, and it's getting better all the time. The stuff that you're not and won't be allowed to do is prohibited for the most part because it's dangerous and counter-productive. Java, like any widely-adopted language, does not simply cater to the 31337 hax0r.

    • Java is approaching C++ speeds for execution time. Java benefits from some runtime compilation techniques that a static compiler can't accomplish, such as finalizing and inlining methods that aren't being overridden by an inheriting class and dynamically re-compiling "hot" methods. Many of the optimization tricks for static compilers, such as loop unrolling, are being brought into the HotSpot server compiler. Changes in the I/O libraries and the 2D libraries are providing a speed boost of 40-100% in J2SE 1.4 (now in Beta) Swing-based GUI applications over v1.2. The 2D layer in v1.4 uses native hardware acceleration for local apps and remote X calls for apps on remote terminals.
    • The litany of things Java abstracts away - direct memory manipulation, pointers, overloaded operators, multiple inheritance - all can be very dangerous for the naive programmer. The fact that C++ not only allows, but often makes you think about these things, is what I consider the bad thing.
    • Templates are coming to Java, probably in 1.5. Generics, as they're being called in JavaSpeak, however, have one important difference - they are 100% type-safe. You will only be able to template Objects, not primitives.
    • Java's syntax provides one blessed thing that C, C++, and especially Perl and some other newer languages don't - readability. There's none of this C++ -> nonsense, or Perl's $/@ crap. Thank god there is no such thing as preprocessor directives. Syntactic simplicity is as much a reason for Java's rapid adoption as anything else. The cleanest-written code is the most maintable code. Considering the commenting habits of most programmers, being able to tell what the code's doing from the code itself is a godsend. Sometimes there should be only one way to do something, because it reinforces the right way of doing it.

    I've helped teach a class for the AP and IB CS exams, and I'll tell you what they're about more than anything else - algorithms. That certainly doesn't benefit more from C/C++ than it does from Java. Hell, if that were the concern, we'd use Haskell! The point is, the class's focus isn't on pointer arithmetic, code optimization, or any other topic that makes C++ a more natural choice than Java. As a matter of fact, having to consider those things make C++ an obstacle to understanding, rather than an aid. I'm glad the College Board is changing the language to Java - it's the right thing to do for the level of understanding they're trying to teach.

    --
    Right...
  2. Java is fine for OO by Hard_Code · · Score: 5

    Let's face it, most tutorial languages are picked for being high level, and having a fairly shallow learning curve. When I started learning programming, Pascal was used, which was fine in the days of purely procedural programming. Now that OO is more or less the defacto way of thinking about things (NOT to say that we should only be programming in OO languages), it makes sense to go with Java. Java was designed from the very very beginning with the explicit goal of making it harder to make mistakes - errors are caught up-front as much as possible.

    Java has:

    1) strict typing
    2) dynamic linking
    3) built-in memory management
    4) a consistent implementation and rich libraries from a single vendor (for better or for worse)
    5) works *identically* on many platforms ("identically" is the key here...we don't need to be spending half our time teaching build environments for various systems)

    For all these reasons, it makes sense to use Java as a beginning language. The basic programming concepts are all there (yes, even resource management). The problem with C and C++ is that it is very easy to obscure larger concepts with intimate technical details, the learning curve is steep. I remember when I was learning Pascal, it was as if the class hit a brick wall when pointers were introduced. Imagine if learning pointers and intimate machine-dependent ("words"??) memory management was the prerequisite to larger programming concepts such as conditional statements, iteration, recursion, etc. The whole learning process would be stymied.

    And I used to be one of the oh-so-cool C++ programmers who thought that Java was just a kindergarten-level "fad", and scoffed at it when it was used to teach programming in CS courses. Now enterprise Java programming is my day job, and I can attest to the fact that it is NOT a fad, is very powerful, and is used to do some really serious, and really cool stuff. I'm sure assembly programmers said "C?? You don't even need to know what REGISTERS are to use that!!".

    --

    It's 10 PM. Do you know if you're un-American?
  3. Re:Wrong Direction by Zigg · · Score: 5

    Actually, that is a pretty interesting philosophy... I like it, and not just because of sadistic tendencies. :-)

    Think about it:

    1. People learn first-hand what happens under the hood.

    2. The lack of any kind of visually impressive positive feedback will guarantee that the really bad programmers with a serious lack of dedication never come back.

    3. The apparently inexplicable things the machine does when you do something wrong will guarantee that those with some dedication but poor understanding will never come back.

    4. You are left with those who are really good programmers at heart, understand what they do, and are strongly dedicated to doing it. Ergo, fewer programmers, better programmers, more money to go around to less people, six figure salaries to all and real productivity. Oh, and Windows eventually goes away too. :-)

    Sigh, what a world that would be...

  4. Re:It is a good education language. by abdulwahid · · Score: 5

    I agree with you in that Java is fine for an education language but it definitely shouldn't be limited to that. For example, one of the new recruits in my company has just graduated from a university where they were only taught Java. Consequently, he doesn't know what a pointer is, he doesn't know what linking object files means and he doesn't know anything about memory allocation.

    As I see it, University (College) is about education not about industrial training. You shouldn't be taught specific tools at university rather you should be taught theory. That way, when you leave university you will be able to apply your theory to different languages or applications. For example, one of the Universities here in the UK teaches all the programming in Visual Basic. I mean what is that all about? How can you possibly claim you know how to program when all you know is Visual Basic! A good programmer should pick a language to use like a carpenter picks a tool for a job. Different languages are good for different jobs and university should give you the theory so that you can easily understand new languages.

    A university should really teach you a mixture, pure object-oriented (like Smalltalk), imperative (like modula-2 or C), functional (like Miranda) etc. The student will then have firm foundations for being a good programmer.

    --
    perl -e 'print $i=pack(c5, (41*2), sqrt(7056), (unpack(c,H)-2), oct(115), 10);'
  5. Why not select language as appropriate for topic? by hding · · Score: 5

    For the express purpose of teaching OOP, why not use Smalltalk, which makes it difficult to fall into other methodologies and easy to use OO techniques?

    But as a greater question, why restrict the field to one or a few languages? I'd think that in a CS curriculum (I insert the disclaimer that I came from mathematics and not from such a curriculum) one would want students to explore as many languages and paradigms as possible, ranging all the way from assembler to Prolog. This would presumably encourage a student both to develop many different ways of thinking about any given problem and to be able and willing to select an appropriate tool for any problem encountered. Far too often we see (as evidenced by responses on Slashdot to articles like this one) that many people are rather narrow-minded about language selection and unwilling to deviate from using their one pet language. Why not start to discourage that immediately in the course of formal CS training?