Archive for 12月, 2011
-
Hello, MSIL World!
Posted on 12月 31st, 2011 by cx20
MSIL
MSIL は .NET Framework で使用されている中間言語(Intermediate Language)である。
ソースコード
.assembly extern mscorlib {} .assembly hello {} .method static void Main() cil managed { .entrypoint ldstr "Hello, MSIL World!" call void [mscorlib]System.Console::WriteLine(string) ret }
上記コードは以下の C# のソースに対応する。
アセンブリファイル(.NET でコンパイルしたモジュール)を ildasm で逆アセンブル(ildasdm hello.exe /out:hello.il)することで MSIL のコードを得られる。using System; class Hello { static void Main( String[] args ) { Console.WriteLine( "Hello, MSIL World!" ); } }
コンパイル&実行方法(Mono)
$ ilasm hello.il $ mono hello.exe
コンパイル&実行方法(.NET Framework)
C:¥> ilasm hello.il C:¥> hello
実行結果
Hello, MSIL World!
-
Hello, Ada World!
Posted on 12月 30th, 2011 by cx20
Ada
Ada は米国国防総省の音頭で開発が進められたプログラミング言語である。名前の由来は世界初のプログラマと言われる Ada さんから。
構文は Pascal に似ており、また、Oracle の PL/SQL は Ada の影響を受けていると言われている。
ソースコード
with Ada.Text_Io; use Ada.Text_Io; procedure Hello is begin Put_Line ("Hello, Ada World!"); end Hello;
コンパイル方法(GNAT)
$ gnatmake hello.adb
実行結果
Hello, Ada World!
-
Hello, Common Lisp World!
Posted on 12月 29th, 2011 by cx20
Common Lisp
Common Lisp は Lisp 方言を標準化する為に開発された関数型プログラミング言語である。
Lisp は FORTRAN や COBOL に並ぶ最古のプログラミング言語のひとつ。名前の由来は「リスト処理(LISt Processing)」から。
様々な方言があるが、現在の主な方言としては Common Lisp、Scheme、Emacs Lisp(ELisp)、Clojure 等がある。
ソースコード
#!/usr/local/bin/clisp (format t "Hello, Common Lisp World!")
実行方法(スクリプトファイルを指定して実行)
$ clisp hello.lisp
実行方法(実行権限を付与して実行)
$ chmod +x ./hello.lisp $ ./hello.lisp
実行結果
Hello, Common Lisp World!
-
Hello, Command Prompt World!
Posted on 12月 28th, 2011 by cx20
Windows コマンドプロンプト
Windows コマンドプロンプトは、Windows の標準のコマンドラインシェルである。DOS プロンプトや DOS 窓と呼ばれることもある。
Windows 3.x や Windows 9x では command.com が、Windows NT 系では cmd.exe が、その機能を提供する。拡張子は *.bat もしくは *.cmd(Windows NT 系の場合、利用可能)を使用する。ソースコード
実行方法
C:¥> hello.bat
実行結果
Hello, Command Prompt World!
-
Hello, PowerShell World!
Posted on 12月 27th, 2011 by cx20
PowerShell
PoweShell は Windows における新しいコマンドラインシェルである。
POSIX系シェルをベースとし、Perl や Python、PHP、C# の特徴を組み合わせた言語とされている。
.NET Framework を基盤としており、コマンドの実行結果は .NET のオブジェクトとして処理される。
ソースコード
ソースコード(.NET ライブラリを使用した場合)
事前準備(実行ポリシーを変更する方法)
PowerShell はスクリプト実行ポリシーが設定され、既定では Restricted(実行は無効)となっている。設定を確認するには Get-ExecutionPolicy コマンドレット、変更するには Set-ExecutionPolicy コマンドレットを用いる。
C:¥> PowerShell Windows PowerShell Copyright (C) 2009 Microsoft Corporation. All rights reserved. PS C:¥> Get-ExecutionPolicy Restricted PS C:¥> Set-ExecutionPolicy RemoteSigned
実行方法
C:¥> PowerShell -File hello.ps1
実行結果
Hello, PowerShell World!
-
Hello, JScript.NET World!
Posted on 12月 26th, 2011 by cx20
JScript.NET
JScript.NET は JScript の .NET Framework 向け実装である。
JavaScript の構文が使える他、.NET Framework のライブラリが利用できる。
スクリプトと名前がついているが、コンパイルが必要。
ソースコード
ソースコード(.NET ライブラリを使用した場合)
コンパイル&実行方法
C:¥> jsc hello.js C:¥> hello
実行結果
Hello, JScript.NET World!
-
Hello, JScript World!
Posted on 12月 25th, 2011 by cx20
JScript
JScript はマイクロソフトによる JavaScript 実装で VBScript 同様に Windows で動作するスクリプト言語である。実行環境としては Windows Script Host(WSH)、Web サーバーである IIS、Web ブラウザである IE 等がある。
JavaScript が主にブラウザ用であるのに対し、JScript は Windows Script Host を用いて、バッチ処理を記述することも出来る。
ソースコード
実行方法(Windows)
C:¥> CScript //Nologo hello.js
実行結果
Hello, JScript World!
-
Hello, VBScript World!
Posted on 12月 24th, 2011 by cx20
VBScript
VBScript は Visual Basic のサブセットで Windows で動作するスクリプト言語である。
実行環境としては Windows Script Host(WSH)、Web サーバーである IIS、Web ブラウザである IE 等がある。
ソフトウェア部品である COM コンポーネントを操作するクライアント言語として一定の成功を収めたが、マイクロソフトが ActiveX から .NET 戦略に舵取りをしたことにより、今後は利用される機会は減っていくと見られている。
以下は OS 毎に導入可能な VBScript のバージョン一覧となっている。IE と同時にインストールされる他、WSH 単体で提供されるケースもある。OS IE4.0
(WSH1.0)IE5.01
(WSH2.0/5.1)IE5.5
(WSH5.5)IE6
(WSH5.6)IE7
(WSH5.7)IE8~
(WSH5.8)Windows 95 VBS 3.0 VBS 5.0 VBS 5.5 VBS 5.6 - - Windows NT 4.0 VBS 3.0 VBS 5.0 VBS 5.5 VBS 5.6 - - Windows 98 VBS 3.0 VBS 5.0 VBS 5.5 VBS 5.6 - - Windows 2000 - VBS 5.0 VBS 5.5 VBS 5.6 VBS 5.7 - Windows Me - - VBS 5.5 VBS 5.6 - - Windows XP - - - VBS 5.6 VBS 5.7 VBS 5.8 Windows 2003 - - - VBS 5.6 VBS 5.7 VBS 5.8 Windows Vista - - - - VBS 5.7 VBS 5.8 Windows 2008 - - - - VBS 5.7 VBS 5.8 Windows 7 - - - - - VBS 5.8 Windows 2008 R2 - - - - - VBS 5.8 Windows 8 - - - - - VBS 5.8 Windows 2012 - - - - - VBS 5.8 ソースコード
実行方法(Windows)
C:¥> CScript //Nologo hello.vbs
実行結果
Hello, VBScript World!
-
Hello, C Shell World!
Posted on 12月 23rd, 2011 by cx20
C Shell
C Shell は、UNIX 系のシェルの一つである。UNIX 系のシェルは主に sh 系と csh 系に分かれる。
sh 系のシェルとしては bash、ksh(Korn Shell)、zsh(Z Shell)等がある。
csh 系のシェルとしては csh の他に tcsh、newcsh 等がある。
ソースコード
実行方法(スクリプトファイルを指定して実行)
$ csh hello.csh
実行方法(実行権限を付与して実行)
$ chmod +x hello.csh $ ./hello.csh
実行結果
Hello, C Shell World!
-
Hello, Bourne Shell World!
Posted on 12月 22nd, 2011 by cx20
Bourne Shell
Bourne Shell は、UNIX 系の標準のシェルである。UNIX 系のシェルは主に sh 系と csh 系に分かれる。
sh 系のシェルとしては bash、ksh(Korn Shell)、zsh(Z Shell)等がある。
ソースコード
実行方法(スクリプトファイルを指定して実行)
$ sh hello.sh
実行方法(実行権限を付与して実行)
$ chmod +x hello.sh $ ./hello.sh
実行結果
Hello, Bourne Shell World!