source code basics. code for a computer to execute instructions, it needs to be in binary each...
TRANSCRIPT
![Page 1: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/1.jpg)
Source Code Basics
![Page 2: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/2.jpg)
CodeFor 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
![Page 3: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/3.jpg)
Op Codes
![Page 4: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/4.jpg)
Punch Cards
![Page 5: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/5.jpg)
But…
![Page 6: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/6.jpg)
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….
![Page 7: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/7.jpg)
Source• Enter 2nd generation
programming languages–First (most significantly) C–C++– Java
• More for humans – using English words
![Page 8: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/8.jpg)
C++ and Java
![Page 9: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/9.jpg)
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)
![Page 10: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/10.jpg)
Languages: C++C++• Pro: Fast!• Con: Have to worry about so
many details, complex -> slow to implement (just like machine code)
![Page 11: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/11.jpg)
Languages: JavaJava• 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
![Page 12: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/12.jpg)
Languages: 4th GenerationRuby, 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)
![Page 13: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/13.jpg)
4th 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
![Page 14: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/14.jpg)
The PointNever 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
![Page 15: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/15.jpg)
Java SourceJava 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
![Page 16: 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”](https://reader035.vdocuments.site/reader035/viewer/2022071806/56649daf5503460f94a9cac6/html5/thumbnails/16.jpg)
Example Java