Programming: Stair & Reynolds (p. 171): "constructing statements that communicate instructions to be executed by a computer."
How to let a computer greet the world?
VB.NET:
Public Class Hello
Shared Sub Main() System.Console.WriteLine("Hello World...") End Sub
End Class
C:
#include <stdio.h>
void main(void) { printf("Hello world..."); }
Generations of programming languages (Stair & Reynolds, p. 172):
Machine language (first generation).
Assembler (second generation).
High-level procedural (third generation):
FORTRAN (science & engineering).
COBOL (admin.).
C (System software, modern application software).
C++/Java /.NET languages (VB, C#, J#) (object-oriented programming).
Perl, Python, Tcl, PHP (scripting languages).
Lisp and Prolog (artificial
intelligence).
And thousands more.
Fourth-generation:
Structured Query Language (SQL).
Dedicated, domain-specific languages.
Extensible Markup Language (XML) Query language.
Fifth generation: natural language based, speculative,
rather experimental.
Compiled, interpreted and byte-compiled languages (Stair & Reynolds.
p. 179).
Compiler: takes all program statements and translates them into machine language (e.g., FORTRAN, C/C++).
Compiler vs. linker.
Static vs. dynamic linking.
Interpreter: takes a program statement, translates it and submits to the CPU for execution (e.g., Tcl, Perl, Python, PHP).
Some consequences:
Interpreted code gets translated every time it is run.
Compiled code gets translated only once --> compiled codes run faster.
Strongly typed vs. weakly typed: interpreted
code is written faster; i.e., requires fewer lines and has less stringent syntactic rules attached.
Compiling code takes time and effort; interpreted code is written faster.
To port your code to another platform you need a compiler
or interpreter for that platform.
Maintaining compiled code for multiple platforms is more
work than maintaining interpreted code for multiple platforms.
The case of Java: byte-compiled:
Java compiler compiles down to platform-independent binary, nonmachine language (!!) code.
Java Virtual Machine (JVM) interpreter translates each
byte-compiled instruction to machine language and submits to the CPU for execution.
Note: requires the JVM on each platform. JVMs are made available by platform manufacturers ==> 'high
transportability.'
Stair & Reynolds, p. 174 "Java is a programming language developed by Sun MicroSystems that can run on any OS and on the Internet."
Runs on any OS???
Runs on the Internet???
Java applets:
run on an applet viewer, typically spawned by an HTTP client; employ
limited Java functionality (e.g., cannot write to the client machine's
file system.
Java Servlets: Java programs interpreted and executed server-side.
Java Server Pages (JSP); HTML-embedded code to be executed server-side after first translating it into a servlet.
JavaScript: subset of Java, embedded in HTMl to be executed client-side (invented by Netscape).
Java (as well as many other languages) contains lots of HTTP and other Internet-specific functions.
Prechelt (2000) An Empirical
Comparison of Seven Programming Languages:
C, C++, Java, Perl, Python, Rexx, Tcl.
Problem: Why these? Where is VB? What about Tcl? Java?