• No results found

On the (un)suitability of Java to be the first programming language

N/A
N/A
Protected

Academic year: 2022

Share "On the (un)suitability of Java to be the first programming language"

Copied!
19
0
0

Loading.... (view fulltext now)

Full text

(1)

SEE&RE Zagreb, 5 -12.9.

1

On the (un)suitability of Java to be the first programming language

Mirjana Ivanovic

Faculty of Science,

Department of Mathematics and Informatics Trg Dositeja Obradovica 4, Novi Sad mira @im.ns.ac.yu

Klaus Bothe

Humboldt-University, Institute of Informatics Rudower Chaussee 25, Berlin

[email protected]

On the (un)suitability of Java to be the first programming language - LITERATURE

[1] L. Boeszoermenyi: “Why Java is not my favorite first-course language ”, Software Concepts and Tools.

[2] http://www.cs.rit.edu/~ncs/Uppsala97 - “Using Java in Computer Science Education – Panel”

[3] M. Koelling, B. Koch, J. Rosenberg: “Requirements for a First Year Object-Oriented Teaching Language ”

[4] Author’s experiences

(2)

SEE&RE Zagreb, 5 -12.9.

3

Choice of First Programming Language

How we learn something for the first time seems to have particular importance

Nobody can learn a programming language properly

just by using it without using it

First programming language serves as a reference for learning additional programming languages

Choice of First Programming Language

No best paradigm - the importance of historical point of view.

Is object-oriented development the right way to go? [1]

For many purposes it is the wrong approach (the concept of modularization is much more fundamental then that of object- orientation).

There is one single “right way” that universities should try to find and teach.

Direction of historical development has not been an accident –

programming started with basic concepts as notion of constant, v ariable, algorithm and function (procedure) – not with notion of objects.

All this does not imply that we cannot start with OO, but it surely follows that we do not have to start with it.

For example: it is true that every sequential program can be regarded as a special case of parallel program. – Is it good idea to start teach with parallel programming?

“My experience suggest that it is better to start with the classical basic concepts and to introduce OO on top of them.” - L. Boeszoermenyi

(3)

SEE&RE Zagreb, 5 -12.9.

5

Choice of First Programming Language

Requirements for the first programming course [1], [4]

It must teach the most basic concepts of programming It must teach them in a way that

the student can use them as a reference for advanced concepts and advanced programming notions.

That makes students understand that programming paradigms and languages and their concepts are under steady development and (hopefully) improvement.

Choice of First Programming Language

First of all the question is which paradigm to use in first programming course?

Procedural Object-oriented Declarative Parallel J

It is necessary to analyze

Good and bad features of language

Quality, reliability, friendly environment

Pascal- like or C (Java)- like languages

(4)

SEE&RE Zagreb, 5 -12.9.

7

Choice of First Programming Language

20th edition 4-8-99, of the list of the languages used in the FIRST course for Computer Science majors at Colleges and Universities that have sent in their listing (597 Institutions).

Pascal 148

C + C++ 74 + 103

Ada 101

Modula + Oberon 50 + 4

Scheme 53

ML +SML+Haskell 18

Java 15

SmallTalk + Simula 5

Other 26

Choice of First Programming Language

Modern trends in IT

New dimension – complexity of software development Distributed client/server architectures

Internet, WWW, E-Business

Some characteristic problems of software development for Internet

Security – non-authorized access

Lack of specialized language for Internet applications Real interaction in Internet applications

Non-portability

Solution?

(5)

SEE&RE Zagreb, 5 -12.9.

9

Choice of First Programming Language

Solution - JAVA?

Java is new fashionable, and to argue against fashion is very similar to fighting against the wind J [1].

“Simple” object-oriented language

Faster software life-circle - JAVA is interpretative language Portability

Application robustness – memory management

Better performances for interactive graphics applications

Possibility for development of adaptable applications – reactivity to changes in run-time environment

Built-in virus protection in JAVA run-time system

JAVA in Real-life Applications Types of Java applications

Stand-alone applications Applets

Java programs as parts of Web documents Java code as a part of HTML documents Interactive applications

Games, commercials , home-page refinement,

simulations of real-life situations

(6)

SEE&RE Zagreb, 5 -12.9.

11

Humboldt-University: history of introductory languages in the 1st semester

up to 1975: Algol 60 1976 – 1984: Pascal 1985 – 1996: Modula-2 from 1997: Java

imperative (algorithmic) languages

object-orientation

modularisation, data abstraction

1st reason for switching to Java (Humboldt):

students motivation

about 1992 – 1996:

Students complain about the “outdated” language Modula-2

(outdated = no more used in practice)

Students vote for C, C++

(We argued: C, and thus C++, are too unsystematic from the

point of view of education.)

(7)

SEE&RE Zagreb, 5 -12.9.

13

2nd reason for switching to Java (Humboldt):

Java becomes broadly excepted at universities 1995 / 96:

A lot of German universities and universities all over the world start with Java in the 1st semester

HU students become aware of this development

