ruby

Updates on IronRuby

26 Aug 2008

Last week I went to Thailand Next Web App and joined in a Rails session. They had a talk and discussed about running Rails in production. Of course, JRuby, Glassfish and other Ruby implementation including IronRuby were mentioned. Then I was asked about it because I was the only .NET guy there. At that time, I didn’t follow the IronRuby for a long time so I replied them that no one other than John Lam and Phil Haacked have used the IronRuby.

Few days ago, while I read the feed about asp.net, I found an open source IronRuby project that aims to help developer implement WPF/Silverlight in rails-like fashion. And that’s mean we, the developers, now can use IronRuby.

After some googling, I’ve recalled that IronRuby, like IronPython, is part of the Microsoft Dynamic Language Runtime. They both are released with full source under Microsoft Public License(MS-PL). Though the source code of IronRuby is hosted on RubyForge and IronPython is on the CodePlex, the license doesn’t mention that they’re open source projects. However, the IronRuby libraries are tended to be open source and are opened to receive the contributions.

From the IronRuby home page, the implementation still does not pass the RubySpecs and can only dispatch some Rails requests. That’s mean it still cannot be used to host a Rails application. But you can utilize .NET framework and create an application with it, like IronNails. If you want to give it a try, you have to compile it yourself from the source. Of course, Windows machine is essential.

In TNWA last week, Sirn said “Don’t host your rails apps with IIS”. I’m sure the situation will change if IronRuby can host Rails app perfectly and I’m waiting for that day.

PS. As for IronPython, I saw how IronPython used with ASP.NET and it was fantastic!! However, I never have chance to try it myself.

How to reverse string

07 Aug 2007

น่าแปลกใจที่ .NET ไม่มีคำสั่งสำหรับ reverse string แฮะ

C#
public string reverse(string s){
  char[] arrS = s.ToCharArray();
  Array.Reverse( arrS );
  string reversedString = new string( arrS );
  return reversedString;
}

php

$st = 'a string';
$st=strrev($st);

ruby

a = "abcdefg"
a.reverse
=> "gfedcba"

จริงๆของ python ก็ไม่มีคำสั่ง reverse string โดยตรง แต่ว่าใน python มอง string ว่าเป็น sequence type แบบนึง ก็เลยเขียน reverse string แบบนี้ได้

python

a = "abcdefg"
a[::-1]
=>'gfedcba'

รู้สึกว่าของ python จะเท่สุดเนอะ

Technorati tags: , , , , , ,

ไม่รู้สิ ทุกวันนี้ความรู้สึกตอนที่หัดเขียน ASP.NET มันหมดไปแล้ว มันรู้สึกเหมือน "อ๋อให้ทำ xxx ด้วย ASP.NET เหรอ อืม ก็ทำได้นะ ยังแตะหรือจับพวกนี้ได้อยู่ แต่ถ้าให้ทำอะไรก็อาจจะเลือกอย่างอื่นมากกว่า"

มีอยู่ช่วงลองหันกลับมาเขียน php  แต่พอเริ่มเขียนไปได้นิดหน่อย นรกที่เคยเจอสมัยหัดเขียน php มันก็เริ่มกลับมาหลอกหลอน ตั้งแต่ magic quotes, auto slash, escape character ก็เลยระลึกขึ้นมาได้ว่าเมื่อก่อนก็เจอแบบนี้เลยเลิกเขียน php ไป ช่วงที่หัดเขียน ruby ตอนนั้นก็บังคับตัวเองว่าต้องเขียนให้เป็นให้ได้ พอเวลามาใช้จริงๆเข้าปรากฏว่าด้วยหัวของ imperative programmer ทำให้เวลาเขียน ruby แล้วไม่ค่อยก้าวหน้าเท่าไหร่ เขียนโค้ดออกมาน่าเกลียดน่ากลัวเหมือนกัน กลับไปดูแล้วก็งงว่าเขียนไปได้ยังไง ถึกมาก ส่วน rails นี่ยิ่งเขียนก็ยิ่งอึดอัด เคยทำ project ส่งด้วย rails ตอนนั้นยังใช้ไม่คล่องแต่ดันทุรัง งานเลยออกมาไม่ค่อยดีเท่าไหร่ ผิดหวังกับตัวเองไปมากจนตอนนี้ยังไม่กล้ากลับไปเขียนซักเท่าไหร่

จริงๆนี่ก็ไม่ใช่ครั้งแรกที่รู้สึกแบบนี้ แต่ตอนนี้คงเพราะมีเหตุผลอื่นด้วย หลักๆก็คงเพราะมันเบื่อล่ะมั้ง แต่ว่าเวลาเขียนอย่างอื่นมันก็ไม่คล่องเท่ากับ C# นี่สิ (ให้ JAVA มาอันดับสองละกัน)

สงสัยคงเพราะช่วงนี้อารมณ์มันออกเป็นสีเทาขุ่นมัวๆ ไม่ค่อยสดใส เหมือนทำอะไรก็แย่ไปซะทุกอย่าง

ปล. เพิ่งจะมารู้เอาตอนฝึกงานว่า ASP.NET นี่มันไม่หมูเลย โดยเฉพาะเวลาเอามาใช้กับ ASP.NET Ajax

Technorati tags: , , , , ,