Download presentation
Presentation is loading. Please wait.
1
languages and tools
2
BY SA
4
machine code
10
assembly
11
section.text global main main: mov eax, 4 ;system call number (sys_write) mov ebx, 1 ;first argument: file handle (stdout) mov ecx, msg ;second argument: pointer to message to write mov edx, len ;third argument: message length int 0x80 ;call kernel mov eax, 1 ;system call number (sys_exit) mov ebx, 0 ;first syscall argument: exit code int 0x80 ;call kernel section.data msg db "Hello, world!", 0xa len equ $ - msg
12
NASM (Netwide Assembler) GAS (Gnu Assembler) MASM (Microsoft Macro Assembler)
13
hello.asm (source) hello.o (object file) hello (executable) assemblerlinker
14
foo.asmfoo.o baz assembler bar.asm bar.o assembler linker
15
dynamic linking.so (Linux).dll (Windows) (linking at runtime)
16
low-level precise control efficiency high-level expressiveness portability
17
compiler
18
foo.cfoo.o baz compiler bar.cbar.o compiler linker
19
foo.o baz bar.c bar.o compiler linker
20
interpreter
21
hello (source) interpreter
22
foo interpreter bar
23
88 + 5 2 – 9 8 * (-3 + 5)
24
88 + 5 2 – 9 8 * (-3 + 5) 93
25
88 + 5 2 – 9 8 * (-3 + 5) -7
26
88 + 5 2 – 9 8 * (-3 + 5) 16
27
as foo 1 + 2 1 + foo 4
28
hello.java (source) hello.class (bytecode) compilervirtual machine
29
hello.java (source) hello.class (bytecode) compiler VM with JIT (Just-in-time) (machine code)
31
function factorial n as val 1 while (gt n 1) # error when n is not a number as val (mul n val) as n (sub n 1) return val (factorial true) # improper type Type error:
32
function num:factorial num:n as num:val 1 while (gt n 1) as val (mul n val) as n (sub n 1) return val (factorial true) # improper type Static typing:
34
as list:foo (list “hello” 14 8) as num:bar (get foo 1) # unknown type
36
polymorphism (print “hello”) (print 100) (print false) (accepts varied number and/or types of inputs)
37
function foo a b if (isNum a) … else … (foo 3 true) (foo “hello” true)
39
function foo a b if (isNull b) … else … (foo 3 true) (foo “hello”)
40
function num:foo num:a bool:b … function bool:foo str:a bool:b … function str:foo str:a …
41
function num:foo num:a bool:b … function bool:foo str:a bool:b … function str:foo str:a # illegal … function num:foo str:a # illegal …
42
function num:foo num:a bool:b … function bool:foo str:a bool:b … function str:foo str:a … (foo “hello”) (foo 3 true) (foo “hello” false)
43
function num:foo num:a bool:b … function bool:foo str:a bool:b … function str:foo str:a … as str:x (foo “hello”)
44
function foo a if (isNum a) … else … as bar 4 if x as bar false (foo bar)
45
function num:foo bool:a … function num:foo num:a … as num:bar 4 if x as bar false # illegal (foo bar)
46
function num:foo bool:a … function num:foo num:a … (foo (ack))
47
Strong typing: Operations only treat a piece of data appropriately to its type. Weak typing: Possible to modify any bytes of data in any way.
48
paradigms imperative (do modify state) functional (don’t modify state) procedural (action-centered design) object-oriented (data-centered design)
49
syntax semantics libraries idioms tools
50
compiler linker interpreter text editor debugger profiler version control IDE (Integrated Developer Environment)
51
C 1970’s static, compiled to machine code “portable assembly” #include int main() { printf(“Hello, world!\n"); return 0; } #include int main() { printf(“Hello, world!\n"); return 0; }
52
C++ 1980’s superset of C (almost) C with OOP #include int main() { std::cout << "Hello, world!\n"; return 0; } #include int main() { std::cout << "Hello, world!\n"; return 0; }
53
Objective-C 1980’s superset of C C with OOP mostly used by Apple #import int main() { printf(“Hello, world!\n”); return 0; } #import int main() { printf(“Hello, world!\n”); return 0; }
54
Java 1990’s by Sun Microsystems static OOP C-style syntax compiled to bytecode, run by VM JVM (Java Virtual Machine) public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); }
55
C# 2001 by Microsoft static OOP C-style syntax compiles to bytecode, run by VM CLR (Common Language Runtime) using System; class ExampleClass { static void Main() { Console.WriteLine("Hello, world!"); } using System; class ExampleClass { static void Main() { Console.WriteLine("Hello, world!"); }
56
Visual Basic 1990’s by Microsoft now basically C# with different syntax Module Module1 Sub Main() Console.WriteLine("Hello, world!") End Sub End Module Module Module1 Sub Main() Console.WriteLine("Hello, world!") End Sub End Module
57
Perl 1990’s dynamic OOP (weak) interpreted print "Hello, world!\n";
58
Python print("Hello, world!\n”) 1990’s dynamic OOP interpreted indentation-sensitive
59
Ruby puts “Hello, world!\n” 1990’s dynamic OOP interpreted generate webpages
60
PHP 1990’s dynamic OOP (weak) interpreted generate webpages
61
Javascript 1990’s dynamic OOP (prototypes) interpreted C-style syntax embedded in webpages alert(“Hello, world!\n”);
62
Fortran 1950’s static compiled many revisions science and engineering program hello print *, “Hello World!” end program hello program hello print *, “Hello World!” end program hello
63
Lisp 1950’s dynamic interpreted prefix notation meta-programming (macros) dialects (Common Lisp, Scheme, Clojure) (print “Hello, world!\n”)
65
efficiency 1)assembly, C, C++, Objective-C, Fortran 2)Java, C# 3)Perl, Python, Ruby, PHP, Javascript
66
portability CPU libraries capabilities
67
functional languages (Haskell, Scala, ML, F#) logic languages (Prolog) shell languages (BASH) scripting languages (Perl, Python) data languages (HTML, XML) query languages (SQL) domain-specific languages graphical languages
68
(Brian Will) created by http://brianwill.net/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.