3rd reason for switching to Java (Humboldt):

Java becomes broadly excepted in industry

6 10 13 14

19 22

44 45 47

0 10 20 30 40 50

Fortran Asmb. Delphi / Pascal

PL1 Java Visual Basic

Cobol C C++

languages used in German industry in 1998

(8)

SEE&RE Zagreb, 5 -12.9.

15

4th reason for switching to Java (Humboldt):

OO can be introduced from the very beginning

Program paradigms:

1960

imperative / algorithmic

1980

modular

1986 / 95 OO

Many new projects in industry start with OO languages OO prog. should be taught at universities very early

5th reason for switching to Java (Humboldt):

Pre-knowledge of the beginners

New students in first semester already know a lot from school and from self-study when they start at university:

Pascal, Basic, C, C++, ...

New beginners even know Java ...

(9)

SEE&RE Zagreb, 5 -12.9.

17

Faculty of Science, Novi Sad: history of introductory languages in the 1st semester

1979-1983: No PL in 1st semester 1984–1990: Pascal

from 1991: Modula-2

Now: Java?

FORTRAN in 3rdsemester

Object-orientation?

Modularisation, data abstraction

Imperative (algorithmic) approach

Reasons for thinking to switch to Java

Java becomes broadly excepted at universities Java becomes broadly excepted at industry

Pressure of modern world trends in IT and acceptably of Java in IT community

Students complain about the “outdated” language Modula-2 and mostly voted for C-like languages

Outdated = no more used in practice, not modern(?)

We argued: C, and thus C++, are too unsystematic from educational purposes

(10)

SEE&RE Zagreb, 5 -12.9.

19

Main reasons not to switch to Java as first PL

Teaching Java as a part of Programming language course (III, IV semesters).

Some of students have no any experience with programming and programming languages.

Most of students have pre -knowledge based on imperative (algorithmic) programming languages (Pascal, BASIC, C).

Dilemma: whether OO concepts should be taught at universities very early?

Modular languages (Pascal, Modula,…) are still very good languages for teaching and learning basic, systematic, algorithmic programming style

Java – general opinions: good, bad, ugly - GOOD

“Simple”, concise language

Implementation of essential concepts of programming languages

Compile-time error checking and diagnosis

Expressiveness, advanced features

Missing pointers

Reliable objects – garbage collection

Single inheritance, interfaces – multiple inheritance

Real portability, exception handling, serialization

(11)

SEE&RE Zagreb, 5 -12.9.

21

Java – general opinions : good, bad, ugly - BAD C++ syntax

Switch statement – unusual semantics Existence of empty statement

For (int i=0;i<10;i++);

Unusual usage of == for equality test, = for assignment

A grate number of confusing operators

x +=i++; (x :=x+i; i:=i+1)

Java – general opinions : good, bad, ugly - UGLY

C++ syntax, { } as block delimiters, statement bodies, … Static – specification of class elements

Complex and confusing I/O, reading an integer

BufferedReader kbd = new BufferedReader (new InputStreamReader(System.in));

Integer.ValueOf(kbd.readLine()).intValue()

Existance of special new operator

MyClass a= new MyClass();

(instead of: MyClass a= MyClass.new(); )

Complex structure even for simple programs

public class MyProgram {

public static void main (string args[]) {...} }

(12)

SEE&RE Zagreb, 5 -12.9.

23

Problems of Java as the first programming language (1)

Before (besides) introducing OO: conventional imperative language constructs have to be introduced:

data types, variables

statements, algorithms, procedures

Solution at HU: Two main parts of Java introduction:

Part I: imperative constructs of Java Part II: object-orientation with Java

Disadvantage: Imperative programming in the framework of an OO language

-

is a bit ‘unnatural’ (K. Bothe)

- could be too difficult for beginners and puts an unnecessary bu rden on the students (L. Boeszoermenyi, M. Ivanovic)

Problems of Java as the first programming language (2) The class concept in Java is no real concept to introduce abstraction or information hiding – it is just implementation.

Modula-2:

definition module =

what the user has to know about the module implementation module =

implementation details (data, algorithms)

which are hidden from the user

(13)

SEE&RE Zagreb, 5 -12.9.

25

Problems of Java as the first programming language (3) The lack of notion of procedure, modes of parameter passing and references.

procedure is a special case of method

Parameter passing: simple types are passed value; objects are passed by reference.

Modula-3 procedures that swaps 2 integer values:

PROCEDURE Swap(VAR int1, int2:INTEGER);

VAR x:INTEGER;

BEGIN

x:=int1; int1:=int2; int2:=x END Swap;

In Java this procedure is actually not implementable.

Problems of Java as the first programming language (3) The lack of notion of procedure, modes of parameter passing and references.

In many well-known algorithms, the lack of VAR parameters leads to necessary complications.

More real example - Most implementations of an insert

(delete) operation of an AVL tree use a Boolean VAR

parameter (height) to show whether the tree was grown

(reduced) at the last recursion level. To realize this in

