CS 240 Advanced Programming Concepts Class Intro Java

  • Slides: 17
Download presentation
CS 240: Advanced Programming Concepts Class Intro Java Basics Android

CS 240: Advanced Programming Concepts Class Intro Java Basics Android

Outline • Meta Data • Expectations • Introduction To Java • Fiddling With Android

Outline • Meta Data • Expectations • Introduction To Java • Fiddling With Android

Meta Data • • • Instructor: Dr. Frank Jones • • • 3372 TMCB

Meta Data • • • Instructor: Dr. Frank Jones • • • 3372 TMCB 801 -422 -7656 frjones@cs. byu. edu Class Website: https: //students. cs. byu. edu/~cs 240 ta/fall 2016 Course Language: Java Course IDE: Android Studio • (https: //developer. android. com/studio/index. html) Officially Supported Device: Kindle Fire • (https: //www. amazon. com/dp/B 00 TSUGXKE/ref=fs_ods_fs_tab_fd) Recommended Emulator: AMIDu. OS • (http: //www. amiduos. com/#!)

Expectations • • • Respect • • Self – be on time, be prepared,

Expectations • • • Respect • • Self – be on time, be prepared, raise your hand, speak politely, pay attention Others – be on time, be prepared, raise your hand, speak politely, pay attention Use of Electronic Devices • • • Appropriate Timely Revocable Effort • • • Significant: 3 “easy” projects; 2 “serious” projects Individual: You are on your own*; !!Programming Exam!! On Time • No “Time Stamp” Submissions *TAs and instructor are here to help

Expectations Cont. • Fun

Expectations Cont. • Fun

Java: A VERY Brief Introduction

Java: A VERY Brief Introduction

Why Java? • C++ • • Cross Platform: Write “once” compile many, run anywhere…

Why Java? • C++ • • Cross Platform: Write “once” compile many, run anywhere… • • Cross Platform: Write “once” compile “once”, run anywhere… Supports Object Oriented Programing: Supports classes etc. Familiar Syntax: Based upon C Fast (very) • Java Truly Object Oriented Language: Everything is a class Familiar Syntax: Closely resembles C++ Fast (enough very)

C++ (Compiled Language) Model

C++ (Compiled Language) Model

Interpreted Language Model What does this mean for performance? . .

Interpreted Language Model What does this mean for performance? . .

Example: C++ vs Interpreted Java • Demo (with –Xint flag) Note: Credit is given

Example: C++ vs Interpreted Java • Demo (with –Xint flag) Note: Credit is given to the blog “beyondjava. net” which provided the example java source code this demo has been derived from… http: //www. beyondjava. net/blog/a-close-look-at-javas-jit-dont-waste-your-time-on-local-optimizations/ … and to “About. com” which made available the high resolution timer class utilized in the c++ implementation. http: //cplus. about. com/od/howtodothingsi 2/a/timing. htm

Bring on the JIT (Just In Time) Compiler (Note: This example is based on

Bring on the JIT (Just In Time) Compiler (Note: This example is based on Oracle’s Jrockit JVM) http: //docs. oracle. com/cd/E 13150_01/jrockit_jvm/jrockit/geninfo/diagnos/underst_jit. html

But Wait, There’s More… • Runtime Optimization • • Function Inlining Selective Compilation Data

But Wait, There’s More… • Runtime Optimization • • Function Inlining Selective Compilation Data Optimizations Etc… http: //docs. oracle. com/cd/E 13150_01/jrockit_jvm/jrockit/geninfo/diagnos/underst_jit. html

Back to Performance Demo… This time we enable the JIT and optimizations… (i. e.

Back to Performance Demo… This time we enable the JIT and optimizations… (i. e. no –Xint flag)

Results… Mean Duration of Iterations in µSeconds Java C++ Optimized 300 250 µSeconds 200

Results… Mean Duration of Iterations in µSeconds Java C++ Optimized 300 250 µSeconds 200 150 100 50 0 1 3 5 7 9 11 13 15 17 19212325 272931 33 35 37 39414345 474951 5355 5759616365676971 73 75 77 79818385 87899193959799 Sequential Iteration Count

Result 2 (a bit easier)… Mean Duration of Iterations in µSeconds 300 250 µSeconds

Result 2 (a bit easier)… Mean Duration of Iterations in µSeconds 300 250 µSeconds 200 150 100 50 0 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 8991 93 95 97 99 Sequential Iteration Count

Yet Another Java Resource… • http: //docs. oracle. com/javase/tutorial/java/TOC. html

Yet Another Java Resource… • http: //docs. oracle. com/javase/tutorial/java/TOC. html

Working With a Physical Device • https: //developer. android. com/studio/run/device. html

Working With a Physical Device • https: //developer. android. com/studio/run/device. html