COMP 2100 From Python to Java

Slides:



Advertisements
Similar presentations
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Advertisements

Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Introduction to Java Programming
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Introduction to Java.
COP4020 Programming Languages
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 1
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Groovy WHAT IS IT? HOW DOES IT WORK? IS IT USEFUL?
CompSci 230 Introduction to Java
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Java Programming Introduction & Concepts. Introduction to Java Developed at Sun Microsystems by James Gosling in 1991 Object Oriented Free Compiled and.
FRST JAVA PROGRAM. Getting Started with Java Programming A Simple Java Application Compiling Programs Executing Applications.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
Chapter 2: A Brief History Object- Oriented Programming Presentation slides for Object-Oriented Programming by Yahya Garout KFUPM Information & Computer.
Programming language. Definition Programming language is a formal language designed to communicate instructions to a computer. Programming languages can.
Copyright © Mohamed Nuzrath Java Programming :: Syllabus & Chapters :: Prepared & Presented By :: Mohamed Nuzrath [ Major In Programming ] NCC Programme.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 2.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
 Programming - the process of creating computer programs.
By: Cheryl Mok & Sarah Tan. Java is partially interpreted. 1. Programmer writes a program in textual form 2. Runs the compiler, which converts the textual.
Software Development Introduction
The Functions and Purposes of Translators Translators, Interpreters and Compilers - High Level Languages.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 15: Java Basics Fundamentals of Web Programming.
Introduction to JAVA Programming
JAVA PROGRAMMING Buzzwords. Simple: Less complex syntax than C++ Not as easy to design as Visual Basic Small size of interpreter.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
CS-140 Dick Steflik Lecture 3. Java C++ Interpreted optimized for the internet Runs on virtual ized machine Derived from C++ Good object model Widely.
Applications Active Web Documents Active Web Documents.
CompSci 230 S Programming Techniques
Java™ 2 Platform Getting Started.
Why don’t programmers have to program in machine code?
Lecture 1b- Introduction
CompSci 230 Introduction to Java
CMIT100 Chapter 14 - Programming.
Assembler, Compiler, MIPS simulator
Before You Begin Nahla Abuel-ola /WIT.
Computational Thinking, Problem-solving and Programming: General Principals IB Computer Science.
Programming languages
Programming Language Hierarchy, Phases of a Java Program
Chapter 1 Introduction to Computers, Programs, and Java
The Java Programming Language
A451 Theory – 7 Programming 7A, B - Algorithms.
Lecture 1 Runtime environments.
2.1. Compilers and Interpreters
Teaching Computing to GCSE
Introduction to Java Dept. Business Computing University of Winnipeg
TRANSLATORS AND IDEs Key Revision Points.
Teaching Computing to GCSE
Introduction to Algorithm Design
CMP 131 Introduction to Computer Programming
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
(Computer fundamental Lab)
Lecture 1 Runtime environments.
Chap 1. Getting Started Objectives
Programming language translators
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

COMP 2100 From Python to Java Prof. Stucki (with thanks to Clark Thomborson)

How does Java compare with Python? Java programs are “robust” if they are well-tested: reliable behaviour. Python is not a strongly-typed language, so a method can produce strange results if given an unexpected input. More difficult to test, so less “robust”? Simple Architecture neutral Object oriented Portable Distributed High performance(?) Multithreaded Robust (as defined by Gosling) Dynamic Secure Simpler than Java Architecture neutral Object oriented Portable Distributed Adequate performance Multithreaded Less robust? More dynamic than Java More difficult to secure?

java4Python (Java for Python Programmers) “Python is a nice language for beginning programming for several reasons. “The syntax is sparse and clear. “The underlying model is very simple. Everything is an object. “You can write powerful and interesting programs without a lot of work. “Python is representative of a whole class of what are referred to as scripting languages. “Other languages in the same category as Python are Ruby and Perl. “Java is representative of what we can call industrial strength languages. Other languages in this category would include C++, C# and Scala. “Industrial strength languages are good for projects with several people working on the project where being formal and careful about what you do may impact lots of other people.”

Static and Dynamic Languages java4Python: “Python is representative of one kind of language, called a dynamic language. “Dynamic languages can be interpreted directly, which means that the actual text of the program — the source code — is used while the program is running. “In contrast, a static language is executed in two phases: first the program is translated from source code to binary code, and then the binary code is interpreted. “Although the terms dynamic and static language are widely used, the distinction is a fuzzy one. “Most execution engines do both translation and interpretation. “Static refers to what the translater does. “The translater is called a compiler. “Dynamic refers to what the interpreter does.” Remember: static vs. dynamic is an imprecise way to describe a language, but compiler vs. interpreter is an important technical distinction.

Java: A Compiled and Interpreted Language “In the Java programming language, all source code is first written in plain text files ending with the .java extension. “Those source files are then compiled into .class files by the javac compiler. “A .class file does not contain code that is native to your processor; “it instead contains bytecodes — the machine language of the Java Virtual Machine (Java VM). “The java launcher tool then runs your application [by interpreting its bytecode on] an instance of the Java Virtual Machine.” Source: http://docs.oracle.com/javase/tutorial/getStarted/intro/definition.html

Is Java a Static or Dynamic Language? Dynamic, because Java bytecode (in a .class file) is interpreted by a JVM. Static, because Java source code (in a .java file) is compiled into another language (Java bytecode) before it is executed – it is not directly executable. So… we might say that Java bytecode is dynamic, and that Java source code is static.

Is Python Static or Dynamic? Python bytecode (in a .pyc file) is dynamic, because it is interpreted by the Python runtime system. Note: Python bytecode is not portable across versions of Python. The semantics of Java bytecode is very stable. “Old” Java bytecode runs on newer JVMs. Python source code (in a .py file) is static, because it is compiled into bytecode before the bytecode is interpreted. However: a Java compilation is more complicated than a Python compilation, and a Python interpretation is more complicated than a Java interpretation. Python source code is often interpreted and executed on a line-by-line basis, in a shell. It is possible to compile Python source into an .exe, see Cython v0.22. So… Python (but not Cython!) is “more dynamic” than Java.

Performance: Python vs. Java Advocates for each language use different ways to measure performance, and (unsurprisingly ;-) get different results. In many applications, performance is unimportant. If performance is very important, you should use a fully-static language such as C or Fortran. Python runtime performance is hampered by the limited amount of analysis done by the Python compiler. The Java compiler performs optimisations which are infeasible in Python (variables lack static type). Java performance is hampered if the source code isn’t pre-compiled. Java compilation is much slower than Python compilation. Most JVMs (and some PVMs, e.g. PyPy) compile bytecode into machine code, to avoid the overheads of interpretation on tight loops. This is called “just-in-time” compilation, or jitting. A jitting VM may run a bytecoded program 10x faster than a non-jitting VM, because machine-coded loops run much faster than interpreted loops.