announcements‎ > ‎

2015-09-18 Notes

posted Sep 17, 2015, 8:57 PM by Samuel Konstantinovich   [ updated Sep 18, 2015, 6:15 AM ]
HW: Beef up your skills!
You decide what you aren't familiar with and practice:
1.  emacs
2.  terminal commands
3.  writing a java program compiling and running. 
 
Languages:
  • Compiled Language
    • Human readable source code is translated (compiled) into machine language. (binary)
    • Machine language contains instructions that are run directly by the computer.
  • Source code and machine code are different files.
  • Java is a hybrid of compiled and interpreted language
  • Java programs do not run directly on a computer, they go through the java virtual machine (JVM)
    • The JVM is like an interpreter. It translates from byte code to machine instructions.
  • Source files have a .java extension and are human readable. They _must_ end in .java 
  • Source files are compiled into java byte code by the compiler (javac) and are stored in files which have .class extension.
  • .class files are readable by the JVM
  • All .class files are cross-platform (can be run on any OS that has a JVM)
  • Each platform has a specific JVM. Mac, Windows, Linux, etc.

Terminal Stuff

Commands you should know and love:
cp     mv     mkdir    rmdir
ls       cd      pwd      rm
cat    man

Commands you should learn to love:
emacs    ssh    less    more  grep

Cool Commands that won't be required:
|   :  (pipe)  lets you run the output of one program into another program
wc  : word count     
sort  :  sorts things...

Resources:
Very Basic Linux Tutorial for n00bs and forgetful people:  https://www.digitalocean.com/community/articles/an-introduction-to-linux-basics

More detailed Linux/Unix tutorial:


Java:

-Java is statically-typed (variables must be declared before they can be used)

The primitive data types: (you need the ones underlined)
byte/short/int/long
float/double
boolean
char

int (32 bit, values from -2^31 to +2^31-1)
double(64 bit)
boolean (size not defined)
char (16 bits , 0 to 65,535)

Other Data Types:
A String is not a primitive type. Strings are special because they are objects, and we will learn about them more later.


Literal - a fixed value written in the source code.
e.g.
54
"hello"
1.3
true
1.23e2 (doubles can be written in engineering notation!)

Identifier - the name given to a variable/function.
May not start with a digit, and may contain letters, digits, _ , and $ . (Don't use dollar signs, and don't use underscores except when discussed in class)
e.g.
a
b
x
fish
num$dollars (terrible name)
x123
GRAVITY_OF_MOON
hi_there


Variables : They store values, and you can change them by re-assigning after they are assigned. You cannot use a variable before it is assigned. 

declare:
<type> <name>;
e.g.
int x;
float z;

assign:
<name> = <expression>;
x = 3;
z = 2*3.14159+1;

declare + assign:
<type> <name> = <expression>;
char c = 'f';
String s = "whoa!";

Reassignment - can have the original variable in the expression:
x = x + 1; 
fish = fish + cat; //assumes fish and cat have values and are compatible with addition.

Comments