20가지 언어의 Hello world 프로그램
< C >
/* Program: helloWorld */
#include <stdio.h>
int main(void) {
printf("Hello, world!\n");
return 0;
}
The godfather of modern imperative language syntax,
you can recognize C by its header files (with the *.h extension) and
its slash-and-asterisk comment delimiters.
< JavaScript >
// Program: helloWorld
function helloWorld() {
document.write("Hello, world!");
}
The Web's scripting language still resembles C and its cousins, but its syntax is a little more verbose.
The I/O based on the document object is a dead giveaway.
<Python>
# Program: helloWorld
def helloWorld():
print "Hello, world!"
return
Compared to the other popular scripting languages, Python does away with C-like syntax,
with its braces and other punctuation marks, in favor of natural-language keywords and
code blocks based on whitespace indentation.
< Java >
// Program: helloWorld
class helloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
Java looks a lot like C and C++,
but it's more strictly object-oriented and uses a different syntax for classes, methods, and types.
< Perl >
# Program: helloWorld
sub helloWorld {
print "Hello, world!\n";
}
You can tell it's a scripting language because it uses the hash symbol (#) to denote comments.
Unlike its competitors, however, the concepts of functions, methods,
and subroutines are interchangeable in Perl, and all are defined using the keyword sub.
< C++ >
// Program: helloWorld
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!" << endl;
return 0;
}
The object-oriented successor to C looks a lot like its older sibling,
but C++ is easy to spot by its simplified, single-line comments and its stream-based console I/O.
< Ruby >
# Program: helloWorld
class HelloWorld
def greet
puts "Hello, world!"
end
end
Ruby's class and method definition syntax resembles that of Python,
but unlike that language, definitions in Ruby must be closed with the end keyword.
< Lisp >
;; Program: helloWorld
(write-line "Hello, world!")
You can always tell a Lisp program by its signature parentheses --
in real programs they are often nested many levels deep.
This program's particular dialect is Common Lisp.
< Visual Basic >
' Program: helloWorld
Imports System
Public Module helloWorld
Sub Main()
Console.WriteLine ("Hello, world!")
End Sub
End Module
Microsoft's often-criticized language bears little resemblance to the Basic that was popular in the 1980s,
but you can still spot Visual Basic by its single-quote comment delimiters.
The example uses the modern Visual Basic .Net syntax.
< Scala >
// Program: helloWorld
object helloWorld {
def main(args: Array[String]) {
Console.println("Hello, world!");
}
}
As a JVM language, Scala borrows much from Java,
but its syntax is more compact and has a few twists of its own.
Watch for the object and def keywords, which aren't used in Java.
< Haskell >
-- Program: helloWorld
module helloWorld where
main = putStrLn "Hello, world!"
As a functional language, Haskell's syntax differs from most of the languages in this quiz.
It can be spotted by its unusual, compact syntax and its double-dash comment delimiter.
< Pascal >
{ Program: helloWorld }
Program helloWorld(output);
Begin
WriteLn('Hello, world!')
End.
One of the earlier structured programming languages,
Pascal's syntax is verbose by today's standards, but it remains eminently readable.
Unlike languages derived from C, curly brackets in Pascal indicate comments.
< Objective-C >
// Program: helloWorld
#import <Foundation/Foundation.h>
int main(void) {
NSLog(@"Hello, world!\n");
return 0;
}
Because Objective-C is a superset of C, some Objective-C code looks almost identical to its older cousin.
To tell which is which, watch for library classes and functions that
start with "NS." That prefix is a holdover from the NeXTstep OS, which popularized Objective-C.
< Logo >
; Program: helloWorld
to helloWorld
print [Hello, world!]
end
Logo is an old language with an unusual syntax.
A teaching language, it is recognizable by its friendly, readable keywords.
The to/end keyword pair, used to define a subroutine, should be a big hint.
< Cobol >
* Program: helloWorld
IDENTIFICATION DIVISION.
PROGRAM-ID. helloWorld.
PROCEDURE DIVISION.
DISPLAY 'Hello, world!'.
STOP RUN.
Once you've seen Cobol code, you can never forget it.
The rigorous and unorthodox program structure,
the mandatory indentation, and the liberal use of uppercase are all dead giveaways.
< Fortran >
* Program: helloWorld
PROGRAM helloWorld
PRINT '(A)', 'Hello, world!'
STOP
END
The granddaddy of programming languages, Fortran is the oldest language still in use today.
As such, it resembles a lot of later languages,
but the primitive syntax and unusual indentation make it readily identifiable.
< Forth >
\ Program: helloWorld
: helloWorld ( -- )
." Hello, world!" cr ;
Not only is Forth seldom used today,
but its syntax remains unique in the history of programming languages.
It can still be found in various embedded systems applications,
including the Open Firmware found in some PowerPC, Sparc, and IBM Power systems.
< C# >
// Program: helloWorld
using System;
public class helloWorld
{
public static void Main()
{
Console.WriteLine("Hello, world!");
}
}
Somewhere between C and Java lies C#.
It retains much of the syntax of the former while adding many of the modern language features of the latter
(and some of its own). If it looks like C but it's too slick to be C++, you just might be looking at .Net code.
< PHP >
# Program: helloWorld
function helloWorld() {
echo "Hello, world!\n";
}
PHP uses the function keyword to begin function definitions like JavaScript,
but it uses the hash character for comments and the echo keyword for text output,
like a scripting language.
If you can remember those things,
you'll be able to recognize one of the more popular scripting languages on the Web.
< Ada >
-- Program: helloWorld
with Text_IO;
use Text_IO;
procedure helloWorld is
begin
Put_Line("Hello, world!");
end helloWorld;
Ada was designed by the U.S. Department of Defense as a reliable, efficient,
and highly maintainable language for embedded systems applications.
As such, it uses a strict,
verbose syntax that owes a lot to Pascal and its related family of languages.
<원본 출처 : http://www.infoworld.com/d/application-development/hello-world-programming-languages-quiz-188874 >
'소프트웨어 개발&환경' 카테고리의 다른 글
소프트웨어 개발 기술 요약 1. (0) | 2015.04.27 |
---|---|
온라인 코딩 사이트 : CodePad.org (0) | 2014.02.20 |
리눅스 사운드 프로그래밍 자료 (0) | 2013.10.16 |
프로그래머가 되려는 분들을 위한 동영상 (0) | 2013.09.05 |
웹 접근성 (Web Accessibility) (0) | 2013.08.14 |