Hello Blogspot !!
อ่า ประเดิม Entry แรกด้วย เรื่องเบสิคสำหรับ Programmer , นักเรียน นักศึกษา ที่สนใจหรือเรียนในสาขาคอมพิวเตอร์
ต้องรู้จักกันดีนั่นคือ "Hello World"
Hello World ถูกใช้ในหนังสือ C Programming Language ของ Dennis Ritchie (ไม่มั่นใจว่าครั้งแรกหรือไม่)
โดยเขียนเพื่อ (เคยได้ฟังมาจากอาจารย์ท่านนึง...)
เช็คการทำงานของโปรแกรม 3 ตัวที่ใช้ในการเขียนโปรแกรมนั่นคือ Compiler , Linker , Runner
ว่าโปรแกรมของเราสามารถเขียนได้ และ รันได้อย่างถูกต้องและปกติดีหรือป่าว ?? เป็นสิ่งที่ต้องทดสอบก่อน
บทความนี้จะนำเสนอรูปแบบการเขียน Hello World ในภาษาคอมพิวเตอร์หลาย ๆ ภาษา
C
#include <stdio.h> int main() { printf("Hello, World!\n"); return 0; }
ASSEMBLER x86 (DOS, MASM)
.MODEL Small .STACK 100h .DATA db msg 'Hello, world!$' .CODE start: mov ah, 09h lea dx, msg ; or mov dx, offset msg int 21h mov ax,4C00h int 21h end start
C++
#include <iostream> using namespace std; int main(int argc, char *argv[]) { cout << "Hello, World!\n"; }
C#
public class HelloWorld { static void Main() { System.Console.Write("Hello, World!\n"); } }
Eiffel
class HELLO_WORLD create make feature make is do io.put_string("Hello, world!%N") end -- make end -- class HELLO_WORLD
Haskell
mmain = putStrLn "Hello, world!"
Java
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } }
JavaScript
Using a standard Web browser's document object
document.writeln('Hello, World!');
KPL (Kids Programming Language)
Program HelloWorld Method Main() ShowConsole() ConsoleWriteLine("Hello, world!") End Method End Program
[edit]
Lisp
Lisp has many dialects that have appeared over its almost fifty-year history.[edit]Common Lisp
(format t "Hello, world!~%")
or(write-line "Hello, world!")
Lisp
Lisp has many dialects that have appeared over its almost fifty-year history.
[edit]Common Lisp
(format t "Hello, world!~%")
or
(write-line "Hello, world!")
Objective C
[edit]Procedural C Version
#import <stdio.h> int main (int argc, const char *argv[]) { printf ("Hello, world!\n"); return 0; }
[edit]Object-Oriented C Version
#import <stdio.h> #import <objc/Object.h> @interface Hello : Object { } - hello; @end @implementation Hello - hello { printf("Hello, world!\n"); } @end int main(void) { id obj; obj = [Hello new]; [obj hello]; [obj free]; return 0; }
OPENSTEP/Cocoa Version
#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSLog(@"Hello, world!"); return 0; }
Perl
[edit
print "Hello, world!\n";
PHP
<?php echo 'Hello, world!'; ?>
Python
Python 3.0 or later:
print("Hello, world!")
Ruby
puts 'Hello, world!'
Smalltalk
Transcript show: 'Hello, world!'
alternative:
StdoutStream nextPutLine: 'Hello, world'
SQL
CREATE TABLE message (text char(15)); INSERT INTO message (text) VALUES ('Hello, world!'); SELECT text FROM message; DROP TABLE message;
ActionScript (Adobe Flash)
this.createTextField("hello_txt",0,10,10,100,20); this.hello_txt.text="Hello, world!";
[edit]AppleScript
display dialog "Hello, world!" buttons {"OK"} default button 1
ป.ล. บทความนี้เขียนขึ้นเพื่อความบันเทิงเท่านั้น อิอิ
มันคงเขียนให้ครบทุกภาษาไม่ได้อ่านะ เขียนแต่ภาษาที่เรารู้จัก และคิดว่าควรจะรู้แล้วกัน
เพราะ Programming Language มีเยอะมาก ตามไปดูที่
http://en.wikipedia.org/wiki/List_of_programming_languages
เยื่ยมมาก หมดยังนี้ ภาษาที่เขียนมา
ReplyDeleteบางอันยังไม่เคยเขียนเลย แต่รู้จัก 55555
ReplyDelete