on the (un)suitability of java to be the first programming language · 2011-03-27 · 1 see&re...
TRANSCRIPT
1
SEE&RE Zagreb, 5-12.9. 1
On the (un)suitability of Java to be the first programming language
Mirjana IvanovicFaculty of Science, Department of Mathematics and InformaticsTrg Dositeja Obradovica 4, Novi [email protected]
Klaus BotheHumboldt-University, Institute of InformaticsRudower Chaussee 25, [email protected]
SEE&RE Zagreb, 5-12.9. 2
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
SEE&RE Zagreb, 5-12.9. 4
Choice of First Programming LanguageNo 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, variable, 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.
SEE&RE Zagreb, 5-12.9. 6
Choice of First Programming Language
First of all the question is which paradigm to use in first programming course?
ProceduralObject-orientedDeclarativeParallel ☺
It is necessary to analyze Good and bad features of languageQuality, reliability, friendly environmentPascal- like or C (Java)- like languages
4
SEE&RE Zagreb, 5-12.9. 7
Choice of First Programming Language20th 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 148C + C++ 74 + 103
Ada 101Modula + Oberon 50 + 4Scheme 53ML +SML+Haskell 18Java 15SmallTalk + Simula 5
Other 26
SEE&RE Zagreb, 5-12.9. 8
Choice of First Programming Language
Modern trends in ITNew dimension – complexity of software developmentDistributed client/server architecturesInternet, WWW, E-Business
Some characteristic problems of software development for Internet
Security – non-authorized accessLack of specialized language for Internet applicationsReal interaction in Internet applicationsNon-portability
Solution?
5
SEE&RE Zagreb, 5-12.9. 9
Choice of First Programming LanguageSolution - JAVA?
Java is new fashionable, and to argue against fashion is very similar to fighting against the wind ☺ [1].
“Simple” object-oriented languageFaster software life-circle - JAVA is interpretative languagePortabilityApplication robustness – memory managementBetter performances for interactive graphics applicationsPossibility for development of adaptable applications – reactivity to changes in run-time environmentBuilt-in virus protection in JAVA run-time system
SEE&RE Zagreb, 5-12.9. 10
JAVA in Real-life Applications
Types of Java applications
Stand-alone applicationsAppletsJava programs as parts of Web documentsJava code as a part of HTML documentsInteractive applicationsGames, 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: Algol60
1976 – 1984: Pascal
1985 – 1996: Modula-2
from 1997: Java
imperative (algorithmic) languages
object-orientation
modularisation, data abstraction
SEE&RE Zagreb, 5-12.9. 12
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
SEE&RE Zagreb, 5-12.9. 14
3rd reason for switching to Java (Humboldt):Java becomes broadly excepted in industry
610
13 1419
22
44 45 47
0
10
20
30
40
50
Fortran Asmb. Delphi /Pascal
PL1 Java VisualBasic
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 / algorithmic1980 modular1986 / 95 OO
Many new projects in industry start with OO languages
OO prog. should be taught at universities very early
SEE&RE Zagreb, 5-12.9. 16
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 3rd semester
Object-orientation?
Modularisation, data abstraction
Imperative (algorithmic) approach
SEE&RE Zagreb, 5-12.9. 18
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
SEE&RE Zagreb, 5-12.9. 20
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 - BADC++ 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 operatorsx +=i++; (x :=x+i; i:=i+1)
SEE&RE Zagreb, 5-12.9. 22
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 integerBufferedReader kbd = new BufferedReader
(new InputStreamReader(System.in));Integer.ValueOf(kbd.readLine()).intValue()
Existance of special new operatorMyClass a= new MyClass();
(instead of: MyClass a= MyClass.new(); )
Complex structure even for simple programspublic 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, variablesstatements, algorithms, procedures
Solution at HU: Two main parts of Java introduction:Part I: imperative constructs of JavaPart 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 burden on
the students (L. Boeszoermenyi, M. Ivanovic)
SEE&RE Zagreb, 5-12.9. 24
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 methodParameter 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:=xEND Swap;
In Java this procedure is actually not implementable.
SEE&RE Zagreb, 5-12.9. 26
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;
SEE&RE Zagreb, 5-12.9. 28
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” arraysunionenumerationset / subset
SEE&RE Zagreb, 5-12.9. 30
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 hasString name; // a namevoid display() {…}… // a display method
} // personpublic class student extends person person { // student is a subclass of person
int matrNr; // a student has additional numbervoid display() {…}… // and an overridden display method
} // student…public static void main (String argv[] ) {
person[] persons = new person [3] //array of personsstudent[] students = new student [3] //array of students…students[1] = new student(“Paul”, 2);persons = students; // persons run -time type becomes array of studentspersons[1] = new person(“John”) // leads to ArrayStoreException
} // main
SEE&RE Zagreb, 5-12.9. 32
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.
SEE&RE Zagreb, 5-12.9. 34
Problems of Java as a first programming language (8) –in other words:
Java is called to be an OO languageThe Java class construct is claimed to support objects, above allHowever, 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 constructsPart II: OO constructs
SEE&RE Zagreb, 5-12.9. 36
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