Programming Languages FILS 2014-2015 Andrei Vasilateanu
Course Master: Administration Andrei Vasilateanu, andraevs@gmail.com Teaching Assistants: Radu Serban Grading: Final exam 40% Laboratory 60% 2 Tests 30% Attendance 10% Homework + Activity 20% Course Policies: Individual HW, >50% in exam, no late HW
Bibliography The lectures are not enough, extra reading is necessary Romanian: L.D.Serbanati, C.Bogdan, Programare orientata spre obiecte cu exemplificari in limbajul Java English: C. Horstmann, G. Cornell, Core Java 2 K.Mughal, R. Rasmussen, Programmer's Guide to Java SCJP Certification http://docs.oracle.com/javase/tutorial/
Short context Specialization: Information Engineering Year 1 Year 2 Year 3 Year 4 Programming Languages Data Structures and algorithms Introduction to Web Programming Object Oriented Programming Operating Systems Databases Algorithm Design and Complexity Mobile Device Application Development Neural Networks and Genetic Algorithms Human Computer Interaction Functional Programming Software Development Methods Web Application Development Software Design Techniques Distributed Systems Artificial Intelligence Semantic Web Compiler Techniques
Overview of the course Introduction to PL and Java Language Fundamentals, Datatypes, Variables Expressions, Control Structures, Methods, Recursion OOP Basics Association Inheritance relations Polymorphism I/O in Java
Programming Languages Language = a set of symbols of communication and the elements used to manipulate them Natural languages (English, Romanian) Artificial (constructed) language Formal Language -> Programming Language Communicate instructions to the computer
Programming paradigms Paradigm = the set of practices that define a scientific discipline at any particular period of time Fundamental style of computer programming Imperative programming Machine-model based, State, HOW Object Oriented programming Programming with Data Types Functional programming Equations; Expression Evaluation Logic programming First-order Logic Deduction
Level of abstraction Machine-level (switches) Assembly language Use symbols instead of binary digits to describe fields of instructions Every aspect of machine visible in program: One statement per machine instruction. Register allocation, call stack, etc. must be managed explicitly. MOV AL, 61h ; Load AL with 97 decimal (61 hex) Avoids Absolute Addressing, Uses Symbolic Names High level language (FORTRAN, LISP, COBOL) http://amturing.acm.org/lectures.cfm
High Level Languages Most programs are created using a high level programming language such as Java, C, C++, or BASIC. With a high level language, a programmer creates a program using powerful, "big" operations which will later be converted into many little machine operations. A line from a program in the language "C": int sum = 0; The machine operations that correspond to this line: set up a small part of main memory to hold a number, store the number zero there, and arrange things so other parts of the program can use it. It might take a hundred machine operations to do all this. A source program (or source file) is a text file that contains instructions written in a high level language. It can not be executed (made to run) by a processor without some intermediate steps. Usually a source program is translated into a machine language program. An application program called a translator takes a source file as input and produces an executable program in an other programming language program as output. Compilation Interpretation
Type system How values and expressions are classified into types, how they are manipulated and how they interact Typed and untyped Verify if the operation is applicable to the type of data Static and dynamic typing Determine the type at compile or runtime Weak and strong typing Treating value of one type as the value of another type
Introduction to Java Java was originally designed for programming consumer devices, but it was first successfully used to write Internet applets. Java was designed to be safe and portable, benefiting both Internet users and students. The Java language itself is relatively simple, but Java contains a vast set of library packages that are required to write useful programs.
The Java Characteristics Sun Microsystems added features to Java that eliminate the possibility of creating code with the most common kinds of bugs. The Java designers eliminated manual memory allocation and deallocation. Memory in Java is automatically garbage collected. You never have to worry about memory corruption. They introduced true arrays and eliminated pointer arithmetic. You never have to worry about overwriting an area of memory because of an offby-one error when working with a pointer. They eliminated multiple inheritance, replacing it with a new notion of interface. Interfaces give you most of what you want from multiple inheritance, without the complexity that comes with managing multiple inheritance hierarchies. The Java Characteristics Object Oriented Distributed. An extensive library of routines for coping with TCP/IP protocols. Robust. A lot of emphasis on early and later dynamic (run-time) checking. Secure. Java enables the construction of virus-free, tamper-free systems. Architecture Neutral. It is generated an architecture-neutral object file format. Portable. No "implementation-dependent" aspects of the specification. Interpreted. The JVM can execute Java bytecodes directly on any machine Multithreaded Dynamic. It was designed to adapt to an evolving environment.
Java Execution Enviroment Phase 1 Editor The program is created with an editor and stored on the disk Phase 2 Compiler The Java Compiler creates the bytecode and stores it on the disk. Main Memory Phase 3 Class Loader The Classloader loads the bytecode in the memory. Phase 4 Bytecode Main Memory Bytecide checker confirms the program is correct and does not contradict the security measures. Main Memory Phase 5 Bytecode The interpreter reads the bytecode, translates it In the machine language and executes the result of the translation, storing the values of the data until the program is executed.
Java Application Program Development and Execution