What is a Programing Language?

What is a Programing Language?
Programming Languages
• A formal language designed to communicate
instructions to a machine
• Mechanical, Electrical, combo
• Typically, a programming language is developed to
make programming easier
• Logical, imperative, functional
• Important bits: Syntax and Semantics
• Syntax: How to write it!
• Semantics: What does it mean?
Programming Languages
• Why have a programming language?
– Because computers are, in the end, nothing more than a series of on/off switches. Thus,
the only real way to would in binary to represent the various on/off states. Computers
still use this language and only this language. It is called Machine Code
• So what would that be an issue?
– Here is basic program in binary
11000111 00111100 00101010 00111100 00101010 00101011 00101010 01011100 00111100 00101000 01011100 00101010 00101011
00101010 01011100 00111100 00101000 01011100 00101010 00101011 00101010 01011100 00111100 00101000 01011100 00101010
00101011 00101010 01011100 00111100 00101000 01011100 00101010 00101011 00101010 01011100 00111100 00101000 01011100
00101010 00101011 00101010 01011100 00111100 00101000 01011100 00101010 00101011 00101010 01011100 00111100 00101000
01011100 00101010 00101011 00101010 01011100 00111100 00101000 01011100 00101010 00101011 00101010 01011100 00111100
00101000 01011100 00101010 00101011 00101010 01011100 00111100 00101000 01011100 00101010 00101011 00101010 01011100
00111100 00101000 01011100 00101010 00101011 00101010 01011100 00111100 00101000 01011100 00101010 00101011 00101010
01011100 00111100 00101000 01011100 00101010 00101011 00101010 00000000 00000000 00000001 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 01100100 01001000 01100101 01101100 01101100 01101111 00101100 00100000 01010111
01101111 01110010 01101100 01100100 00100001 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
• Yeah, that looks… painful. So what did they do about it?
– Assembly Language!
Programming Languages
• What is assembly language?
– Machine code is the primordial computing language (a lot like baby babble or
monkey chatter) and assembly language is considered a low-level language
(think cave man grunting). Here is the pervious program in assembly language
– A_CR = $0D ;
BSOUT = $FFD2 ;
LDX #$00 ;
LOOP LDA MSG,X ;
BEQ LOOPEND ;
JSR BSOUT ;
INX BNE LOOP ;
LOOPEND RTS ;
MSG .BYT 'Hello, world!',A_CR,$00
• That doesn’t look much better…
– Its not but that is what most of the computer hardware today is capable of
reading so we still use it. Granted it doesn’t really solve the issue that
programming is assembly language is both cruel and unusual
• Ok, so what did they do about that issue?
– If Assembly language is a low-level language, then we need to level up!
Programming Languages
• Level up? What does that mean?
– It means that we will need a High-level Language.
Remember FORTRAN? That is a high level language because
it uses natural language elements to make programing easier.
It also hides or automates significant parts of the computing
system such as memory management. This is called
abstraction.
• Ok, so now it is readable right?
– Like beauty, readable is in the eye of the beholder. Here is
that program in FORTRAN
1 Program Hello
2 Print *, "Hello World!"
3 End Program Hello
• Nice, but if a computer only reads binary how do we
get that higher level language back to binary?
– Thought you would never ask!
Programming Languages
• Going from a High-Level Language to Machine Code
• Issues of Note:
– Machine code is unique to that CPU
– Assembly Language is unique to particular computer
architecture
– High-level Languages are portable
– This flow chart is missing the Linker
Programming Languages
• Compiler (Women and Comma Example)
– Translates source code in a specific set of assembly language.
– Lexical Analysis
• Breaks the code into tokens which are pieces of the code that a unique
such as keyword, variable names, etc.
– Syntax/Semantic Analysis
• Syntax: The tokens are parsed. Parsing is the analysis of a sentence or
command to determine the exact meaning. Parse Tree is created.
• Semantic: Semantic information is compared to the parse tree and
determines if the tokens relate correctly.
– Produces a file of containing assembly language
• Assembler
– Produces the an Object File for a CPU. This is not an executable
file
• Linker
– Takes object code and creates an executable file
Programming Languages
•This seems really stupid.
What crack pot two bit
hack came up with this
system!?
Programming Languages
• Rear Admiral Grace Murray Hopper, that’s who!
– Coined the term “debugging”
– Developed the Harvard 1, which is
basically the computer that modern
device are modeled on.
– Wrote COBOL and the compiler for it
– Has a US Navy Destroyer named after
her
– Earn a PhD in Mathematics from Yale
in 1934
– Nicknamed “Amazing Grace” and “Grandma COBOL”
– Known for her irreverent speaking style.
– Jay Elliot described Grace Hopper as appearing to be "'all
Navy', but when you reach inside, you find a 'Pirate' dying to
be released"
Programming Languages
• Right, I take back my previous comment and would
like to state for the record that the compiler is the
coolest thing ever and the Dr. Hopper is awesome
• So Java works pretty much the same, right?
– Yes and no
Programming Languages
• Java Virtual Machine
– Java got around the issues of OS and Hardware compatibility with
the Virtual Machine.
– It is a run-time environment that handles the assembly and linking
on it’s own
– It was the first “write once, run anywhere” code.
• A Bit of History
– The big computing companies wouldn’t allow certain developers
to have the assembly and linker codes so they could write for their
software (Microsoft and Apple, I am looking at you)
– Sun Microsystems got around this with the Virtual Machine which
enabled anyone to write in Java and have the program be
compatible with any VM-enabled machine
– This led to the expansion of the internet and the bigger
companies to stop their silly feud… well until the Patent Wars
which is a different story
Programming Languages
• Java Compiler
– Creates byte code which is read by the VM
– Bytecode is unique to the VM and cannot be assemble
– The VM is written for a particular type of machine and
executes the bytecode
– Byte code files are *.class files.
Programming Languages
• We will be writing *.java files (Source Code) which
will be our programs
• The javac command will produce the *.class files
– NOTE: The Java Compiler is still a compiler. It will check
your code and throw errors
• We will also increase our Awesome Rating
throughout the year.
Programming Languages
Programming Languages
Programming Languages