Boo는 Python에 영향을 받은 새로운 객체지향 언어로서 언어로서 CLI(Common Language Infrastructure)를 위한 정적 타입 언어(변수의 형이 컴파일 시에 정해지는 언어)이다.

Boo 언어의 홈페이지는 boo.codehaus.org 이다.
(2009년 3월 18일 현재 Boo의 최신버전은 0.9.1 이다.)

Boo 언어의 요약: docs.codehaus.org/display/BOO/Language+Summary


Boo 언어로 작성된 소스코드는 booi 명령으로 직접 실행되기도 하고,
booc 명령으로 컴파일되어 실행파일이 만들어지기도 한다.

컨솔에 문자 출력하는 Boo 구문은

       print "문자열(스트링)"

이다. Boo의 print 구문은 Python의 print 구문처럼 개행 문자 "\n" 없어도 개행한다.
 
소스 파일명: hello.boo
------------------------------[소스 시작]
print "Hello, world!"
------------------------------[소스 끝]

스크립트 파일을 실행하는 명령은 booi이고, 스크립트 파일을 컴파일하는 명령은 booc이다.

바로 실행하기
실행> booi hello.boo
Hello, world!


컴파일후 실행하기
컴파일> booc -out:Hello.exe hello.boo
실행> Hello
Hello, world!



소스 파일명: helloWin.boo
------------------------------------------------------------[소스 시작]
/*
 * Filename: helloWin.boo
 *
 *     참고 1: 소스파일이 UTF-8 인코딩으로 저장되어야 함.
 *     참고 2: 이 파일은 Boo의 기본 예제 winforms.boo로 부터 수정됨.
 *
 *  소스코드를 직접 실행: booi helloWin.boo
 *
 *  컴파일: booc -utf8 -r:System.Windows.Forms -out:HelloWin.exe helloWin.boo
 *    실행: HelloWin
 */

#region license
// Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

import System
import System.Windows.Forms from System.Windows.Forms

class App:
 
    [getter(Times)]
    _times = 0
 
    def Run():
        f = Form(Text: "Hello 윈도우 애플리케이션")
    
        button = Button(Text: "클릭하시오!")
        button.Click += def:
            print("클릭!")
            ++_times
  
        f.Controls.Add(button)
  
        if Application.MessageLoop:
            # if we are running inside boox
            # just show a dialog
            f.ShowDialog()
        else:   
            Application.Run(f)

app = App()
app.Run()
print("${app.Times}번 클릭됨")
------------------------------------------------------------[소스 끝]


바로 실행하기
실행> booi helloWin.boo


컴파일후 실행하기
실행> booc -utf8 -r:System.Windows.Forms -o:HelloWin.exe helloWin.boo
실행> HelloWin


 

실행시 아래와 같은 에러메세지가 나오고 실행되지 않는 경우가 있다.

---------------------------------------------------[에러메세지 시작]
처리되지 않은 예외: System.IO.FileNotFoundException: 파일이나 어셈블리 'Boo.Lang
, Version=2.0.9.1, Culture=neutral, PublicKeyToken=32c39770e9a21a67' 또는 여기에
 종속되어 있는 파일이나 어셈블리 중 하나를 로드할 수 없습니다. 지정된 파일을 찾
을 수 없습니다.
파일 이름: 'Boo.Lang, Version=2.0.9.1, Culture=neutral, PublicKeyToken=32c39770e
9a21a67'
   위치: Toolbar2Module.Main(String[] argv)

경고: 어셈블리 바인딩 로깅이 꺼져 있습니다.
어셈블리 바인딩 오류 로깅 기능을 사용하려면 레지스트리 값 [HKLM\Software\Microso
ft\Fusion!EnableLog] (DWORD)를 1로 설정하십시오.
참고: 어셈블리 바인딩 오류 로깅 기능을 사용하도록 설정하면 그렇지 않은 경우보다
성능이 약간 떨어집니다.
이 기능을 끄려면 레지스트리 값 [HKLM\Software\Microsoft\Fusion!EnableLog]를 제거
하십시오.
---------------------------------------------------[에러메세지 시작]

이럴 경우, %BOO_HOME%\bin\Boo.Lang.dll 파일을 helloWin.exe 가 있는 곳에 복사한 다음에 실행하면 된다.



크리에이티브 커먼즈 라이선스
Creative Commons License


 

Posted by Scripter
,