======== CS 235 - Week 1 Lecture - 2021-08-23 ======== TODAY we will: * intros/see who's here * intro CS 235's "big idea" * point out the course syllabus, review a few HIGHLIGHTS * intro to public course web site and course Canvas site * basic course structure * discussion and example of clickers, clicker questions * start talking about Java, I hope! * prep for next class * when I call on you: * unmute your microphone if you can (otherwise put this into Chat) * give your preferred name * your hometown * your major * do you have an assumption or a question about Java you'd like to share? * which Java? anything at or after OpenJDK Java 11 *should* be fine, probably Java 15 or 16 in in-class examples ======== START our intro to Java!!! * See course text, Chapter 1, Section 1.2 * when Java was designed in the 1990s, * they wanted to make it easy to learn, so they deliberately designed it to be close to C++ in a lot ways, but not ALL ways * BUT! also deliberately OMITTING those features of C++ that Java's developers felt were: * rarely used * poorly understood * confusing ...and bring (in their opinions) brought more grief than benefit * Java does not have (or does not need) * header files * pointer arithmetic (or even a pointer syntax) [!!!] * structures (structs) * unions * operator overloading * virtual base classes * multiple inheritance - Java uses interfaces instead ===== [little aside] * SO -- as just a few examples that should look familiar to a C++ programmer -- using jshell, a Java interactive REPL (Read-Evaluate-Print-Loop) tool introduced in Java 9 that gives you a means to type JUST Java expressions and see their values!: (pasted from jshell demo during class): macbook-pro:235lect01 smtuttle$ jshell | Welcome to JShell -- Version 16.0.1 | For an introduction type: /help intro jshell> int count; count ==> 0 jshell> count = 27; count ==> 27 jshell> count count ==> 27 // well, not ALL of the example expressions demo'd // are like you'd see in C++: jshell> String name; name ==> null jshell> name = "Sharon"; name ==> "Sharon" jshell> name + name $6 ==> "SharonSharon" // FORGOT to mention during class: you can END the jshell session // by typing the control key and d key at the same time // (often written as "type ^D") ===== [end of little aside] * Java is a highly-portable, object-oriented language that is suitable for general-purpose computing * developed at Sun Microsystems * development started in 1990 * originally known as Oak * needed to be very reliable * converted to being an "Internet programming language" in 1993, with the explosion of the World Wide Web * famous white paper in which Sun claims Java to be... (and it included 11 famous buzzwords) * simple * object-oriented * distributed * interpreted * robust * secure * architecture-neutral * portable * high-performance * multi-threaded * dynamic * you can translate Java in different ways, but the classic way is to "compile" it into Java bytecode, a special low-level virtual machine language, BUT not for any particular hardware when you give Java bytecode to a Java Runtime Environment (JRE), THAT's an interpreter! And Java bytecode is made to be efficiently interpreted by the JRE * JRE: is JUST for interpreting and executing Java bytecode! * You need the JDK - Java Development Kit - to get the compiler, javac, that compiles high-level Java files into Java bytecode * if your hardware is running a JRE, it can run the Java bytecode * robust? * they made language design decisions to avoid certain common errors; * e.g., strongly typed (the type of a variable has to be apparent) * there's no pointer syntax * you are not allowed to overflow an array's bounds * and more...