EC2上でC#を試してみる
価値があるとは思えませんが、環境があるとC#の文法ぐらいは勉強できるかと。
root@ip-XXX-XX-XX-XX:/home/ubuntu/download# sudo add-apt-repository ppa:keks9n/monodevelop-latest Here you can find the latest MonoDevelop. monodevelop-latest package is rebuilding every time when new commits are found at http://github.com/mono/monodevelop. Checks for commits are performed every day, so you can always have the latest version. If you want to debug ASP.NET applications make sure that you are using your system Mono runtime ( http://i.imgur.com/SO93KJ2.png ). XSP isn't included to /opt/ Mono installation because of compatibility issues. More info: https://launchpad.net/~keks9n/+archive/monodevelop-latest Press [ENTER] to continue or ctrl-c to cancel adding it gpg: keyring `/tmp/tmpkgh406/secring.gpg' created gpg: keyring `/tmp/tmpkgh406/pubring.gpg' created gpg: requesting key 41A6E3C3 from hkp server keyserver.ubuntu.com gpg: /tmp/tmpkgh406/trustdb.gpg: trustdb created gpg: key 41A6E3C3: public key "Launchpad PPA for keks-n" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) OK root@ip-XXX-XX-XX-XX:/home/ubuntu/download# sudo apt-get update Ign http://ap-northeast-1.ec2.archive.ubuntu.com saucy InRelease Ign http://ap-northeast-1.ec2.archive.ubuntu.com saucy-updates InRelease Get:1 http://ap-northeast-1.ec2.archive.ubuntu.com saucy Release.gpg [933 B] Get:2 http://ap-northeast-1.ec2.archive.ubuntu.com saucy-updates Release.gpg [933 B] 途中省略 Ign http://ppa.launchpad.net saucy/main Translation-en Fetched 14.8 MB in 9s (1,521 kB/s) Reading package lists... Done root@ip-XXX-XX-XX-XX:/home/ubuntu/download# sudo apt-get install monodevelop-latest Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: 途中省略 Problem: O:System.Runtime.InteropServices.HandleRef.Conversion, with xpath: /Type/Members/Member[@MemberName='op_Conversion']/Docs Problem: O:System.Web.UI.WebControls.FontUnit.Conversion, with xpath: /Type/Members/Member[@MemberName='op_Conversion']/Docs Problem: O:System.Web.UI.WebControls.Unit.Conversion, with xpath: /Type/Members/Member[@MemberName='op_Conversion']/Docs 途中で止まる。
デスクトップ環境がないので、インストールは途中で失敗するのだと思います。
実行してみます。
root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop# gcc --version gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop# gmcs --version Mono C# compiler version 2.10.8.1 root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop# cat ./test01.cs using System; class Foo { public static void Main() { Console.WriteLine("あ"); } } root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop# gmcs ./test01.cs root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop# ./test01.exe あ root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop#
スレッドができるか確認してみると。
root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop# cat ./test02.cs using System; using System.Threading.Tasks; using System.Threading; class Test02 { static void Main() { const int N = 3; Parallel.For(0, N, id => { Random rnd = new Random(); for (int i = 0; i < 5; ++i) { Thread.Sleep(rnd.Next(1, 1000)); Console.Write("{0} (ID: {1})\n", i, id); } }); } } root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop# dmcs ./test02.cs root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop# ./test02.exe 0 (ID: 0) 1 (ID: 0) 2 (ID: 0) 3 (ID: 0) 4 (ID: 0) 0 (ID: 1) 1 (ID: 1) 2 (ID: 1) 3 (ID: 1) 4 (ID: 1) 0 (ID: 2) 1 (ID: 2) 2 (ID: 2) 3 (ID: 2) 4 (ID: 2) root@ip-XXX-XX-XX-XX:/home/ubuntu/monodevelop#
コンパイル、実行はできますが、平行に実行されていないようですねぇ。。
実際はスレッド周りのプログラミングをしたかったのに残念。