Java, we need a special object just to store a Boolean

value. We, may, of course also change the algorithm,

e.g., by turning the insert procedure into a function. In

the case of deletion we need a more sophisticated

change.

(14)

SEE&RE Zagreb, 5 -12.9.

27

Problems of Java as the first programming language (4) To “catch” the C / C++ programmers, a lot of

unsystematic C language elements are included in Java:

side effect expressions:

x = i++ - (--j) +x

meaningless keywords: ‘static’ ...

Example: definition of a constant

CONST Num =100;

static final int Num = 100;

Problems of Java as the first programming language (5) Students do not learn the pointer (extremely important concept) as a special data structure like in C, C++, Pascal, Modula-2 (e.g. to implement connected lists, trees ...)

Instead of it, in Java pointers are “simulated”

by the class concept (object references) –

which can make confusion for first year

students

(15)

SEE&RE Zagreb, 5 -12.9.

29

Problems of Java as the first programming language (6)

Other conventional data structures are missing:

record / structure

“usual” arrays union

enumeration set / subset

Problems of Java as the first programming language (6) Array “missing” – An example:

If we have an array of type T1 and array of type T2 (regarded as subclass of T1) - a kind of covariance.

The pleasant consequence : array values of a subclass can be

assigned to array variables or parameters of a superclass.

The unpleasant consequence : it may lead to unexpected run-

time errors, if an array variable has the run-time type of a subclass (via an assignment as above) then it becomes

incompatible with the superclass or with other subclasses of the

same superclass (undetectable for the compiler).

(16)

SEE&RE Zagreb, 5 -12.9.

31

Problems of Java as the first programming language (6)

Array “missing” – An example:

public class person { // a person has

String name; // a name

void display() {…}… // a display method } // person

public class student extends person person { // student is a subclass of person

int matrNr; // a student has additional number

void display() {…}… // and an overridden display method } // student

public static void main (String argv[] ) {

person[] persons = new person [3] //array of persons student[] students = new student [3] //array of students

students[1] = new student(“Paul”, 2);

persons = students; // persons run -time type becomes array of students persons[1] = new person(“John”) // leads to ArrayStoreException

} // main

Problems of Java as the first programming language (7)

The Java API:

It is not easy for beginners to cope with the big

diversity of standard classes in the library.

(17)

SEE&RE Zagreb, 5 -12.9.

33

Problems of Java as a first programming language (8)

OO programming is based on the concepts of

object (unit of hidden data + visible access operations)

class (a framework of similar objects – an instance of a class is an object)

Java classes allow not only OOP but also a lot of other kinds of software modules:

Classes which are completely in correspondence with OOP Simpler constructs, e.g. implementation of quite ordinary algorithmic elements (collections of input/output procedures)

This multi- functional use of the Java class concept is not easy to comprehend by the students.

Problems of Java as a first programming language (8) – in other words:

Java is called to be an OO language

The Java class construct is claimed to support objects, above all

However, in real Java programs, classes are not only used to implement objects

Methodological challenge in lectures

(18)

SEE&RE Zagreb, 5 -12.9.

35

Conclusions: Java as the first programming language at HU

Was necessary at HU: students motivation, OO from the very beginning, preknowledge of the beginners

Has disadvantages: class is no abstraction, missing data types, bad C constructs included …

Requires methodological concepts:

Part I: imperative constructs Part II: OO constructs

Conclusions: Java as the first programming language at DMI – Novi Sad?

Students motivation and preknowledge are in great discrepancy …

Has disadvantages: class is no abstraction, missing data types, bad C constructs included, not good for educational purposes

Teaching Java as a part of Programming languages course (II year)

Still there are a lot of Universities which use some other more

educational languages (Modula, Pascal, Eiffel, SmallTalk, …)

(19)

SEE&RE Zagreb, 5 -12.9.

37

THANK YOU VERY MUCH

FOR ATTENTION

References

Related documents

 Language Translators: convert programs written in programming language into machine language.  Example of programming languages: C++, Java, COBOL,

The original version and implementation of the AODV protocol was centered on efficient routing of data packets, but had little consideration for security aspects and we have designed

OSL ages, obtained using the SAR protocol on quartz from £uvial channel deposits in the Rhine^ Meuse Delta, are in excellent agreement with tight independent age control for the

In addition to being a valuable UEH indicator, eCSC meets many of the criteria of UHC tracer indicators[ 26 ] as blindness and visual impairment from cataract are prevalent in

To evaluate the relationship between teams’ co-location and project performance, this paper uses a parallel between project performance parameters proposed by Clark

IBM Disaster Recovery Services – Continuity Planning Assessment and Virtual Workplace Continuity.. Mark Young – IBM Global

Using multiple examples, you will learn the fundamental programming language (Java), and then use this programming language to build Android apps in the

Session 2: Tourism planning, marketing and destination management (4.00 pm – 6.00 pm) Co-moderators: (tbd) and Mohamed Reza Salamat, Senior Sustainable Development Officer, Division