5 Replies - 1886 Views - Last Post: 10 December 2012 - 01:16 PM Rate Topic: -----

#1 ccdan  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 38
  • Joined: 09-December 12

An academic on Pascal (procedural) vs Java (OOP) Hello World!

Posted 09 December 2012 - 11:42 AM

To illustrate the additional complexity of OOP consider as a simple metric the comparison of the program code for 'Hello World' written in Pascal, a language used in many universities to teach introductory programming in the past, and Java a contemporary OOP language widely used commercially and in universities today to teach programming.
PASCAL:
program HelloWorld
begin
   write ('Hello World')
end.

JAVA:
class Message
{
   public static void main (String args[ ])
   {
      Message helloWorld = new Message ( );
      helloWorld.printMessage ( );
   }
   void printMessage ( )
   {
      System.out.print ("Hello World");
   }
}


These two programs perform exactly the same function. It is not difficult to see that the early generation Pascal program is very simple and easy to understand, most students and even most ordinary adults would have no problem understanding what is going on.

The Java program on the other hand is much longer, uses a range of complex programming words, many of which have difficult concepts associated with their use, and is much more difficult to understand. Faced with this as their first exposure to the simplest of introductory programs it is not surprising that many students are overwhelmed and confused.

http://www.bcs.org/c...ConWebDoc/18854

Whether it's good or not to teach OOP from the beginning is a bit debatable, but such an example is ridiculous... :D No one starts with that kind of stuff from the very beginning...

Is This A Good Question/Topic? 0
  • +

Replies To: An academic on Pascal (procedural) vs Java (OOP) Hello World!

#2 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1359
  • View blog
  • Posts: 3,424
  • Joined: 28-November 09

Re: An academic on Pascal (procedural) vs Java (OOP) Hello World!

Posted 09 December 2012 - 01:28 PM

They kinda do mate...
Was This Post Helpful? 4
  • +
  • -

#3 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,682
  • Joined: 13-March 10

Re: An academic on Pascal (procedural) vs Java (OOP) Hello World!

Posted 09 December 2012 - 04:43 PM

One thing i can mention regarding the topic is that although Java is an OO programming language, the vast majority of students do not know how to program in an OO way - myself included.

If you ask any student what an encapsulation is, what an interface is or an abstract class is, they will provide you with an A-mark-answer. If you ask them what loosely coupled classes are, they again will give you a good answer.

But if you ask them when to use an interface vs abstract class or to refactor the design of the program to make it more maintainable etc etc.. they will be lost.

I may not be fair to some students as they might be gurus in OO Analysis and Design but i know that i use Java not being aware of the design flaws of my programs. I guess, it's time to pick up some OO oriented book or a refactoring book.

Oh and in Python, you can do:

print("Python rocks")

Was This Post Helpful? 0
  • +
  • -

#4 mojo666  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 352
  • View blog
  • Posts: 770
  • Joined: 27-June 09

Re: An academic on Pascal (procedural) vs Java (OOP) Hello World!

Posted 10 December 2012 - 09:44 AM

View PostLemur, on 09 December 2012 - 01:28 PM, said:

They kinda do mate...


It may be because I come from c++, but I would be surprised if they did. Here is what an actual hello world looks like from an introduction to programming class.

JAVA:  
class HelloWorld  
{  
    public static void main (String args[ ])  
    {  
       System.out.print ("Hello World");  
    } 
} 



So, ccdan is correct that people don't start with the complex concepts from the beginning. There is no class instantion that calls a constructor nor is there a function to call. Though we still have a class and main function, such things can be dismissed as "that weird thing that each program needs to run" until after the student has learned the basics of programming.
Was This Post Helpful? 0
  • +
  • -

#5 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5780
  • View blog
  • Posts: 12,595
  • Joined: 16-October 07

Re: An academic on Pascal (procedural) vs Java (OOP) Hello World!

Posted 10 December 2012 - 01:05 PM

The same arguments are used for Python vs. Java. Only, you know, Python is still relevant. ;)

Pascal is a neat language. Delphi was actually a lot easier to use than C++ MFC for a while. Ada has some things to recommend it. ( Today is Ada Lovelace's birthday! We remember you, too, programmer zero. ) There are even those who make a good case for the old BASIC with line numbers being a preferable starting language.

But, really, why not start with something that's current and not an historical footnote?
Was This Post Helpful? 0
  • +
  • -

#6 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7577
  • View blog
  • Posts: 12,737
  • Joined: 19-March 11

Re: An academic on Pascal (procedural) vs Java (OOP) Hello World!

Posted 10 December 2012 - 01:16 PM

Agreeing that the more sensible Java version would be the one posted by mojo666, this is still incorrect:


Quote

The Java program on the other hand is much longer, uses a range of complex programming words, many of which have difficult concepts associated with their use, and is much more difficult to understand. Faced with this as their first exposure to the simplest of introductory programs it is not surprising that many students are overwhelmed and confused.



There is nothing in even the "complicated" version that a reasonably attentive child can't master. Yes, there is more complexity, but the complexity is fairly easy to understand, because it's all explicit - everything you need to understand is right in front of you. If you can't get this across to a student, it's probably because you're not a very good teacher. The answer then is not to resort to a "simpler" language. It's to quit teaching and go become a garbageman or a marketing executive or anything that doesn't involve trying to explain concepts you don't grasp yourself.

There may be reasons to prefer some other language to Java, but this isn't one of them.

tl;dr: this professor needs a kicking.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1