• Ruby 언어 연습하는 곳:  _why's Try Ruby!
  • Haskell  언어 연습하는 곳:  Try Haskell
  • 갖종 언어(C/C++/D/Haskell/Lua/OCaml/PHP/Perl/Perl/Plain Text/Python/Runy/Scheme/) 연습하는 곳: codepad.org

사용 예:
codepad.org 에서 C++ 언어 Hello 예제 연습 결과: http://codepad.org/FaeCe1x9  
codepad.org 에서 C++ 언어 한글 출력 Hello 예제 연습 결과: http://codepad.org/vANozcKj
Posted by Scripter
,

Mono for Ubuntu

Official Packages

The following official versions are available in the standard Ubuntu repositories:

Ubuntu Dapper (6.06 LTS): 1.1.13.6
Ubuntu Hardy (8.04 LTS): 1.2.6
Ubuntu Jaunty (9.04): 2.0.1
Ubuntu Karmic (9.10): 2.4.2.3
Ubuntu Lucid (10.04 LTS): 2.4 branch snapshot
Ubuntu Maverick (10.10): 2.6.7

Dependencies are automatically tracked for applications in the archive such as Tomboy, Gbrainy and F-Spot. Ubuntu comes with these three applications by default, and therefore comes with Mono installed by default.

To compile your own software, install mono-devel on Dapper (6.06 LTS), Jaunty (9.04), Karmic (9.10), Lucid (10.04 LTS), or Maverick (10.10).

To compile your own software, install mono-2.0-devel on Hardy (8.04 LTS).


Unofficial Packages

Ubuntu Hardy (8.04 LTS)

