「コーディングを支える技術」を読んだ

コーディングを支える技術」を読んだので、感想等をしゅるしゅると書いてみます。

はじめに

自分の知らないコト(言語やフレームワークなど)について学ぼうと思った時は、Webサイトを眺めてまず軽く情報を集めることが多いのですが、特定プログラミング言語についてではなく、「コーディング」そのものについて知識を増やしたいと思ったので買いました。

自分は言語マニアな感じではなくて、「使ってみたいフレームワークがその言語で実装されてるから」程度の興味で新しいプログラミング言語を使い始めることがほとんどでした。
それでも、いくつか複数の言語を使う機会はあるので、言語間の差異に関係ない共通の概念のようなものを学びたいと思いました。

どんなかんじ


最初の1,2章は、「言語を深く効率的に学ぶには」、「プログラミング言語を俯瞰する」と、あらゆる言語を学ぶ人に役に立つ感じの内容でした。
「言語によって真偽値(true, false)が違う」など、言語設計のレベルから軽く解説がありました。
また、プログラミングの歴史を取り上げて、人間が楽をするためにプログラミングがどんどん進化している感じをつかむことが出来ました。

以降の3~12章は、言語の文法や関数、型、並行処理、オブジェクト指向などを解説していました。
複数の言語のコードを例として出して違いを見せてくれるので、自分にとってはわかりやすかったです。
また、実際に手元のPCで実行しながら確かめることもできるので、ただ本を読むだけでなく更に理解がしやすかったです。

さいごに

各章とも基礎の基礎から説明があるため、プログラミング自体の経験が少ししか無い人でも読みやすい本だと思いました。
一方で、古くから確立されているテクニックだけでなく、新しい概念についての説明もあるため、自分のようにあまり多くの言語に触れていない人にとっては、新しい言語を使う前の踏み台になったと思います。
コラムがいくつか挟まれているのですが、興味深い内容が多くあったので、飽きることなくさらさらと読むことができます。

第三回ISUCONの予選に出たけどダメだった

つい数日前に、あおみかんさん(@AknEp)としんのすけさん(@cnosuke)と一緒に、第三回ISUCONの予選に出場しました。
チーム名は、休学って楽しいよね! (まてぃー「僕はちがいます!」)でした。
(自分休学したことないです)
あおみかんさんしんのすけさんもwrite-upを書いているので、そっちも読むとより雰囲気が分かるんじゃないかなぁと思います。

予選は2日目で参加したため、競技終了後すぐに暫定版の結果が出たのですが、その時はギリギリ学生枠3位で本戦出場予定!でした。
∩(´・ヮ・`)∩やったー
ですが、提出したAMIで思った通りの記録が出ず、確定版の結果では本戦出場ができないとわかりました。
∩(´;ヮ;`)∩うわーん

どんな競技だったのか

#isucon 2013年予選問題の解説など に出題者の方からの解説がありますが、今回のお題はgistのようなWebサービスのパフォーマンス改善でした。
参加するまでは、「どんな言語の実装で来るんだろう」と不安だったのですが、Ruby, Python, Go, Node.js, PHPの実装が用意してあったので助かりました。

RubySinatraPythonはFlask、Node.jsはExpress.js(他の2つは見てないです)がベースで実装されていたのですが、チームのみんなが使えるRuby実装で取り組みました。

ちなみに競技で使ったAMIは、最新のAmazonLinuxで、nginxなど便利そうなパッケージが入ってる感じのやつでした。

何をしたのか

