Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Programming Introduction

Similar presentations


Presentation on theme: "Java Programming Introduction"— Presentation transcript:

1 Java Programming Introduction
Phil Tayco San Jose City College Slide version 1.0 September 4, 2018

2 Introduction Why are we here?
What is your interest in learning to program? What is a computer program? How does a computer know how to execute your program instructions? What is a programming language? Why learn Java?

3 Introduction Computer program fundamentals
Learning how a program works fundamentally requires a basic understanding of 2 major components: hardware and software Hardware is the physical: desktop, laptop, mobile device, smart TV, rocket ship, ... Software is the virtual: app, operating system, user interface, menus, … The 2 are co-dependent Hardware has little use without software to have it do something useful Software cannot be useful without some physical machine to run on

4 Introduction Computer architecture
Off the assembly line, a computer is essentially a machine with a system of controlled electrical currents Control is primarily handled by the Central Processing Unit (CPU) Programs are instructions written in machine language executed by the CPU Programs reside in the computer’s RAM (Random Access Memory) – temporary storage used by the program as long as it is running

5 Introduction Program compilation
Programs that the CPU understands are at a very low level of detail in machine language beyond the scope of this class Higher level programming languages allow you to write code at more human readable levels Programming languages “compile” the code by converting the high level language instructions that you write into machine language level instructions the CPU understands Different programming languages have been standardized at this level with their own compilers (C, C++, Visual Basic, …)

6 Introduction Popular programs
Many different types of programs have been created using specific programming languages that exist on a computer: internet browser, games, file management, etc. You know a lot of these programs already – you probably also know which programs run on which devices (Safari on a Mac or iPhone, Excel on Windows, Google Chrome on everything) Each one of these was written in a language that was compiled to a level that the machine’s CPU understands

7 Introduction Hardware differences
Different computers essentially have their own CPUs (Intel core processors, T2 chips for Macs) These chips have their own architecture leading to their own machine language definitions This leads to a program written specifically for a Mac must be done with a compiler that knows how to take your program and convert it to the appropriate machine language instructions Many popular programs, though, run on different computers, yet work and look the same Is the same code written for one machine the same for another?

8 Introduction Native code
The compilation to code that a specific CPU understands is called “native code” Native code for one processor will not work on another The higher level program, though, may be desired to work on multiple machines MS Word, Excel, Powerpoint – these programs work essentially the same whether on a PC or Mac The native code underneath for them will be different – can we get to that point using the same set of high level instructions?

9 Introduction Operating system
Another layer of complexity that rests between the machine language and higher level programming language layers is the operating system (OS) The OS serves as organizational component that provides capabilities such as file and memory management You know these by name as well and which hardware they are associated with (iOS for Apple, Windows for PCs) OS updates affect the interfaces and the way you use the device and usually “shouldn’t” affect programs already installed

10 Introduction Operating system libraries
Operating systems also come with programs that optimize on the machine language architecture it resides on iOS programs know how to use machine language modules that work well on an Apple product – similar for Windows on Intel-based products This leads to operating system specific compilers that convert your code to the appropriate machine language level instructions

11 Introduction Understanding the layers
All together this presents a complex organizational structure for using computers and writing programs You can write C/C++ programs at a high levels that are compiled to native machine code for the given processor The compiler is designed for the specific OS that uses that to optimize the native code created This also leads to compilers that know specific OS features that are offered through the programming language This also leads to programs that are written for specific devices

12 Introduction iOS specific C++ program iOS compiler Mac native code
Windows specific C++ program Windows compiler Intel-based native code

13 Introduction How does Java fit into the picture?
Java comes in and addresses the programming language code differences across different operating systems Java does this by creating a Virtual Machine (JVM) environment that wraps itself around the operating system Java programs are compiled into instructions the JVM understands (called “bytecodes”) When the Java program runs, the bytecodes are converted to the OS specific native code depending on where the JVM resides

14 Introduction Java program (*.java) JVM Java compiler iOS
Mac native code JVM bytecodes (*.class) Windows Intel-based native code

15 Introduction Pros and Cons
The primary benefit to this is that the Java program can be written one way regardless of the OS it will run on The Java program will be specific to the version of the JVM and any OS where that JVM is installed will run your program The Java programmer does not have to focus on OS and CPU specific features – the JVM takes care of that including whenever updates occur Cost often that comes up is keeping up with versioning and performance due to the additional computation layer


Download ppt "Java Programming Introduction"

Similar presentations


Ads by Google