Source Code Basics
Code For a computer to execute instructions, it needs to be in binary Each instruction is given a number Known as “operation code” Collection of these is what a program “binary” is
Op Codes
Punch Cards
But…
Machine Code Punch-card like instructions still used today – Called machine code, or (technically incorrect) assembly language Now we convert human-readable instructions into this What a program “binary” is. What companies sell and is too complex to figure out how it works exactly… but sometimes….
Source Enter 2 nd generation programming languages – First (most significantly) C – C++ – Java More for humans – using English words
C++ and Java
JVM Sometimes called the Java Runtime Environment (JRE) The java program is the JVM/JRE Is why Java is secure (checks and controls java code, isolates it) and portable (java code just needs to worry about the JVM)
Languages: C++ C++ Pro: Fast! Con: Have to worry about so many details, complex -> slow to implement (just like machine code)
Languages: Java Java Pro: Worry about less (e.g. memory), fully object oriented (more in line with real world), less machine oriented Con: Slow (mostly) run speed, very slow load speed
Languages: 4 th Generation Ruby, Swift, Python, Shell Pros: Worry about even less, more human centric (even like natural language), higher programmer efficiency Cons: Even slower (but computers are getting faster), loss of control over some things (like memory)
4 th Generation Non-compiled Java and C# is halfway (still compile for the interpreter) Likely to dominate most programming as computers speed up and problems get more complex Interpreter is like the JVM, each language needs one (ruby, python, sh) Bad for learning… hide too many fundamentals
The Point Never have a general argument about which language is “better” Always pros and cons. There are tradeoffs Only which language is best for the given problem or project
Java Source Java enforces rules: Every source code file must be.java Every file must have a matching class definition with exact same name (case sensitive!) Brackets {} groups “blocks” of code All normal code must belong to a class
Example Java