Presentation is loading. Please wait.

Presentation is loading. Please wait.

SEE&REZagreb, 5-12.9. 1 On the (un)suitability of Java to be the first programming language Mirjana Ivanovic Faculty of Science, Department of Mathematics.

Similar presentations


Presentation on theme: "SEE&REZagreb, 5-12.9. 1 On the (un)suitability of Java to be the first programming language Mirjana Ivanovic Faculty of Science, Department of Mathematics."— Presentation transcript:

1 SEE&REZagreb, 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 bothe@informatik.hu-berlin.de

2 SEE&REZagreb, 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”http://www.cs.rit.edu/~ncs/Uppsala97 [3] M. Koelling, B. Koch, J. Rosenberg: “Requirements for a First Year Object-Oriented Teaching Language” [4] Author’s experiences

3 SEE&REZagreb, 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

4 SEE&REZagreb, 5-12.9. 4 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, 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

5 SEE&REZagreb, 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.

6 SEE&REZagreb, 5-12.9. 6 Choice of First Programming Language First of all the question is which paradigm to use in first programming course? Procedural Object-oriented Declarative Parallel It is necessary to analyze Good and bad features of language Quality, reliability, friendly environment Pascal-like or C (Java)-like languages

7 SEE&REZagreb, 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). Pascal148 C + C++74 + 103 Ada101 Modula + Oberon50 + 4 Scheme53 ML +SML+Haskell18 Java15 SmallTalk + Simula5 Other26

8 SEE&REZagreb, 5-12.9. 8 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?

9 SEE&REZagreb, 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 [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

10 SEE&REZagreb, 5-12.9. 10 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

11 SEE&REZagreb, 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

12 SEE&REZagreb, 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.)

13 SEE&REZagreb, 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

14 SEE&REZagreb, 5-12.9. 14 3rd reason for switching to Java (Humboldt): Java becomes broadly excepted in industry

15 SEE&REZagreb, 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 / 95OO Many new projects in industry start with OO languages OO prog. should be taught at universities very early

16 SEE&REZagreb, 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...

17 SEE&REZagreb, 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 3 rd semester Object-orientation? Modularisation, data abstraction Imperative (algorithmic) approach

18 SEE&REZagreb, 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

19 SEE&REZagreb, 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

20 SEE&REZagreb, 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

21 SEE&REZagreb, 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)

22 SEE&REZagreb, 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 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[]) {...} }

23 SEE&REZagreb, 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 burden on the students (L. Boeszoermenyi, M. Ivanovic)

24 SEE&REZagreb, 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

25 SEE&REZagreb, 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.

26 SEE&REZagreb, 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.

27 SEE&REZagreb, 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;

28 SEE&REZagreb, 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

29 SEE&REZagreb, 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

30 SEE&REZagreb, 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).

31 SEE&REZagreb, 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

32 SEE&REZagreb, 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.

33 SEE&REZagreb, 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.

34 SEE&REZagreb, 5-12.9. 34 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

35 SEE&REZagreb, 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

36 SEE&REZagreb, 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, …)

37 SEE&REZagreb, 5-12.9. 37 THANK YOU VERY MUCH FOR ATTENTION


Download ppt "SEE&REZagreb, 5-12.9. 1 On the (un)suitability of Java to be the first programming language Mirjana Ivanovic Faculty of Science, Department of Mathematics."

Similar presentations


Ads by Google