Outline
Language Tour
dosseg .model small .stack 100h .data hello_message db 'Hello, World!',0dh,0ah,'$' .code main proc mov ax,@data mov ds,ax mov ah,9 mov dx,offset hello_message int 21h mov ax,4C00h int 21h main endp end main
C
#include <stdio.h>
C++
#include <iostream>
C#
class HelloWorld { static void Main () { System.Console.Write("Hello World!"); } }
HTML
<HTML> <HEAD> <TITLE>Hello, World Page!</TITLE> </HEAD>
Java
class HelloWorld { public static void main (String args[]) { for (;;) { System.out.print("Hello World "); } } }
Javascript
<TITLE> Hello World in JavaScript </TITLE> <SCRIPT> document.write ("Hello, world!") </SCRIPT>
LATEX
\documentclass{article} \begin{document} \begin{center} \Huge{HELLO WORLD} \end{center} \end{document}
Lisp
(DEFUN HELLO-WORLD () (PRINT (LIST 'HELLO 'WORLD)))
(while t (message "Hello World") (message "") ; force emacs to update the display )
Prolog
hello :printstring("HELLO WORLD!!!!"). printstring([]). printstring([H|T]) :- put(H), printstring(T).
Smalltalk
Transcript show: 'Hello World.
Visual Basic
Private Sub FOrm_Load() Static I I=1 for I = 1 to 10 msgbox "Hello World" Next I end sub
Visual C++
///////////////////////////////////////////////////////////////////////////// // CHelloDlg dialog CHelloDlg::CHelloDlg(CWnd* pParent /*=NULL*/) : CDialog(CHelloDlg::IDD, pParent) { //{{AFX_DATA_INIT(CHelloDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); }
SQL
CREATE TABLE HELLO (HELLO CHAR(12)) UPDATE HELLO SET HELLO = 'HELLO WORLD!' SELECT * FROM HELLO
SQL
CREATE TABLE HELLO (HELLO CHAR(12)) UPDATE HELLO SET HELLO = 'HELLO WORLD!' SELECT * FROM HELLO
Word Macro
Sub MAIN FileNewDefault Insert "Hello World!" FormatParagraph .Alignment = 1 While (1 = 1) For count = 1 To CountFonts() EditSelectAll Font(Font$(count)), 40 Next Wend End Sub
PHP
<?php echo "<html> <head> <title>Hello World Page</title> </head> <body> Hello World! </body> </html>" ?>
Machine Language
CPU Memory
0101001001101011 1101111001001001
I/O
0001101010101010
Machine Language
Instruction:
Operation Code Operands
10110011010010010011010110110 001
Assembly Language
A := B + C if A = 0 then body MOV r0, B ADD r0, C MOV A, r0 BNE L1 equal 0 ; ; ; ; move B into register r0 add store branch if result not
body
L1:
Language Levels
Natural Language
High-Level
Machine Language
LowLevel
Language Classification
Imperative
Declarative
Imperative statements
Modification of variables
Object-Oriented Languages
Imperative statements
Functional Languages
Logic Languages
Prolog, VisiCalc
Objectives
To increase your capacity to express ideas using a programming language To allow you to choose an appropriate programming language for a design task To give you the ability to quickly learn new languages To understand basic tasks of a compiler
Programming environment
Portability of programs
Cost of use
program execution program translation program creation, testing, use program maintenance
Interpreter
Output
Input
Tr
References
Programming Languages Principles and Practices Kenneth C. Louden, Thomson Brooks/ Cole, 2003 Ngn ng lp trnh Cc nguyn l v m hnh Cao Hong Tr, 2004 Programming Languages Design and Implementation, Terrence W. Pratt & Marvin V. Zelkowitz, 2001
References
www.google.com www.wikipedia.com
Assessment
Class exercise/ lab: 10% Assignment: 30% Mid-term: 10~20% Final: 40~50%
Course Web-site
www.cse.hcmut.edu.vn/elearning