CS240 Dick Steflik What is going on CS140

  • Slides: 16
Download presentation
CS-240 Dick Steflik

CS-240 Dick Steflik

What is going on ? • CS-140 – Intro to Programming – Java •

What is going on ? • CS-140 – Intro to Programming – Java • CS-240 – Data Structures (definitely not intro) – C++

Java or C++

Java or C++

C++ this semester • Data Structures are language independent • C++, it’s just another

C++ this semester • Data Structures are language independent • C++, it’s just another language • The syntax of Java and C++ are very similar – the symantics are different, we’ll investigate those differences • Both support object orientation

Java • Interpreted • optimized for the internet • Derived from C++ • Good

Java • Interpreted • optimized for the internet • Derived from C++ • Good object model • Widely accepted as the internet programming language • about 10 years C++ • Compiled • optimized for workstation usage • derived from C • Poorer object model • Widely accepted as workstation programming language • about 15 years old

This semester… • You’ll learn quit a lot of C++ • More about OOP

This semester… • You’ll learn quit a lot of C++ • More about OOP • Get an intuitive introduction to Algorithms and Algorithm Analysis

The Java Compiler • Translates Java source code into java bytecodes – java bytecodes

The Java Compiler • Translates Java source code into java bytecodes – java bytecodes are the machine language for the Java Virtual Machine • the JVM is a hypothetical machine that written mostly in Java but a little bit in C++ and is compiled specifically for various platforms (Windows, Sun, HP, LINUX) • Bytecodes are portable between platforms

The C++ Compiler • Translates C++ source code into the machine language for the

The C++ Compiler • Translates C++ source code into the machine language for the hardware platform – output of the compiler are object files (. obj) which are partially ready to run – object files must be linked together using the system linker to make an executable file (. exe) • . exe files are specific for the hardware platform • C++ is portable only at the source level

Java import statements • imports indicate which parts of which java packages an application

Java import statements • imports indicate which parts of which java packages an application will need at run time – also allows the compiler to run to completion and not indicate that the class isn’t part of the file being compiles • Remember the compiler only works with the file being compiled

C++ include statements • indicate to the compiler preprocessor which files (source) to include

C++ include statements • indicate to the compiler preprocessor which files (source) to include in the file to be compiled. Included files are actually copied into the source file and replace the #include statement.

Java application • is defined as a class that is instantiated when the program

Java application • is defined as a class that is instantiated when the program is run • main() is the name of the function to be run initially • constructor is used initialize the class

C++ application • classes are/can be used by a C++ application; but the application

C++ application • classes are/can be used by a C++ application; but the application is not itself an instantiated class (like Java) • main() is the name of the function where the executable file starts execution • C++ classes do not have main() functions • C++ objects are initialized via class constructors, C++ applications are initialized in the main() function.

Java - Hello. World public class Hello. World { public static void main(String args[])

Java - Hello. World public class Hello. World { public static void main(String args[]) { System. out. println(“Hellow World”); } }

C++ - Hello. World #include <iostream. h> int main() { cout << “Hello World”

C++ - Hello. World #include <iostream. h> int main() { cout << “Hello World” << “n”; }

Java Application Development classpath Java Source File javac Java Class File JVM Compile into

Java Application Development classpath Java Source File javac Java Class File JVM Compile into bytecodes base classes Run the program

C++ application development C++ Source File C++ Include Files compiler Object File System Object

C++ application development C++ Source File C++ Include Files compiler Object File System Object Files Linker . EXE File