Users of Ubuntu 8.04 LTS (Hardy Heron) can install 2.4 branch snapshot by using Synaptic from the badgerports (http://badgerports.org) repository. badgerports is an unofficial community project from one of the Debian/Ubuntu Mono developers to ship latest Ubuntu packages for Ubuntu LTS users. Please visit the URL below for full information on enabling these packages:

Ubuntu Lucid (10.04 LTS)

Users of Ubuntu 10.04 LTS (Lucid Lynx) can install 2.6.7 by using Synaptic from the badgerports (http://badgerports.org) repository. badgerports is an unofficial community project from one of the Debian/Ubuntu Mono developers to ship latest Ubuntu packages for Ubuntu LTS users. Please visit the URL below for full information on enabling these packages:

----------------------------------------

CSharp Compiler


Introduction

The Mono C# compiler is considered feature complete for C# 1.0, C# 2.0 and C# 3.0 (ECMA). A preview of C# 4.0 is distributed with Mono 2.6, and a complete C# 4.0 implementation is available with Mono 2.8 or when building Mono from our trunk source code release.

Starting with Mono 2.2 it supports a Compiler Service that applications can consume.

Bug reports can be filed on our bug tracking system.

You have to pick one of:

  • mcs: compiler to target 1.1 runtime (to be deprecated with Mono 2.8).
  • gmcs: compiler to target the 2.0 runtime.
  • smcs: compiler to target the 2.1 runtime, to build Moonlight applications.
  • dmcs: Starting with Mono 2.6 this command is the C# 4.0 compiler, and references the 4.0 runtime.

The compiler is able to compile itself and many more C# programs (there is a test suite included that you can use). The compiler is routinely used to compile Mono, roughly four million lines of C# code and a few other projects.

The compiler is also fairly fast. On a IBM ThinkPad t40 it compiles 18,000 lines of C# code per second.

Compiler Service

The compiler can be used as a service by using the Mono.CSharp.Evaluator class in the Mono.Sharp.dll assembly.

Both a console and GUI read-eval-print shells are distributed as part of Mono 2.2 and are both built on top of the above service.

State of the Compiler

Starting with Mono version 2.6 a new compiler dmcs is available as a preview of C# 4.0 (a preview since Mono 2.6 will ship before C# 4.0 is finalized).

The default compiler (mcs) now defaults to the 3.x language specification, starting with Mono 2.8 it will default to 4.0:

All C# 2.0 features are supported including:

All C# 3.0 features are supported including:

  • Extension methods
  • Query expressions (LINQ)
  • Expression trees
  • Automatically implemented properties
  • Lambda expressions
  • Anonymous types
  • Collection initializers
  • Object initializers
  • Implicitly typed arrays
  • Partial methods

All C# 4.0 features are supported including:

  • Dynamic binding support
  • Generic type variance
  • Optional parameters
  • Named arguments

Those are 2.0 language features available in the 1.0 compiler, if you want to limit the mcs compiler to be a strict 1.0 compiler, use the -langversion:ISO-1 flag.

The mcs compiler produces assemblies that reference the 1.x class libraries, while the gmcs compiler generates assemblies that reference the 2.x assemblies.

Specification

The C# 2.0 specification is availble on the third edition of the ECMA 334 standard (http://www.ecma-international.org/publications/standards/Ecma-334.htm).

An on-line and hyperlinked version of the C# 1.0 specification is available from Jon Jagger's (http://www.jaggersoft.com) site here (http://www.jaggersoft.com/csharp_standard/).

The specification shipped with Monodoc, and available on our web downloads is based on Jon's original XML documentation that he extracted from the ECMA 334 specification.

Working with MCS

Obtaining MCS

The Mono C# compiler is part of the `mono' module in the Mono Git you can get it from our Anonymous SVN server, or you can get nightly download page.

You can also browse or download a snapshot of the compiler alone:

If you are interested in developing the C# compiler, the C# Compiler as a Service or the interactive shell on Windows we provide Visual Studio solutions that work on VS 2008 and 2010 and allow developers to quickly get the compiler up and running.

To do this, download the entire MCS tree from:

And then open the Visual Studio solution on mcs/tools/csharp, this will build the Mono.CSharp.dll compiler as a service as well as the command line interactive C# shell "csharp".

Running MCS

MCS is written in C# and uses heavily the .NET APIs (in particular it uses System.Reflection and System.Reflection.Emit). MCS runs on Linux with the Mono runtime and on Windows with both the .NET runtime and the Mono runtime.

Reporting Bugs

You can submit bugs by filing the bugs against the C# compiler in our Bugs page.

When you report a bug, try to provide a small test case that would show the error so we can include this as part of the Mono C# regression test suite. If the bug is an error or a warning that we do not flag, write a sample program called `csXXXX.cs' where XXXX is the code number that is used by the Microsoft C# compiler that illustrates the problem. That way we can also do regression tests on the invalid input.

Implementation details

The compiler is documented in the file mcs/docs/compiler (http://github.com/mono/mono/blob/master/mcs/docs/compiler.txt)

CIL Optimizations.

The compiler performs a number of simple optimizations on its input: constant folding (this is required by the C# language spec) and can perform dead code elimination.

Other more interesting optimizations like hoisting are not possible at this point since the compiler output at this point does not generate an intermediate representation that is suitable to perform basic block computation.

Adding an intermediate layer to enable the basic block computation to the compiler should be a simple task, but we are considering having a generic CIL optimizer. Since all the information that is required to perform basic block-based optimizations is available at the CIL level, we might just skip this step altogether and have just a generic IL optimizer that would perform hoisting on arbitrary CIL programs, not only those produced by MCS.

If this tool is further expanded to perform constant folding (not needed for our C# compiler, as it is already in there) and dead code elimination, other compiler authors might be able to use this generic CIL optimizer in their projects reducing their time to develop a production compiler.

Open bugs

See the bugs page for more information. A test suite is maintained to track the progress of the compiler and various programs are routinely compiled and ran.

Slides

Slides for the Mono C# Compiler presentation at .NET ONE are available here (http://primates.ximian.com/~miguel/slides-europe-nov-2002/Mono_C_Sharp_Overview_1007.sxi) in StarOffice format.

History

MCS was able to parse itself on April 2001, MCS compiled itself for the first time on December 28 2001. MCS became self hosting on January 3rd, 2002.

The Mono Runtime and the Mono execution engine were able to make our compiler self hosting on March 12, 2002.

On July 2003 work started on the generics support of mcs. Since the core of the compiler was used in production and in the development of Mono itself, a fork of the compiler was created. This fork is `gmcs'. The `gmcs' fork merges all of the changes from mcs on a regular basis and will eventually become the default compiler.

Support for the third edition of the C# standard became available on the Mono 1.1.8 release in the summer of 2005.

The compiler was originally written as an attempt to learn the C# language, it began as a tokenizer for the language, and then evolved into a parser for the language and later got the semantic analysis and code generation features in place. This explains the difference in coding styles from the tokenizer (which is the earliest code) and the code generation (which came at later phases).

Miguel de Icaza started the compiler and did most of the early work. He was later was joined by Ravi Pratap who would take over attributes, delegates, and overload resolution.

Martin Baulig wrote the flow analysis code as well as the generics support. Harinath Raja fixed and refactored large parts of the compiler, rearchitected flow analysis and fixed many of the early design mistakes.

Harinath Raja has been the compiler maintainer for the last two years and was in charge of making the compiler conform to the standard and productized many areas in the compiler, from fixing the name resolution hacks, to performance, to correctness, to simplifying many of the complexity that had crawled into the compiler over the years

Marek Safar initially focused on improving the warnings, error messages and made the compiler more robust as part of his work to make the compiler CLS compliant (Common Language Specification errors and warnings). He later implemented extension methods, delegate type inference and has been a mentor to new compiler authors for a long time.

Atsushi Enomoto wrote the support for inline documentation.

Sebastien Pouliot wrote all the code required to sign assemblies, delay sign them and deal with keys.

Ben Maurer did a lot of profiling work on the mcs compiler and helped fixed some of the problems in it.

Scott Peterson contributed in 2007 many of the foundation blocks for C# 3 (var, support, anonymous types, automatic properties, variable type inference and object and collection initializers).

In 2007 Marek Safar took over the maintenance of the compiler and he completed the C# 3.0 implementation, lambdas, mutators, type inferencing and LINQ expressions.

In 2008 Miguel de Icaza turned the compiler into a reusable library (Mono.CSharp.dll) and introduced the Interactive C# Shell.

In 2009 Marek Safar evolved the compiler to support C# 4.0, adding support for the dynamic data type, named parameters, default parameter values as well as co/contravariance support.

Many other developers contributed fixes and other small components in the compiler.

Common Questions

What is the difference between mcs, gmcs and smcs

They are the same compiler with three different set of defaults.

  • mcs: references the 1.0-profile libraries (the APIs as defined in 1.1) and supports C# 1.0 and C# 3.0 minus generics and any features that depends on generics.
  • gmcs: references the 2.0-profile libraries (the APIs as defined in 2.0 and 3.5) and exposes the full C# 3.0 language.
  • smcs: references the 2.1-profile libraries (the APIs defined for Silverlight) and exposes the full C# 3.0 language. This is the compiler used for creating Silverlight/Moonlight applications.


--------------------------------------

sudo apt-get install monodevelop monodevelop-database

------------------------



1. Mono 설치하기

Ubuntu 10,4.1 에는 Mono 런타임이 이미 설치되어 있으므로 컴파일러만 설치하면 된다.

(1) (C# 1.1 컴파일러) mcs 설치하기 명령
$ sudo agt-get install mono-mcs

(2) (C# 2.0 컴파일러) gmcs 설치하기 명령
$ sudo agt-get install mono-gmcs

(3) (C# 2.1 컴파일러) smcs 설치하기 명령
$ sudo agt-get install moonlight-web-devel




(Ubuntu 10.4.1 이면 yum 대신 apt-get 명령으로
$ sudo apt-get install mono-mcs
)
'

2. Hello.cs 작성

namespace ConsoleApplication01 {

using System;

  public class HelloApp {
      public static void Main(string[] Args) {
          Console.WriteLine("Hello, world!");
          Console.WriteLine("안녕하세요?");
      }
  }
}



3. 컴파일하기

$ mcs Hello.cs


4. 실행하기와 실행 결과

$ mono Hello.exe
Hello, world!
안녕하세요?






'소개와 설치 > Mono' 카테고리의 다른 글

Fedora 13에 Mono 설치하고 테스트하기  (0) 2010.09.11
Posted by Scripter
,

1. Mono 설치하기

Fedora 13과 CentOS 5 에서 Mono 설치하기 명령

$ sudo yum install mod_mono

(Ubuntu 10.4.1 이면 yum 대신 apt-get 명령으로
$ sudo apt-get install mono-mcs
)
'

2. Hello.cs 작성

namespace ConsoleApplication01 {

using System;

  public class HelloApp {
      public static void Main(string[] Args) {
          Console.WriteLine("Hello, world!");
          Console.WriteLine("안녕하세요?");
      }
  }
}



3. 컴파일하기

$ mcs Hello.cs


4. 실행하기와 실행 결과

$ mono Hello.exe
Hello, world!
안녕하세요?







'소개와 설치 > Mono' 카테고리의 다른 글

Ubuntu 10.4.1 에 Mono 설치하기  (0) 2010.09.11
Posted by Scripter
,
OCaml 은 Objective Caml 을 줄인 글로서 발음은 오캐멀(oʊˈkæməl)이라고 읽는다.
Caml 언어는 함수형 언어 ML 에서 파생된 언어로서 OCaml 과 Caml Light 로 나뉜다. OCaml 은 Caml 에 객체지향 언어의 기능을 추가한 명령형 언어의 특징징을 지닌 객체지향 함수형 언어이다.

* 참고로 안터프리터 명령 ocaml 로 실행한 경우에는 # 프롬프트에서 #quit;; 을 입력하고 엔터 키를 누르면 된다.

Posted by Scripter
,
F# 언어는 .NET(닷넷)용 언어로서 OCaml 언어를 기반으로 하고, Haskell 언어의 철학을 반영한 함수형 언어이다. OCaml 언어가 명령형 언어(imperative language)의 특징을 지니고 있는 객체지향 함수형 언어이듯이 F# 언어도 그러하다.
Posted by Scripter
,
명령형 언어는 "어떤(how) 방법"으로 해결할 것인가에 중점을 두지만,
선언형 언어는 "무엇(what)"을 할 것인가에 중점을 둔다.


Wikiclone에서 찾아본
    명령형(impertarive) 프로그래밍 언어와   선언형(declarative) 프로그래밍 언어


명령형 프로그래밍 언어의 종류:
    C, C++, Java, C#, SmallTalk, FORTRAN, Pascal, BASIC, Python, Ruby, Perl, PHP, Groovy, ......

선언형 프로그래밍 언어의 종류:
    Lisp, Haskell, ML, Prolog, SQL, XSL, ......


Posted by Scripter
,
다운로드: http://groovy.codehaus.org/Download

문서: http://groovy.codehaus.org/Documentation

Groovy 1.6.1 은 Groovy 1.6의 많은 Bug Fix가 있었다.

Groovy 1.5.8 역시 1.5.x 시리즈의 수많은 버그를 해결한 안정적인 최신 버전이다.

[참고]
http://jira.codehaus.org/browse/GROOVY?report=com.atlassian.jira.plugin.system.project:changelog-panel

'소개와 설치 > Groovy' 카테고리의 다른 글

Groovy 1.6에서 새로워진 것  (0) 2009.03.05
Posted by Scripter
,

아래의 두 예제의 실행 결과는 똑 같다.
이 두 예제를 통해서 Java 언어와 Scala 언어의 문법적인 차이를 알아보고자 한다.


Java 예제
 

/**
 * Filename: HelloWorld.java
 *
 *  Compile: javac -d classes HelloWorld.java
 *  Execute: java -cp classes examples.HelloWorld
 */

package examples;

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
        System.out.println("안녕하세요?");
    }
}

/*
Console Output:
Hello, world!
안녕하세요?
*/





 Scala 예제

/**
 * Filename: hello.scala
 *
 *  Compile: scalac -d classes -encoding MS949 hello.scala
 *  Execute: scala -cp classes examples.HelloWorld
 */

package examples

object HelloWorld {
    def main(args: Array[String]) {
        println("Hello, world!")
        println("안녕하세요?")
    }
}

/*
Console Output:
Hello, world!
안녕하세요?
*/



컴파일러와 인터프리터

    • javac는 명령줄에서 실행하는 Java의 컴파일 명령이고,
      scalac는 명령줄에서 실행하는 Scala의 컴파일 명령이다.
      여기서 컴파일이라 함은 소스 코드릉 번역하여
      (자바가상기계가 인식하는) 바이트 코드를 생성하는 과정을 말한다.

    • java는 명령줄에서 실행하는 Java의 인터프리터 명령이고,
      scala는 명령줄에서 실행하는 Scala의 인터프리터 명령이다.
      여기서 인터프리터 명령이라 함은 바이트 코드로 이루어진 클래스 파일을
      자바가상기계에 불러들여 인터프리트 방식으로 바이트 코드를 하나씩
      실행시킨다는 의미이다.
      명령줄에서 scala를 옵션 없이 실행하면 대화형 모드(intractive mode)에서
      Scala 코드를 직접 입력하면서 결과를 볼 수 있다. 
      이는 Python 언어의 python 명령과 유사하다.
     


Java 언어와 Scala 언어의 같은 점:

    • package 구문이 있다. (클래스 관리에 사용)
    • class 예약어가 있다.  (클래스 정의에 사용)
    • new 예약어가 있다.  (클래스 인스턴스에 사용)
    • new 예약어를 클래스명 앞에 붙인다. 
    • 중괄호 열기와 닫기 기호({와 })는 블럭을 나타내는데 사용한다.
    • String 상수의 리터럴은 쌍따옴표(")로 묶어 나타낸다.
    • String의 연결(concatenation) 연산자는 +이다.



Java 언어와 Scala 언어의 다른 점:

    • Scala는 소스 코드에 (UHC, 확장완성형) 한글이 한 자라도 포함되어 있으면,
      scalac 명령이나 scala 명령을 쓸 때 옵션 -encoding MS949를 사용한다.

    • Java 언어에서는 class 예약어로 정의된 클래스영과 소스의 파일명이 대체로
      일치하지만,  Scala 언어에서는 (public 클래스라고 하더라도) 반드시 그렇지는 않다.

    • Java 언어에서는 class 예약어로 클래스를 정의하면 그 클래스 다시 정의할 수
      없지만,  Scala 언어에서는 언제나 동일 클래스 명으로 언제나 확장 재정의할 수 있다.

    • Java 언어에서는 구문의 끝에 세미콜론(;)을 반드시 붙이지만,
      Scala 언어에서는 붙이지 않아도 된다.

    • 컨솔에 문자 출력하는 메소드가 Java 언어에서는 System.out.println이지만,
      Scala 언어에서는 println이다.

    • Java 언어와는 달리 Scala 언어에서는 클래스를 정의하는 예약어로 class 외에
      object가 있다. object 예약어로 정의된 클래스는 재정의할 수 없다.
      Scala 언어에서는 class 예약어로 정의된 클스는 언제나 확장 재정의해도 된다.
      (확장 재정의는 Ruby 언어에서도 지원하는 기능이다.)

    • 배열의 요소
       Java 언어:   배열변수명[번호]    예: args[0]
      Scala 언어:   배열변수명(번호)    예: args(0)

    • 변수의 타입선언 그리고 초기화
      Java 언어는 변수의 타입을 엄격히 적용하는 언어이지만,
      Scala 언어는 변수의 타입을 거의 엄격히 적용하는 언어이다. 여기서 '거의 엄격히'
      라고 한 것은 변수를 선언할 때 타입을 명기하지 않아도 되는 경우가 있기 때문이다.
      Scala 언어에서는 변수를 선언할 때 변수명 앞에 def, val, var 세 가지 중 하나를
      사용한다.

                 def 변수명
                 val 변수명
                 var 변수명

      그리고 변수명 뒤에는 이어서 콜론(:)과 타입명을 적어준다.

                 def 변수명 : 타입명
                 val 변수명 : 타입명
                 var 변수명 : 타입명

      또 타입명 뒤에는 이어서 등호(=)와 값을 표현하는 표현식 리터럴을 적는다.

                 def 변수명 : 타입명 = 표현식 리터럴
                 val 변수명 : 타입명 = 표현식 리터럴
                 var 변수명 : 타입명 = 표현식 리터럴

     :
                def TEN : BigInt = BigInt("10")    // BigInt 클래스는 케이스 클래스이므로
                                                             // new 예약어 없이 인스턴스된다.
                val ZERO : Double = 0.0
                var x : Int = 5

       val과 def는 그 연산 시점이 다르다.
       val로 선언된 변수는 그 우변을 계산해서 값을 할당하고 그 이후로는 줄곧
       변하지 않지만, def로 선언된 변수는 그 우변의 표현식이 저장되어, 사용될 때 마다
       그 우변의 표현식에 의하여 언제나 새로 계산된다(lazy evaluation).
        scala 인터프리터 명령으로 이 차이를 알아보자.

프롬프트> scala
Welcome to Scala version 2.7.3.final (Java HotSpot(TM) Client VM, Java 1.6.0_12)
.
Type in expressions to have them evaluated.
Type :help for more information.

scala> var x : Int = 5
x: Int = 5

scala> x = 7
x: Int = 7

scala> val y = x
y: Int = 7

scala> y = 3
<console>:6: error: reassignment to val
       y = 3
         ^

scala> def t = x*x      // lazy evaluation
t: Int

scala> t
res2: Int = 49

scala> x = 10
x: Int = 10

scala> t
res4: Int = 100

scala> exit



 

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

 

Posted by Scripter
,

'소개와 설치 > Groovy' 카테고리의 다른 글

Groovy 1.6.1 과 1.5.8 출시됨  (0) 2009.04.08
Posted by Scripter
,
http://www.digitalmars.com/d/2.0/arrays.html

D 2.0에서는
std.stdio에 writeln() 함수가 추가되었는데, 이는 writefln() 함수와는 다소 다르다.

string a = "One";
string b = "Two";
string c = "Three";
string d = "Four";

writef(a, b);
writef(c, d);

writefln(a, b);
writefln(c, d);

writeln(a, b);
writeln(c, d);


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

 

'소개와 설치 > D' 카테고리의 다른 글

What is D?  (0) 2009.02.08
Posted by Scripter
,