競技時間中はかなり必死だったので、細部まできちんと覚えていないのですが自分が試したことを書いてみます。
  • アプリケーションサーバをpumaに置き換えようとしました
    • が、オプションをうまく調節できずMySQLがToo many connectionsエラーを吐きまくったので諦めました('A`)
  • nginxを設置しました
    • フツーにunix domain socket経由でつなぎました
  • memcachedからRedisに置き換えました
    • memcachedの罠に関しては全く気づけなかったのですが、Redisのほうが早いと思ったので、置き換えました
    • 残り時間がなかったので、普段自分がさくらのVPSで使っている秘伝のredis.conf(特に凄いわけではない)を使いました
  • 使わないサービスを切りました
    • 最終的に提出したバージョンではmemcachedを使っていなかったので、パフォーマンスが上がればいいなぁくらいの思いで、chkconfigでいらなそうなサービスをぽちぽち切りました
自分ができたことはこのくらいでした。
(書き出してみると全然できてない;´Д`)
あおみかんさんしんのすけさんが、Sinatraまわりやデータベースまわりの改善をしてくださいました。

反省はしているが後悔もしている

  • そもそも、ベンチマークスクリプトの結果を競う競技なのに、改善前/改善後の比較などをしていなかったのがダメでした
    • 時間ない!って思ってしまい、てんぱってしまいました
  • 常にmasterブランチはオールグリーンな状態を死守するべきでした
    • 今回の競技の場合はベンチマークスクリプト自体が最強のテストツールになっていたので、それを回して間違いに早く気付けたら...
  • 大規模なアクセスを考えた時のベストプラクティスがわからない
    • MySQLunicornやnginxやRedisの設定を改善するだけで、かなりスコアが上がるらしかったのですが、どれをどのくらい改善すればよいのかを考えながら設定していく余裕がなかったです

    最後に

    ほぼ準備もできず、記念受験な状態だったのですが、いざ競技が始まるとみんな必死にやっていて8時間がとても濃密で楽しかったです。
    本戦に出場できないことは悔しいですが、今回の予選で大規模アクセスがあるWebサービスを構築するためにこれから勉強するべきことが見えて有意義でした。

    運営をしてくださった皆様には感謝しきれません。
    本当にありがとうございました。

      Google Summer of Code 2013に出したら落ちた

      落ちたけどProposalを書いておきます・э・

      * Title
      Extending webapp-config to work with rack


      * Abstract
      Webapp-config is a python tool which can maintain web applications
      written in PHP, usual as part of a LAMP stack.
      However today, many web applications are written in ruby and python,such as Ruby on Rails.
      Currently webapp-config does not adequately work with those web applications.
      So, I propose to extend webapp-config to work with web applications written in
      languages other than php, with emphasis on common languages use in LAMP stacks.


      * Objective
      Webapp-config can install, update, and remove web applications,
      but currently webapp-config does not adequately work with those web applications.
      So, I implement that to use Rack applications with uWSGI, Passenger, and Unicorn.
      And install Redmine and GitLab in order to make sure it works well.


      * Deliverables
      The goal is "Enhancing webapp-config to provide deployment configurations for any Rack applications."
      In particular, Rack applications will be able to install, update, and remove with webapp-config.
      To check deliverables of my, Sending e-mail to maintainer and sending pull request to git repository[3].


      * Timeline
      I will implement Rack applications support with Unicorn and Passenger by mid-term evaluations.
      I will implement Rack applications support with uWSGI and write the documents by pencils down date.
      I write next concrete schedule.

      -05/26 To check up something wrong of webapp-config by IRC and bugzilla.
      05/27- (2weeks) Read the source code and trying some simple enhance to prepare developing.
      06/17- (2weeks) Implementing Rack applications support with Unicorn.
      [06/26-07/02 Final exam week]
      07/01- (1week) Testing in various environments and to check Redmine and GitLab with Unicorn can use.
      07/08- (2weeks) Implementing Rack applications support with Passenger.
      07/22- (1week) Testing in various environments and to check Redmine and GitLab with Passenger can use.
      07/29: mid-term evaluations.
      08/05- (2weeks) Implementing Rack applications support with uWSGI.
      08/19- (1week) Testing in various environments and to check Redmine and GitLab with uWSGI can use.
      08/26- (2weeks) Writing ebuilds and testing sure whether it is possible.
      09/09- (2weeks) Writing documentation where enhanced by me.
      09/23:  'pencils down' date


      * Biography
      I am a third year undergraduate student majoring in information science at University of Tsukuba in Japan.
      I had used linux for three years, and I have started to use Gentoo Linux
      on the recommendation of a friend from two years ago.
      Currently I use Gentoo on my laptop computer and part-time job which develops web applications.
      And, I'm operating servers Redmine, GitLab and RoR applications at the company.
      I also can develop web application whose framework are Sinatra, RoR, and Flask.
      And I often write scripts by python in order to ease.
      As activities in the external, I served tutor at "Security and Programing Camp 2011"[4] and "Security Camp 2012"[5] which was organized by Information-technology Promotion Agency[6].


      * Links
      [1]: http://www.redmine.org/
      [2]: http://gitlab.org/
      [3]: git://git.overlays.gentoo.org/proj/webapp-config.git
      [4]: http://www.ipa.go.jp/jinzai/renkei/spcamp2011/
      [5]: http://www.ipa.go.jp/jinzai/renkei/camp2012/
      [6]: http://www.ipa.go.jp/index-e.html