comp-prog/lecture_1
Matt Gottsacker
Computer Programming
Marquette University High School
Last modified: 01.10.2020
All instructions are primitive and specific to different types of computers. These instructions are in binary form. These languages are very hard for humans to read and interpret. Each processing architecture has its own machine code. For example, ARM (mobile devices) is different than Intel x64 (Macs / PCs).
110101010101111000011101110101010101111000011101110101010101111000011101
Assembly makes machine language easier to understand, though it is still not very human-readable. Assembly languages can be directly converted into machine language via an assembler. Because it is compiled into machine language, assembly is different for each processor architecture.
.global _start
.text
_start:
# write(1, message, 13)
mov $1, %rax # system call 1 is write
mov $1, %rdi # file handle 1 is stdout
mov $message, %rsi # address of string to output
mov $13, %rdx # number of bytes
syscall # invoke OS to write
# exit(0)
mov $60, %rax # system call 60 is exit
xor %rdi, %rdi # we want return code 0
syscall # invoke operating system to exit
message:
.ascii "Hello, world\n"
These languages are the ones most typically used by developers. Some examples include Java, C, C++, Python, Haskell, Go, Rust, R, etc. High level languages are easier to read and often have cross-platform support. For example, applications written in Java can typically run on Windows, OS X, and Linux without modification.
There are some good examples of high level langauges and their uses on pg. 8 of Liang textbook.
System.out.print("Hello, world!")
An OS manages and controls a computer system. Windows, Mac OS, Linux, and Unix are examples. Operating systems control and monitor system activities, allocate and assign system resources, and schedule operations. The operating system communicates with the system hardware directly.
public class Lecture_1_1 {
public static void main (String[] args) {
System.out.println("Mr. Gottsacker is super cool.");
System.out.println("Java is a cool language.");
System.out.println("I can't decide which is cooler.");
}
}
Computer programming is highly dependent on syntax. Integrated Development Environments (IDEs) like Eclipe and Netbeans take care of a lot of things for you, like adding closing braces and quotation marks. It is better to learn by typing these yourself so that you understand what an IDE does for you. Otherwise, you may forget how to do certain things. This will show on tests/quizzes in this class, or in other CS-related classes.